1
0

Remove build-zig-package

Turns out this actually is already implemented upstream.
This commit is contained in:
xeals 2023-11-30 12:52:45 +11:00
parent de3e031dcf
commit 52371f9e13
Signed by: xeals
SSH Key Fingerprint: SHA256:pRv+8swQDA+/LuZ7NHj9m006BbKexlNK62OUA01ZZBc
2 changed files with 9 additions and 62 deletions

View File

@ -11,19 +11,23 @@
let
pkgs = import nixpkgs { inherit system; };
zig = pkgs.zig_0_11;
buildZigPackage = import ./nix/build-zig-package.nix {
inherit (pkgs) stdenv;
inherit zig;
};
in
{
devShells.default = pkgs.mkShellNoCC {
buildInputs = [ zig pkgs.zls ];
};
packages.default = buildZigPackage {
packages.default = pkgs.stdenv.mkDerivation {
name = "aoc23";
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
nativeBuildInputs = [ zig.hook ];
meta = {
description = "Advent of Code 2023";
homepage = "https://git.xeal.me/xeals/aoc23";
inherit (zig.meta) platforms;
};
};
});
}

View File

@ -1,57 +0,0 @@
{ stdenv
, zig
}:
{ buildInputs ? [ ]
, nativeBuildInputs ? [ ]
, optimize ? "ReleaseSafe"
, meta ? { }
, ...
}@args:
stdenv.mkDerivation (args // {
nativeBuildInputs = nativeBuildInputs ++ [
zig
];
buildInputs = buildInputs;
strictDeps = true;
configurePhase = args.configurePhase or ''
runHook preConfigure
runHook postConfigure
'';
ZIGFLAGS = args.ZIGFLAGS or [
"-Doptimize=${optimize}"
];
# https://github.com/ziglang/zig/issues/6810 requires setting XDG_CACHE_HOME
# in all zig build phases. --cache-dir and --global-cache-dir do not prevent
# the builder from attempting to create the XDG cache.
buildPhase = args.buildPhase or ''
runHook preBuild
XDG_CACHE_HOME=_cache zig build $ZIGFLAGS
runHook postBuild
'';
doCheck = args.doCheck or true;
checkPhase = args.checkPhase or ''
runHook preCheck
XDG_CACHE_HOME=_cache zig build test $ZIGFLAGS
runHook postCheck
'';
installPhase = args.installPhase or ''
runHook preInstall
XDG_CACHE_HOME=_cache zig build install --prefix $out $ZIGFLAGS
runHook postInstall
'';
meta = {
# default to Zig's platforms
platforms = zig.meta.platforms;
} // meta;
})