Subject: [wip-zig-bootstrap] zig cache is not updated for dependencies of dependencies

From: Noé Lopez <[email-masked]>
Date: Mon, 02 Dec 2024 22:15:44 +0100

Hi,

I got my hands on packaging liskvork, a gomoku server.  The build fails
because dependencies of dependencies are not added to the zig cache, and
so can’t be found correctly by the zig build system.

I attached a patch that reproduces this, a workaround when reproducing
the steps in a local checkout is to call “zig fetch” on the missing
dependencies:

$ zig fetch /gnu/store/j0x1vl6w2vgr3fz60l4jgyx5gx53af61-zig-httpz-0-0.7d2ddae/src/zig-httpz-0-0.7d2ddae --save=httpz
warning: overwriting existing dependency named 'httpz'
$ zig build --summary all
/home/noe/.cache/zig/p/1220476906a8f57d6cbaaaeb05d44a41311a5bb6ca74bb86bc3aa1467506c241b29b/build.zig.zon:7:20: error: invalid URI: UnexpectedCharacter
$ zig fetch /gnu/store/59w4s1g1y4vy4gw3mwn9fjsfcqc5454i-zig-metrics-0-0.fcf9e94/src/zig-metrics-0-0.fcf9e94 --save=metrics
$ zig fetch /gnu/store/izxqkxplp7alrh0n3c8j8cv277nqa04a-zig-websocket-0-0.cf89cb8/src/zig-websocket-0-0.cf89cb8 --save=websocket
$ zig build --summary all
Build Summary: 5/5 steps succeeded
install success
+- install liskvork success
   +- zig build-exe liskvork Debug native-native success 3s MaxRSS:276M
      +- options cached
      +- options cached

This has the issue of adding the packages to build.zig.zon, so a better
solution is required.

I’m attaching the patch with the liskvork package and dependencies. The
error can be reproduced with “./pre-inst-env guix build liskvork”.

Have a nice day,
Noé

>From 6ff4fd23182c315c0389e547ad5654bc0571fcb8 Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
From: =?UTF-8?q?No=C3=A9=20Lopez?= <[email-masked]>
Date: Mon, 2 Dec 2024 22:10:43 +0100
Subject: [PATCH] gnu: liskvork: New package and depencies WIP.

Change-Id: Iaaff549a2f202518e4af7e5bcfb0b58d04e07f40
---
 gnu/packages/zig-xyz.scm | 187 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 187 insertions(+)

diff --git a/gnu/packages/zig-xyz.scm b/gnu/packages/zig-xyz.scm
index d7210af594..b6c250eb64 100644
--- a/gnu/packages/zig-xyz.scm
+++ b/gnu/packages/zig-xyz.scm
@@ -83,6 +83,193 @@ (define-public zig-known-folders
       (home-page "https://github.com/ziglibs/known-folders")
       (license license:expat))))
 
+(define-public zig-ini
+  ;; No releases.
+  (let ((commit "e18d36665905c1e7ba0c1ce3e8780076b33e3002")
+        (revision "0"))
+    (package
+      (name "zig-ini")
+      (version (git-version "0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/ziglibs/ini.git")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0b1688g6kvcrbr8pbl3glv09fpd27p5z2bif8jmn6km6myq5fs1y"))))
+      (build-system zig-build-system)
+      (home-page "https://github.com/ziglibs/ini")
+      (synopsis "Simple INI parser")
+      (description "INI is a very simple ini-parser library that provides:
+@itemize
+@item Raw record reading
+@item Leading/trailing whitespace removal
+@item comments based on ; and #
+@item Zig API
+@item C API
+@end itemize")
+      (license license:expat))))
+
+(define-public zig-metrics
+  ;; No releases, latest commit from zig-0.13 branch.
+  (let ((commit "fcf9e94fa54a20f4954e9821801c32e44d407a2f")
+        (revision "0"))
+    (package
+      (name "zig-metrics")
+      (version (git-version "0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/karlseguin/metrics.zig.git")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1vvfy97ak5xwvwv3rkqsgsj644298d3c75645386qf4psija6a25"))))
+      (build-system zig-build-system)
+      (arguments (list #:skip-build? #t)) ;fails to build examples
+      (home-page "https://github.com/karlseguin/metrics.zig")
+      (synopsis "Prometheus metrics library")
+      (description "metrics is a library designed for using Prometheus metrics.  It
+supports, counters, gauges and histograms and the labeled-variant of each.")
+      (license license:expat))))
+
+(define-public zig-logz
+  ;; No releases, latest commit from zig-0.13 branch.
+  (let ((commit "5d5bbaeb98ad30cda30c60ab0f2d1a7fb4890676")
+        (revision "0"))
+    (package
+      (name "zig-logz")
+      (version (git-version "0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/karlseguin/log.zig.git")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "01xihyvyx3rpv0kvjh6mg1b99d6agq683q4iyn39nwqb6ma0i0sz"))))
+      (build-system zig-build-system)
+      (arguments
+       (list
+        #:zig-inputs `(("metrics" ,zig-metrics))))
+      (home-page "https://github.com/karlseguin/log.zig")
+      (synopsis "Structured Logging for Zig")
+      (description "logz is an opinionated structured logger that outputs to stdout,
+stderr, a file or a custom writer using logfmt or JSON.  It aims to minimize runtime
+memory allocation by using a pool of pre-allocated loggers.")
+      (license license:expat))))
+
+(define-public zig-zul
+  ;; No releases.
+  (let ((commit "f122a0079309f88991aa014cb885500a977ca450")
+        (revision "0"))
+    (package
+      (name "zig-zul")
+      (version (git-version "0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/karlseguin/zul.git")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1aajy6ygrzzq089g71yg7nw3fiklfckl606rysibfhg64d1w3pvl"))))
+      (build-system zig-build-system)
+      (arguments (list #:tests? #f))    ;fifty-five compilation errors
+      (home-page "https://www.goblgobl.com/zul/")
+      (synopsis "Zig utility library")
+      (description "The purpose of this library is to enhance Zig's standard
+library. Much of zul wraps Zig's std to provide simpler APIs for common
+tasks (e.g. reading lines from a file). In other cases, new functionality has been
+added (e.g. a UUID type).
+
+Besides Zig's standard library, there are no dependencies. Most functionality is
+contained within its own file and can easily be copy and pasted into an existing
+library or project.")
+      (license license:expat))))
+
+(define-public zig-websocket
+  ;; No releases, latest commit from zig-0.13 branch
+  (let ((commit "cf89cb8b9c61c99982ced19da54890983e226245")
+        (revision "0"))
+  (package
+    (name "zig-websocket")
+    (version (git-version "0" revision commit))
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/karlseguin/websocket.zig.git")
+                    (commit commit)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1q85pvc1dgyj5zdpk3xav1zgj6857p0nygndz3nc5xlm260hrck8"))))
+    (build-system zig-build-system)
+    (home-page "https://github.com/karlseguin/websocket.zig")
+    (synopsis "WebSocket implementation for Zig")
+    (description "")
+    (license license:expat))))
+
+(define-public zig-httpz
+  ;; No releases, latest commit from zig-0.13 branch
+  (let ((commit "7d2ddae87af9b110783085c0ea6b03985faa4584")
+        (revision "0"))
+  (package
+    (name "zig-httpz")
+    (version (git-version "0" revision commit))
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/karlseguin/http.zig.git")
+                    (commit commit)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "02hixvyx1r04lg0nzvhkyrqwcwm8m8rs8hm01n2nzw6jv935frh8"))))
+    (build-system zig-build-system)
+    (arguments
+     (list #:zig-inputs
+           `(("metrics" ,zig-metrics)
+             ("websocket" ,zig-websocket))))
+    (home-page "https://github.com/karlseguin/http.zig")
+    (synopsis "HTTP/1.1 server for Zig")
+    (description "")
+    (license license:expat))))
+
+(define-public liskvork
+  (package
+    (name "liskvork")
+    (version "0.5.1")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/liskvork/liskvork")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1x7cif9wpaq7mk1pqmixq3flymrradb6zpx5qnmiihw699zr2xhw"))))
+    (build-system zig-build-system)
+    (arguments
+     (list #:install-source? #f
+           #:zig-release-type "safe"
+           #:zig-inputs
+           `(("ini" ,zig-ini)
+             ("logz" ,zig-logz)
+             ("zul" ,zig-zul)
+             ("httpz" ,zig-httpz))))
+    (home-page "https://liskvork.org")
+    (synopsis "Modern multi-platform gomoku game server.")
+    (description "liskvork is a modern Gomoku game server that is purpose-built for
+AI matches.  It is almost completely configurable and backwards compatible with older
+AIs made for previous Gomoku managers such as Piskvork.")
+    (license license:gpl3)))
+
 (define-public river
   (package
     (name "river")

base-commit: ceb267f7c108050633136b0abbd0964b6f31882c
-- 
2.46.0