2021-05-20 23:08:51 +00:00
|
|
|
{ lib
|
2022-07-18 16:21:45 +00:00
|
|
|
, stdenv
|
2021-05-20 23:08:51 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, llvmPackages
|
|
|
|
, libxml2
|
|
|
|
, zlib
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "zig";
|
2022-02-20 05:27:41 +00:00
|
|
|
version = "0.9.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ziglang";
|
2023-07-15 17:15:38 +00:00
|
|
|
repo = "zig";
|
|
|
|
rev = finalAttrs.version;
|
2022-02-20 05:27:41 +00:00
|
|
|
hash = "sha256-x2c4c9RSrNWGqEngio4ArW7dJjW0gg+8nqBwPcR721k=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-01-11 07:51:40 +00:00
|
|
|
patches = [
|
|
|
|
# Fix index out of bounds reading RPATH (cherry-picked from 0.10-dev)
|
|
|
|
./rpath.patch
|
|
|
|
# Fix build on macOS 13 (cherry-picked from 0.10-dev)
|
|
|
|
./ventura.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
# TODO: remove on next upgrade
|
2023-07-15 17:15:38 +00:00
|
|
|
prePatch = let
|
|
|
|
zig_0_10_0 = fetchFromGitHub {
|
|
|
|
owner = "ziglang";
|
|
|
|
repo = "zig";
|
|
|
|
rev = "0.10.0";
|
|
|
|
hash = "sha256-DNs937N7PLQimuM2anya4npYXcj6cyH+dRS7AiOX7tw=";
|
|
|
|
};
|
|
|
|
in ''
|
2023-01-11 07:51:40 +00:00
|
|
|
cp -R ${zig_0_10_0}/lib/libc/include/any-macos.13-any lib/libc/include/any-macos.13-any
|
|
|
|
cp -R ${zig_0_10_0}/lib/libc/include/aarch64-macos.13-none lib/libc/include/aarch64-macos.13-gnu
|
|
|
|
cp -R ${zig_0_10_0}/lib/libc/include/x86_64-macos.13-none lib/libc/include/x86_64-macos.13-gnu
|
|
|
|
cp ${zig_0_10_0}/lib/libc/darwin/libSystem.13.tbd lib/libc/darwin/
|
|
|
|
'';
|
2022-08-21 13:32:41 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
nativeBuildInputs = [
|
2021-06-06 07:54:09 +00:00
|
|
|
cmake
|
|
|
|
llvmPackages.llvm.dev
|
2021-05-20 23:08:51 +00:00
|
|
|
];
|
2022-02-20 05:27:41 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
buildInputs = [
|
|
|
|
libxml2
|
|
|
|
zlib
|
2021-05-20 23:08:51 +00:00
|
|
|
] ++ (with llvmPackages; [
|
|
|
|
libclang
|
|
|
|
lld
|
|
|
|
llvm
|
|
|
|
]);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
export HOME=$TMPDIR;
|
|
|
|
'';
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
# file RPATH_CHANGE could not write new RPATH
|
|
|
|
"-DCMAKE_SKIP_BUILD_RPATH=ON"
|
2023-02-22 10:55:15 +00:00
|
|
|
|
|
|
|
# ensure determinism in the compiler build
|
|
|
|
"-DZIG_TARGET_MCPU=baseline"
|
2022-08-12 12:06:08 +00:00
|
|
|
];
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
doCheck = true;
|
2023-07-15 17:15:38 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
./zig test --cache-dir "$TMPDIR" -I $src/test $src/test/behavior.zig
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
meta = {
|
2021-05-20 23:08:51 +00:00
|
|
|
homepage = "https://ziglang.org/";
|
2020-04-24 23:36:52 +00:00
|
|
|
description =
|
|
|
|
"General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software";
|
2023-07-15 17:15:38 +00:00
|
|
|
license = lib.licenses.mit;
|
|
|
|
changelog = "https://ziglang.org/download/${finalAttrs.version}/release-notes.html";
|
|
|
|
maintainers = with lib.maintainers; [ aiotter andrewrk AndersonTorres ];
|
|
|
|
platforms = lib.platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2023-07-15 17:15:38 +00:00
|
|
|
})
|