Something went wrong. Try again.
What happens if I push all of nixpkgs
Something went wrong. Try again.
1.9 kB · 62 lines
Nix
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263{ lib, makeSetupHook, zig, stdenv, xcbuild,}:
makeSetupHook { name = "zig-hook";
propagatedBuildInputs = [ zig ] # while xcrun is already included in the darwin stdenv, Zig also needs # xcode-select (provided by xcbuild) for SDK detection ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcbuild ];
substitutions = { # This zig_default_flags below is meant to avoid CPU feature impurity in # Nixpkgs. However, this flagset is "unstable": it is specifically meant to # be controlled by the upstream development team - being up to that team # exposing or not that flags to the outside (especially the package manager # teams).
# Because of this hurdle, @andrewrk from Zig Software Foundation proposed # some solutions for this issue. Hopefully they will be implemented in # future releases of Zig. When this happens, this flagset should be # revisited accordingly.
# Below are some useful links describing the discovery process of this 'bug' # in Nixpkgs:
# https://github.com/NixOS/nixpkgs/issues/169461 # https://github.com/NixOS/nixpkgs/issues/185644 # https://github.com/NixOS/nixpkgs/pull/197046 # https://github.com/NixOS/nixpkgs/pull/241741#issuecomment-1624227485 # https://github.com/ziglang/zig/issues/14281#issuecomment-1624220653
zig_default_flags = let releaseType = if lib.versionAtLeast zig.version "0.12" then "--release=safe" else if lib.versionAtLeast zig.version "0.11" then "-Doptimize=ReleaseSafe" else "-Drelease-safe=true"; in [ "-Dcpu=baseline" releaseType ]; };
passthru = { inherit zig; };
meta = { description = "Setup hook for using the Zig compiler in Nixpkgs"; inherit (zig.meta) maintainers platforms broken; };} ./setup-hook.sh