Subject: Re: Bootstrapping Zig with no Binary Blobs

From: Hilton Chain <[email-masked]>
Date: Mon, 02 Dec 2024 13:11:53 +0800

On Thu, 28 Nov 2024 19:08:09 +0800,
Hilton Chain wrote:
>
> Made "#:zig-inputs" a private keyword, its value will be passed to inputs like
> cargo-build-system (the build system doesn't extract the whole closure for
> now, this can be added in the future depending on how Zig ecosystem develops).

Just thought if we can avoid using #:zig-inputs, it turns out doing so is quite
easy:
--8<---------------cut here---------------start------------->8---
@@ -330,9 +327,20 @@ (define-public zig-zls-0.12
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "1ini1ifa9b0v2ika3sqsiiv2p7v9npfslss45280yxwn2pjqmn7n"))))
+                "1ini1ifa9b0v2ika3sqsiiv2p7v9npfslss45280yxwn2pjqmn7n"))
+              (modules '((guix build utils)))
+              (snippet
+               #~(begin
+                   (substitute* "build.zig"
+                     (("(b\\.dependency.\")diffz" _ prefix)
+                      (string-append prefix "zig-diffz"))
+                     (("(b\\.dependency.\")known_folders" _ prefix)
+                      (string-append prefix "zig-known-folders")))
+                   (substitute* "build.zig.zon"
+                     (("\\.diffz") ".@\"zig-diffz\"")
+                     (("\\.known_folders") ".@\"zig-known-folders\""))))))
     (build-system zig-build-system)
-    (inputs (list zig-0.12))
+    (inputs (list zig-0.12 zig-diffz zig-known-folders))
     (arguments
      (let ((version-data-path
             #~(string-append "-Dversion_data_path="
@@ -344,7 +352,4 @@ (define-public zig-zls-0.12
              #:zig-build-flags
              #~(list #$version-data-path)
              #:zig-test-flags
-             #~(list #$version-data-path)
-             #:zig-inputs
-             `(("known_folders" ,zig-known-folders)
-               ("diffz" ,zig-diffz)))))))
+             #~(list #$version-data-path))))))

 (define-public zig-zls-0.13
   (package
--8<---------------cut here---------------end--------------->8---

I also continued the bootstrap path to current master:
https://paste.sr.ht/~hako/584dd15fd1614f23e6a421b906092a1b28614148