Skip to content

Conversation

@jmbaur
Copy link
Contributor

@jmbaur jmbaur commented Dec 22, 2025

By moving the zig setup hook to the zig derivation itself, we allow for zig to splice correctly with callPackage, meaning that the correct zig can be pulled in during builds when zig is in nativeBuildInputs (for example).

This change retains the zig.hook attribute for backward compatibility by just pointing to the zig derivation. This also removes zig_default_flags, since now the setup hook is not a derivation that can be overridden. Overriding the build flags can now be done by setting dontSetZigDefaultFlags = true.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 6.topic: zig Zig is an imperative, general-purpose, statically typed, compiled system programming language. 8.has: documentation This PR adds or changes documentation labels Dec 22, 2025
Copy link
Contributor

@jcollie jcollie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ghostty changes LGTM

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Dec 22, 2025
@nixpkgs-ci nixpkgs-ci bot requested review from GetPsyched and jcollie December 22, 2025 23:18
@jmbaur
Copy link
Contributor Author

jmbaur commented Dec 23, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review
Commit: 2be232bc5a12f1e00c8909e742720efcab38b35e


x86_64-linux

⏩ 1 package marked as broken and skipped:
  • fancy-cat
❌ 1 package failed to build:
  • roc
✅ 54 packages built:
  • arocc
  • aroccPackages.latest-unwrapped
  • aroccStdenv
  • blackshades
  • bork
  • cargo-lambda
  • cargo-zigbuild
  • creek
  • dt
  • findup
  • flow-control
  • ghostty
  • ghostty.man
  • ghostty.shell_integration
  • ghostty.terminfo
  • ghostty.vim
  • glsl_analyzer
  • hevi
  • linuxwave
  • lsr
  • ly
  • mepo
  • minizign
  • ncdu
  • nixpkgs-manual
  • odiff
  • outfieldr
  • owi
  • poop
  • river-bedload
  • river-classic
  • river-classic.man
  • river-ultitile
  • rivercarro
  • superhtml
  • tuatara
  • waylock
  • wayprompt
  • zf
  • zig
  • zig-zlint
  • zig.doc
  • zigStdenv
  • zig_0_13
  • zig_0_13.doc
  • zig_0_14
  • zig_0_14.doc
  • zigfetch
  • zigimports
  • zls
  • zls_0_14
  • zon2nix
  • zsnow
  • ztags

@jmbaur
Copy link
Contributor Author

jmbaur commented Dec 23, 2025

looks like roc is failing to build on master as well

@RossComputerGuy
Copy link
Member

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 473413
Commit: 2be232bc5a12f1e00c8909e742720efcab38b35e


aarch64-linux

❌ 10 packages failed to build:
  • cargo-lambda
  • dt
  • hevi
  • poop
  • tuatara
  • wayprompt
  • zig_0_13
  • zig_0_13.doc
  • zigimports
  • ztags
✅ 46 packages built:
  • arocc (aroccPackages.latest)
  • aroccPackages.latest-unwrapped
  • aroccStdenv
  • blackshades
  • bork
  • cargo-zigbuild
  • creek
  • findup
  • flow-control
  • ghostty
  • ghostty.man
  • ghostty.shell_integration
  • ghostty.terminfo
  • ghostty.vim
  • glsl_analyzer
  • linuxwave
  • lsr
  • ly
  • mepo
  • minizign
  • ncdu
  • nixpkgs-manual
  • odiff
  • outfieldr
  • owi
  • pkgsArocc.stdenv
  • pkgsZig.stdenv
  • river-bedload
  • river-classic
  • river-classic.man
  • river-ultitile
  • rivercarro
  • superhtml
  • waylock
  • zf
  • zig (zig_0_15)
  • zig-zlint
  • zig.doc (zig_0_15.doc)
  • zigStdenv
  • zig_0_14
  • zig_0_14.doc
  • zigfetch
  • zls (zls_0_15)
  • zls_0_14
  • zon2nix
  • zsnow

Error logs: `aarch64-linux`
zig_0_13
[17/19] Building C object CMakeFiles/zig2.dir/zig2.c.o
In file included from /nix/store/jkqdwnd0ifr3fkjif3lz003an2fhbh17-glibc-2.40-66-dev/include/bits/libc-header-start.h:33,
                 from /nix/store/jkqdwnd0ifr3fkjif3lz003an2fhbh17-glibc-2.40-66-dev/include/limits.h:26,
                 from /nix/store/35f3jqq1xw3lk9cpg7sb99nbrbgxd9ag-gcc-14.3.0/lib/gcc/aarch64-unknown-linux-gnu/14.3.0/include/limits.h:210,
                 from /nix/store/35f3jqq1xw3lk9cpg7sb99nbrbgxd9ag-gcc-14.3.0/lib/gcc/aarch64-unknown-linux-gnu/14.3.0/include/syslimits.h:7,
                 from /nix/store/35f3jqq1xw3lk9cpg7sb99nbrbgxd9ag-gcc-14.3.0/lib/gcc/aarch64-unknown-linux-gnu/14.3.0/include/limits.h:34,
                 from /build/source/stage1/zig.h:7,
                 from /build/source/build/zig2.c:2:
/nix/store/jkqdwnd0ifr3fkjif3lz003an2fhbh17-glibc-2.40-66-dev/include/features.h:422:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
  422 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
      |    ^~~~~~~
[18/19] Linking CXX executable zig2
[19/19] Building stage3
FAILED: [code=1] stage3/bin/zig /build/source/build/stage3/bin/zig 
cd /build/source && /build/source/build/zig2 build --prefix /build/source/build/stage3 --zig-lib-dir /build/source/lib -Dversion-string=0.13.0 -Dtarget=native -Dcpu=baseline -Denable-llvm -Dconfig_h=/build/source/build/config.h -Dno-langref -Dstd-docs=false -Doptimize=ReleaseFast -Dstrip
thread 502 panic: reached unreachable code
Panicked during a panic. Aborting.
error: the following build command crashed:
/build/source/.zig-cache/o/b9b398a11e453a52970dc1a24f282981/build /build/source/build/zig2 /build/source /build/source/.zig-cache /build/zig-cache --seed 0xd9349cd0 -Z00318b9f28f4b045 --prefix /build/source/build/stage3 --zig-lib-dir /build/source/lib -Dversion-string=0.13.0 -Dtarget=native -Dcpu=baseline -Denable-llvm -Dconfig_h=/build/source/build/config.h -Dno-langref -Dstd-docs=false -Doptimize=ReleaseFast -Dstrip
ninja: build stopped: subcommand failed.

@RossComputerGuy
Copy link
Member

nixpkgs-review fails to bring up a shell.

error: build log of '/nix/store/flzp1vqbvmxzfchfxan5prksw4nzi5xf-cargo-lambda-1.8.6' is not available
Posting comment on https://github.com/NixOS/nixpkgs/pull/473413
$ /run/current-system/sw/bin/nom-shell --argstr local-system aarch64-linux --argstr nixpkgs-path /home/ross/.cache/nixpkgs-review/pr-473413-4/nixpkgs --argstr
 nixpkgs-config-path /tmp/tmpbnv0n_en.nix --argstr attrs-path /home/ross/.cache/nixpkgs-review/pr-473413-4/attrs.nix --nix-path 'nixpkgs=/home/ross/.cache/nix
pkgs-review/pr-473413-4/nixpkgs nixpkgs-overlays=/tmp/tmpw7jbmnub' /nix/store/s33x7rcapdcjvn0d5phlcrnsx7rlqwkk-nixpkgs-review/lib/python3.13/site-packages/nix
pkgs_review/nix/review-shell.nix
warning: unknown setting 'eval-cores'
warning: unknown setting 'lazy-trees'
warning: unknown setting 'eval-cores'
warning: unknown setting 'lazy-trees'
/nix/store/nfryf3g47bfpdg006jmvpwg2j0dx59md-zig-0.14.1/nix-support/setup-hook: 行 4: zigDefaultCpuFlag: 読み取り専用の変数です

$ git worktree remove -f /home/ross/.cache/nixpkgs-review/pr-473413-4/nixpkgs

Bash complains about zigDefaultCpuFlag being read-only.

@jmbaur
Copy link
Contributor Author

jmbaur commented Dec 25, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review
Commit: e00cd23502d68207c20456afec6ed831fb3d63f9


aarch64-linux

⏩ 1 package marked as broken and skipped:
  • fancy-cat
✅ 54 packages built:
  • arocc
  • aroccPackages.latest-unwrapped
  • aroccStdenv
  • blackshades
  • bork
  • cargo-lambda
  • cargo-zigbuild
  • creek
  • dt
  • findup
  • flow-control
  • ghostty
  • ghostty.man
  • ghostty.shell_integration
  • ghostty.terminfo
  • ghostty.vim
  • glsl_analyzer
  • hevi
  • linuxwave
  • lsr
  • ly
  • mepo
  • minizign
  • ncdu
  • nixpkgs-manual
  • odiff
  • outfieldr
  • owi
  • poop
  • river-bedload
  • river-classic
  • river-classic.man
  • river-ultitile
  • rivercarro
  • superhtml
  • tuatara
  • waylock
  • wayprompt
  • zf
  • zig
  • zig-zlint
  • zig.doc
  • zigStdenv
  • zig_0_13
  • zig_0_13.doc
  • zig_0_14
  • zig_0_14.doc
  • zigfetch
  • zigimports
  • zls
  • zls_0_14
  • zon2nix
  • zsnow
  • ztags

@jmbaur
Copy link
Contributor Author

jmbaur commented Dec 25, 2025

nixpkgs-review fails to bring up a shell.

error: build log of '/nix/store/flzp1vqbvmxzfchfxan5prksw4nzi5xf-cargo-lambda-1.8.6' is not available
Posting comment on https://github.com/NixOS/nixpkgs/pull/473413
$ /run/current-system/sw/bin/nom-shell --argstr local-system aarch64-linux --argstr nixpkgs-path /home/ross/.cache/nixpkgs-review/pr-473413-4/nixpkgs --argstr
 nixpkgs-config-path /tmp/tmpbnv0n_en.nix --argstr attrs-path /home/ross/.cache/nixpkgs-review/pr-473413-4/attrs.nix --nix-path 'nixpkgs=/home/ross/.cache/nix
pkgs-review/pr-473413-4/nixpkgs nixpkgs-overlays=/tmp/tmpw7jbmnub' /nix/store/s33x7rcapdcjvn0d5phlcrnsx7rlqwkk-nixpkgs-review/lib/python3.13/site-packages/nix
pkgs_review/nix/review-shell.nix
warning: unknown setting 'eval-cores'
warning: unknown setting 'lazy-trees'
warning: unknown setting 'eval-cores'
warning: unknown setting 'lazy-trees'
/nix/store/nfryf3g47bfpdg006jmvpwg2j0dx59md-zig-0.14.1/nix-support/setup-hook: 行 4: zigDefaultCpuFlag: 読み取り専用の変数です

$ git worktree remove -f /home/ross/.cache/nixpkgs-review/pr-473413-4/nixpkgs

Bash complains about zigDefaultCpuFlag being read-only.

I got different results 🤔

@jmbaur
Copy link
Contributor Author

jmbaur commented Jan 3, 2026

@RossComputerGuy any chance you could take another look at this? I didn't seem to run into the same breakages you did.

Copy link
Member

@kirillrdy kirillrdy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 473413
Commit: 440c93a747de74f188145f6abb2f2771d0f5f458


x86_64-linux

✅ 57 packages built:
  • arocc (aroccPackages.latest)
  • aroccPackages.latest-unwrapped
  • aroccStdenv
  • blackshades
  • bork
  • cargo-lambda
  • cargo-zigbuild
  • creek
  • dt
  • findup
  • flow-control
  • ghostty
  • ghostty.man
  • ghostty.shell_integration
  • ghostty.terminfo
  • ghostty.vim
  • glsl_analyzer
  • hevi
  • linuxwave
  • lsr
  • ly
  • mepo
  • minizign
  • ncdu
  • nixpkgs-manual
  • odiff
  • outfieldr
  • owi
  • pkgsArocc.stdenv
  • pkgsZig.stdenv
  • poop
  • river-bedload
  • river-classic
  • river-classic.man
  • river-ultitile
  • rivercarro
  • roc
  • superhtml
  • tuatara
  • waylock
  • wayprompt
  • zf
  • zig (zig_0_15)
  • zig-zlint
  • zig.doc (zig_0_15.doc)
  • zigStdenv
  • zig_0_13
  • zig_0_13.doc
  • zig_0_14
  • zig_0_14.doc
  • zigfetch
  • zigimports
  • zls (zls_0_15)
  • zls_0_14
  • zon2nix
  • zsnow
  • ztags

@RossComputerGuy
Copy link
Member

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 473413
Commit: 440c93a747de74f188145f6abb2f2771d0f5f458


aarch64-linux

❌ 10 packages failed to build:
  • cargo-lambda
  • dt
  • hevi
  • poop
  • tuatara
  • wayprompt
  • zig_0_13
  • zig_0_13.doc
  • zigimports
  • ztags
✅ 46 packages built:
  • arocc (aroccPackages.latest)
  • aroccPackages.latest-unwrapped
  • aroccStdenv
  • blackshades
  • bork
  • cargo-zigbuild
  • creek
  • findup
  • flow-control
  • ghostty
  • ghostty.man
  • ghostty.shell_integration
  • ghostty.terminfo
  • ghostty.vim
  • glsl_analyzer
  • linuxwave
  • lsr
  • ly
  • mepo
  • minizign
  • ncdu
  • nixpkgs-manual
  • odiff
  • outfieldr
  • owi
  • pkgsArocc.stdenv
  • pkgsZig.stdenv
  • river-bedload
  • river-classic
  • river-classic.man
  • river-ultitile
  • rivercarro
  • superhtml
  • waylock
  • zf
  • zig (zig_0_15)
  • zig-zlint
  • zig.doc (zig_0_15.doc)
  • zigStdenv
  • zig_0_14
  • zig_0_14.doc
  • zigfetch
  • zls (zls_0_15)
  • zls_0_14
  • zon2nix
  • zsnow

Error logs: `aarch64-linux`
zig_0_13
[17/19] Building C object CMakeFiles/zig2.dir/zig2.c.o
In file included from /nix/store/w5qwv2s934nra3g415gf9n313ml78yhy-glibc-2.40-66-dev/include/bits/libc-header-start.h:33,
                 from /nix/store/w5qwv2s934nra3g415gf9n313ml78yhy-glibc-2.40-66-dev/include/limits.h:26,
                 from /nix/store/sbfrl6127w424l34lsq0lzryibq1226j-gcc-15.2.0/lib/gcc/aarch64-unknown-linux-gnu/15.2.0/include/limits.h:210,
                 from /nix/store/sbfrl6127w424l34lsq0lzryibq1226j-gcc-15.2.0/lib/gcc/aarch64-unknown-linux-gnu/15.2.0/include/syslimits.h:9,
                 from /nix/store/sbfrl6127w424l34lsq0lzryibq1226j-gcc-15.2.0/lib/gcc/aarch64-unknown-linux-gnu/15.2.0/include/limits.h:34,
                 from /build/source/stage1/zig.h:7,
                 from /build/source/build/zig2.c:2:
/nix/store/w5qwv2s934nra3g415gf9n313ml78yhy-glibc-2.40-66-dev/include/features.h:422:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
  422 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
      |    ^~~~~~~
[18/19] Linking CXX executable zig2
[19/19] Building stage3
FAILED: [code=1] stage3/bin/zig /build/source/build/stage3/bin/zig 
cd /build/source && /build/source/build/zig2 build --prefix /build/source/build/stage3 --zig-lib-dir /build/source/lib -Dversion-string=0.13.0 -Dtarget=native -Dcpu=baseline -Denable-llvm -Dconfig_h=/build/source/build/config.h -Dno-langref -Dstd-docs=false -Doptimize=ReleaseFast -Dstrip
thread 502 panic: reached unreachable code
Panicked during a panic. Aborting.
error: the following build command crashed:
/build/source/.zig-cache/o/f5232d885e245298b93a85be50e2a6d4/build /build/source/build/zig2 /build/source /build/source/.zig-cache /build/zig-cache --seed 0xcaf08829 -Z2e2cfc7e91752a0a --prefix /build/source/build/stage3 --zig-lib-dir /build/source/lib -Dversion-string=0.13.0 -Dtarget=native -Dcpu=baseline -Denable-llvm -Dconfig_h=/build/source/build/config.h -Dno-langref -Dstd-docs=false -Doptimize=ReleaseFast -Dstrip
ninja: build stopped: subcommand failed.

@jmbaur
Copy link
Contributor Author

jmbaur commented Jan 3, 2026

@ofborg build wayprompt

@RossComputerGuy
Copy link
Member

Huh, I still get the bash problem where it doesn't like zigDefaultCpuFlag.

@jmbaur
Copy link
Contributor Author

jmbaur commented Jan 4, 2026

I haven't personally ran into the build failures nor the bash issue. Ofborg doesn't seem to fail builds either (tested with just wayprompt, https://logs.ofborg.org/?attempt_id=e1f15a20-9be5-4213-b236-3e5a06287231&key=nixos%2Fnixpkgs.473413). Does it seem fair to chalk those issues up to something with your particular setup?

@RossComputerGuy
Copy link
Member

Idk, I don't use bash so bash is stock. This is the only PR I've seen this issue with.

@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 6, 2026
@jmbaur
Copy link
Contributor Author

jmbaur commented Jan 9, 2026

Spoke offline with @RossComputerGuy, we'll go ahead with the merge here as it's likely the breakage in his review was due to using a kernel built with 64K page size, which is known to not work well on older zig releases.

jmbaur added 5 commits January 9, 2026 14:07
By moving the zig setup hook to the zig derivation itself, we allow for
zig to splice correctly with `callPackage`, meaning that the correct zig
can be pulled in during builds when zig is in `nativeBuildInputs` (for
example).

This change retains the `zig.hook` attribute for backward compatibility
by just pointing to the zig derivation. This also removes
`zig_default_flags`, since now the setup hook is not a derivation that
can be overridden. Overriding the build flags can now be done by setting
`dontSetZigDefaultFlags = true`.
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 9, 2026
@jmbaur jmbaur added this pull request to the merge queue Jan 9, 2026
Merged via the queue into NixOS:master with commit d4815e6 Jan 9, 2026
25 checks passed
@jmbaur jmbaur deleted the zig-setup-hook branch January 9, 2026 22:21
MithicSpirit added a commit to MithicSpirit/ghostty that referenced this pull request Jan 11, 2026
As of NixOS/nixpkgs#473413[1], `zig.hook` is no longer necessary, and
optimization flags can now be included directly in `zigBuildFlags`.

[1] NixOS/nixpkgs#473413
MithicSpirit added a commit to MithicSpirit/ghostty that referenced this pull request Jan 11, 2026
As of NixOS/nixpkgs#473413[1], `zig.hook` no longer supports
`zig_default_flags`, and now they can and must be provided in
`zigBuildFlags` instead.

[1] NixOS/nixpkgs#473413
MithicSpirit added a commit to MithicSpirit/ghostty that referenced this pull request Jan 11, 2026
As of NixOS/nixpkgs#473413[1], `zig.hook` no longer supports
`zig_default_flags`, and now they can and must be provided in
`zigBuildFlags` instead.

Updating also requires removing gnome-xorg since it has been removed
from nixpkgs.

[1] NixOS/nixpkgs#473413
MithicSpirit added a commit to MithicSpirit/ghostty that referenced this pull request Jan 12, 2026
As of NixOS/nixpkgs#473413[1], `zig.hook` no longer supports
`zig_default_flags`, and now they can and must be provided in
`zigBuildFlags` instead.

Updating also requires removing gnome-xorg since it has been removed
from nixpkgs.

[1] NixOS/nixpkgs#473413
MithicSpirit added a commit to MithicSpirit/ghostty that referenced this pull request Jan 12, 2026
As of NixOS/nixpkgs#473413[1], `zig.hook` no longer supports
`zig_default_flags`, and now they can and must be provided in
`zigBuildFlags` instead.

Updating also requires removing gnome-xorg since it has been removed
from nixpkgs.

[1] NixOS/nixpkgs#473413
@mattrobenolt
Copy link

👋 I am not so much a nix expert here, but I think this is backwards incompatible change for existing uses of zig in devShells.

I think this surfaces this issue more bluntly: #270415

Since now there's not a separate zig.hook derivation. So this leaves ZIG_GLOBAL_CACHE_DIR in the devShell pointing to a temp dir that no longer exists, causing zig builds to fail.

I worked around this by adding unset ZIG_GLOBAL_CACHE_DIR in my shellHook, but just flagging this as a potential issue when I pulled in this change.

@RossComputerGuy
Copy link
Member

It is a backwards incompatible change, that's why this PR isn't being backported to a stable release. I haven't looked into that issue that much but I've definitely seen it before. I am not sure why it is happening that way. But anyone is free to look into this and submit PR's.

@jmbaur
Copy link
Contributor Author

jmbaur commented Jan 12, 2026

#479423 addresses this by setting that environment variable in configurePhase

mitchellh added a commit to ghostty-org/ghostty that referenced this pull request Jan 12, 2026
As of NixOS/nixpkgs#473413, `zig.hook` no longer supports
`zig_default_flags`, and now they can and must be provided in
`zigBuildFlags` instead.

Updating also requires removing gnome-xorg since it has been removed
from nixpkgs.

`nix flake check` succeeds on my system (x86_64-linux), with a couple
deprecation warnings that I believe aren't important.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: zig Zig is an imperative, general-purpose, statically typed, compiled system programming language. 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 12.approvals: 2 This PR was reviewed and approved by two persons. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants