bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#74217: Bootstrapping Zig with no Binary Blobs


From: Hilton Chain
Subject: bug#74217: Bootstrapping Zig with no Binary Blobs
Date: Sat, 07 Dec 2024 22:07:22 +0800

On Thu, 05 Dec 2024 14:27:14 +0800,
Hilton Chain wrote:
>
> On Mon, 02 Dec 2024 13:11:53 +0800,
> Hilton Chain wrote:
> >
> > 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:
>
> Added two procedures producing origin snippets in (gnu packages zig-xyz).
>
> 'add-build.zig.zon' for generating build.zig.zon, currently unused.
> 'rename-zig-dependencies' for replacing #:zig-inputs.

Moved to (gnu packages zig).

> I'll try to make unpack-dependencies phase reading dependencies from
> build.zig.zon instead of input labels so that we can have more specificity.

Changed install path for Zig packages to /src/zig, added a GUIX_ZIG_PACKAGE_PATH
search path (currently only in Zig 0.13 to avoid rebuilds).

Phase unpack-dependencies is changed to:
1. Find dependencies in build.zig.zon.
2. Find inputs in GUIX_ZIG_PACKAGE_PATH.
3. Per dependency, invoke "zig fetch" on matched input ('^dependency[-.]?', this
pattern expands available specificity to minor version, in case it's unavoidable
to propagate multiple versions of the same package into build environment).

With above changes, it's possible to reuse dependencies packaged in Guix, for 
example:
--8<---------------cut here---------------start------------->8---
cd $(mktemp -d)
cp --recursive --no-preserve=all $(<...>/pre-inst-env guix build --source 
zig-httpz)/. .
<...>/pre-inst-env guix shell --development zig-httpz
<...>/pre-inst-env guile -c "((@@ (guix build zig-build-system) 
unpack-dependencies))"
zig build
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
cd $(mktemp -d)
git clone https://github.com/karlseguin/http.zig && cd http.zig
git checkout zig-0.13
<...>/pre-inst-env guile -c "(eval ((@ (gnu packages zig) 
rename-zig-dependencies) '((\"metrics\" . \"zig-metrics\") (\"websocket\" . 
\"zig-websocket\"))) (interaction-environment))"
<...>/pre-inst-env guix shell zig zig-metrics zig-websocket
<...>/pre-inst-env guile -c "((@@ (guix build zig-build-system) 
unpack-dependencies))"
zig build
--8<---------------cut here---------------end--------------->8---





reply via email to

[Prev in Thread] Current Thread [Next in Thread]