Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at netboot-syslinux-multiplatform 88 lines 2.0 kB view raw
1{ lib 2, stdenv 3, fetchFromGitHub 4, cmake 5, coreutils 6, llvmPackages 7, libxml2 8, zlib 9}: 10 11stdenv.mkDerivation rec { 12 pname = "zig"; 13 version = "0.10.1"; 14 outputs = [ "out" "doc" ]; 15 16 src = fetchFromGitHub { 17 owner = "ziglang"; 18 repo = pname; 19 rev = version; 20 hash = "sha256-69QIkkKzApOGfrBdgtmxFMDytRkSh+0YiaJQPbXsBeo="; 21 }; 22 23 nativeBuildInputs = [ 24 cmake 25 llvmPackages.llvm.dev 26 ]; 27 28 buildInputs = [ 29 coreutils 30 libxml2 31 zlib 32 ] ++ (with llvmPackages; [ 33 libclang 34 lld 35 llvm 36 ]); 37 38 patches = [ 39 # Backport alignment related panics from zig-master to 0.10. 40 # Upstream issue: https://github.com/ziglang/zig/issues/14559 41 ./zig_14559.patch 42 ]; 43 44 preBuild = '' 45 export HOME=$TMPDIR; 46 ''; 47 48 postPatch = '' 49 # Zig's build looks at /usr/bin/env to find dynamic linking info. This 50 # doesn't work in Nix' sandbox. Use env from our coreutils instead. 51 substituteInPlace lib/std/zig/system/NativeTargetInfo.zig --replace "/usr/bin/env" "${coreutils}/bin/env" 52 ''; 53 54 cmakeFlags = [ 55 # file RPATH_CHANGE could not write new RPATH 56 "-DCMAKE_SKIP_BUILD_RPATH=ON" 57 58 # always link against static build of LLVM 59 "-DZIG_STATIC_LLVM=ON" 60 61 # ensure determinism in the compiler build 62 "-DZIG_TARGET_MCPU=baseline" 63 ]; 64 65 postBuild = '' 66 ./zig2 build-exe ../doc/docgen.zig 67 ./docgen ./zig2 ../doc/langref.html.in ./langref.html 68 ''; 69 70 doCheck = true; 71 72 postInstall = '' 73 install -Dm644 -t $doc/share/doc/$pname-$version/html ./langref.html 74 ''; 75 76 installCheckPhase = '' 77 $out/bin/zig test --cache-dir "$TMPDIR" -I $src/test $src/test/behavior.zig 78 ''; 79 80 meta = with lib; { 81 homepage = "https://ziglang.org/"; 82 description = 83 "General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software"; 84 license = licenses.mit; 85 maintainers = with maintainers; [ aiotter andrewrk AndersonTorres ]; 86 platforms = platforms.unix; 87 }; 88}