Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 24.05-beta 51 lines 1.7 kB view raw
1{ lib 2, makeSetupHook 3, zig 4}: 5 6makeSetupHook { 7 name = "zig-hook"; 8 9 propagatedBuildInputs = [ zig ]; 10 11 substitutions = { 12 # This zig_default_flags below is meant to avoid CPU feature impurity in 13 # Nixpkgs. However, this flagset is "unstable": it is specifically meant to 14 # be controlled by the upstream development team - being up to that team 15 # exposing or not that flags to the outside (especially the package manager 16 # teams). 17 18 # Because of this hurdle, @andrewrk from Zig Software Foundation proposed 19 # some solutions for this issue. Hopefully they will be implemented in 20 # future releases of Zig. When this happens, this flagset should be 21 # revisited accordingly. 22 23 # Below are some useful links describing the discovery process of this 'bug' 24 # in Nixpkgs: 25 26 # https://github.com/NixOS/nixpkgs/issues/169461 27 # https://github.com/NixOS/nixpkgs/issues/185644 28 # https://github.com/NixOS/nixpkgs/pull/197046 29 # https://github.com/NixOS/nixpkgs/pull/241741#issuecomment-1624227485 30 # https://github.com/ziglang/zig/issues/14281#issuecomment-1624220653 31 32 zig_default_flags = 33 let 34 releaseType = 35 if lib.versionAtLeast zig.version "0.12" then 36 "--release=safe" 37 else if lib.versionAtLeast zig.version "0.11" then 38 "-Doptimize=ReleaseSafe" 39 else 40 "-Drelease-safe=true"; 41 in 42 [ "-Dcpu=baseline" releaseType ]; 43 }; 44 45 passthru = { inherit zig; }; 46 47 meta = { 48 description = "A setup hook for using the Zig compiler in Nixpkgs"; 49 inherit (zig.meta) maintainers platforms broken; 50 }; 51} ./setup-hook.sh