diff --git a/pkgs/development/compilers/zig/0.10.nix b/pkgs/development/compilers/zig/0.10.nix new file mode 100644 index 000000000000..89f23b9ca25d --- /dev/null +++ b/pkgs/development/compilers/zig/0.10.nix @@ -0,0 +1,69 @@ +{ lib +, stdenv +, fetchFromGitHub +, cmake +, coreutils +, llvmPackages +, libxml2 +, zlib +}: + +stdenv.mkDerivation rec { + pname = "zig"; + version = "0.10.1"; + + src = fetchFromGitHub { + owner = "ziglang"; + repo = pname; + rev = version; + hash = "sha256-69QIkkKzApOGfrBdgtmxFMDytRkSh+0YiaJQPbXsBeo="; + }; + + nativeBuildInputs = [ + cmake + llvmPackages.llvm.dev + ]; + + buildInputs = [ + coreutils + libxml2 + zlib + ] ++ (with llvmPackages; [ + libclang + lld + llvm + ]); + + preBuild = '' + export HOME=$TMPDIR; + ''; + + postPatch = '' + # Zig's build looks at /usr/bin/env to find dynamic linking info. This + # doesn't work in Nix' sandbox. Use env from our coreutils instead. + substituteInPlace lib/std/zig/system/NativeTargetInfo.zig --replace "/usr/bin/env" "${coreutils}/bin/env" + ''; + + cmakeFlags = [ + # file RPATH_CHANGE could not write new RPATH + "-DCMAKE_SKIP_BUILD_RPATH=ON" + ]; + + doCheck = true; + installCheckPhase = '' + $out/bin/zig test --cache-dir "$TMPDIR" -I $src/test $src/test/behavior.zig + ''; + + meta = with lib; { + homepage = "https://ziglang.org/"; + description = + "General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software"; + license = licenses.mit; + maintainers = with maintainers; [ aiotter andrewrk AndersonTorres ]; + platforms = platforms.unix; + # Build fails on Darwin on both AArch64 and x86_64: + # https://github.com/NixOS/nixpkgs/pull/210324#issuecomment-1381313616 + # https://github.com/NixOS/nixpkgs/pull/210324#issuecomment-1381236045 + broken = stdenv.isDarwin; + }; +} diff --git a/pkgs/development/compilers/zig/default.nix b/pkgs/development/compilers/zig/0.9.1.nix similarity index 100% rename from pkgs/development/compilers/zig/default.nix rename to pkgs/development/compilers/zig/0.9.1.nix diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 763a6e0e62dd..07b67f820ca0 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5406,9 +5406,13 @@ with pkgs; rex = callPackage ../tools/system/rex { }; - river = callPackage ../applications/window-managers/river { }; + river = callPackage ../applications/window-managers/river { + zig = zig_0_9; + }; - rivercarro = callPackage ../applications/misc/rivercarro { }; + rivercarro = callPackage ../applications/misc/rivercarro { + zig = zig_0_9; + }; rmapi = callPackage ../applications/misc/remarkable/rmapi { }; @@ -7254,7 +7258,9 @@ with pkgs; findutils = callPackage ../tools/misc/findutils { }; - findup = callPackage ../tools/misc/findup { }; + findup = callPackage ../tools/misc/findup { + zig = zig_0_9; + }; bsd-finger = callPackage ../tools/networking/bsd-finger { }; bsd-fingerd = bsd-finger.override({ buildClient = false; }); @@ -18814,7 +18820,9 @@ with pkgs; ytt = callPackage ../development/tools/ytt {}; - zls = callPackage ../development/tools/zls { }; + zls = callPackage ../development/tools/zls { + zig = zig_0_9; + }; zydis = callPackage ../development/libraries/zydis { }; @@ -23833,9 +23841,15 @@ with pkgs; libzra = callPackage ../development/libraries/libzra { }; # requires a newer Apple SDK - zig = darwin.apple_sdk_11_0.callPackage ../development/compilers/zig { + zig_0_9 = darwin.apple_sdk_11_0.callPackage ../development/compilers/zig/0.9.1.nix { llvmPackages = llvmPackages_13; }; + # requires a newer Apple SDK + zig_0_10 = darwin.apple_sdk_11_0.callPackage ../development/compilers/zig/0.10.nix { + llvmPackages = llvmPackages_15; + }; + # Zig 0.10.1 is broken on Darwin, so use 0.9.1 on Darwin instead. + zig = if stdenv.isDarwin then zig_0_9 else zig_0_10; zimlib = callPackage ../development/libraries/zimlib { }; @@ -30187,7 +30201,9 @@ with pkgs; waybar = callPackage ../applications/misc/waybar {}; - waylock = callPackage ../applications/misc/waylock {}; + waylock = callPackage ../applications/misc/waylock { + zig = zig_0_9; + }; wayshot = callPackage ../tools/misc/wayshot { }; @@ -31104,7 +31120,9 @@ with pkgs; merkaartor = libsForQt5.callPackage ../applications/misc/merkaartor { }; - mepo = callPackage ../applications/misc/mepo { }; + mepo = callPackage ../applications/misc/mepo { + zig = zig_0_9; + }; meshcentral = callPackage ../tools/admin/meshcentral { }; @@ -31743,7 +31761,9 @@ with pkgs; netcoredbg = callPackage ../development/tools/misc/netcoredbg { }; - ncdu = callPackage ../tools/misc/ncdu { }; + ncdu = callPackage ../tools/misc/ncdu { + zig = zig_0_9; + }; ncdu_1 = callPackage ../tools/misc/ncdu/1.nix { }; ncdc = callPackage ../applications/networking/p2p/ncdc { }; @@ -34768,7 +34788,9 @@ with pkgs; inherit (perlPackages) PathTiny; }; - blackshades = callPackage ../games/blackshades { }; + blackshades = callPackage ../games/blackshades { + zig = zig_0_9; + }; blobby = callPackage ../games/blobby { };