2023-08-05 14:07:23 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, llvmPackages
|
|
|
|
, libxml2
|
|
|
|
, zlib
|
|
|
|
, coreutils
|
2023-08-10 00:43:09 +00:00
|
|
|
, callPackage
|
2023-08-05 14:07:23 +00:00
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
|
2023-08-05 14:07:49 +00:00
|
|
|
args:
|
2023-08-05 14:07:23 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
|
|
pname = "zig";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ziglang";
|
|
|
|
repo = "zig";
|
|
|
|
rev = finalAttrs.version;
|
2023-08-05 14:07:49 +00:00
|
|
|
inherit (args) hash;
|
2023-08-05 14:07:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
llvmPackages.llvm.dev
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
libxml2
|
|
|
|
zlib
|
|
|
|
] ++ (with llvmPackages; [
|
|
|
|
libclang
|
|
|
|
lld
|
|
|
|
llvm
|
|
|
|
]);
|
|
|
|
|
2023-08-05 14:07:49 +00:00
|
|
|
env.ZIG_GLOBAL_CACHE_DIR = "$TMPDIR/zig-cache";
|
2023-08-05 14:07:23 +00:00
|
|
|
|
|
|
|
# Zig's build looks at /usr/bin/env to find dynamic linking info. This doesn't
|
|
|
|
# work in Nix's sandbox. Use env from our coreutils instead.
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace lib/std/zig/system/NativeTargetInfo.zig \
|
|
|
|
--replace "/usr/bin/env" "${coreutils}/bin/env"
|
|
|
|
'';
|
|
|
|
|
2023-08-05 14:07:49 +00:00
|
|
|
doInstallCheck = true;
|
2023-08-05 14:07:23 +00:00
|
|
|
installCheckPhase = ''
|
|
|
|
runHook preInstallCheck
|
|
|
|
|
|
|
|
$out/bin/zig test --cache-dir "$TMPDIR/zig-test-cache" -I $src/test $src/test/behavior.zig
|
|
|
|
|
|
|
|
runHook postInstallCheck
|
|
|
|
'';
|
|
|
|
|
2023-08-10 00:43:09 +00:00
|
|
|
passthru = {
|
|
|
|
hook = callPackage ./hook.nix {
|
|
|
|
zig = finalAttrs.finalPackage;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-08-05 14:07:23 +00:00
|
|
|
meta = {
|
|
|
|
description = "General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software";
|
|
|
|
homepage = "https://ziglang.org/";
|
|
|
|
changelog = "https://ziglang.org/download/${finalAttrs.version}/release-notes.html";
|
|
|
|
license = lib.licenses.mit;
|
2023-08-22 02:33:37 +00:00
|
|
|
maintainers = with lib.maintainers; [ andrewrk ] ++ lib.teams.zig.members;
|
2023-08-05 14:07:23 +00:00
|
|
|
platforms = lib.platforms.unix;
|
|
|
|
};
|
2023-08-05 14:07:49 +00:00
|
|
|
} // removeAttrs args [ "hash" ])
|