Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 24.05-beta 75 lines 1.8 kB view raw
1{ lib 2, stdenv 3, fetchFromGitHub 4, cmake 5, llvmPackages 6, libxml2 7, zlib 8, coreutils 9, callPackage 10, ... 11}: 12 13args: 14 15stdenv.mkDerivation (finalAttrs: { 16 pname = "zig"; 17 18 src = fetchFromGitHub { 19 owner = "ziglang"; 20 repo = "zig"; 21 rev = finalAttrs.version; 22 inherit (args) hash; 23 }; 24 25 nativeBuildInputs = [ 26 cmake 27 llvmPackages.llvm.dev 28 ]; 29 30 buildInputs = [ 31 libxml2 32 zlib 33 ] ++ (with llvmPackages; [ 34 libclang 35 lld 36 llvm 37 ]); 38 39 env.ZIG_GLOBAL_CACHE_DIR = "$TMPDIR/zig-cache"; 40 41 # Zig's build looks at /usr/bin/env to find dynamic linking info. This doesn't 42 # work in Nix's sandbox. Use env from our coreutils instead. 43 postPatch = if lib.versionAtLeast args.version "0.12" then '' 44 substituteInPlace lib/std/zig/system.zig \ 45 --replace "/usr/bin/env" "${coreutils}/bin/env" 46 '' else '' 47 substituteInPlace lib/std/zig/system/NativeTargetInfo.zig \ 48 --replace "/usr/bin/env" "${coreutils}/bin/env" 49 ''; 50 51 doInstallCheck = true; 52 installCheckPhase = '' 53 runHook preInstallCheck 54 55 $out/bin/zig test --cache-dir "$TMPDIR/zig-test-cache" -I $src/test $src/test/behavior.zig 56 57 runHook postInstallCheck 58 ''; 59 60 passthru = { 61 hook = callPackage ./hook.nix { 62 zig = finalAttrs.finalPackage; 63 }; 64 }; 65 66 meta = { 67 description = "General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software"; 68 homepage = "https://ziglang.org/"; 69 changelog = "https://ziglang.org/download/${finalAttrs.version}/release-notes.html"; 70 license = lib.licenses.mit; 71 maintainers = with lib.maintainers; [ andrewrk ] ++ lib.teams.zig.members; 72 mainProgram = "zig"; 73 platforms = lib.platforms.unix; 74 }; 75} // removeAttrs args [ "hash" ])