1
0

Compare commits

..

No commits in common. "9286a82d8621650bc279c93e982400014ba90e06" and "de3e031dcf4fc6b2cc8e737ad35af8448d7296e8" have entirely different histories.

3 changed files with 62 additions and 32 deletions

22
LICENSE
View File

@ -1,22 +0,0 @@
MIT License
Copyright (c) 2023 xeals
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -11,24 +11,19 @@
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 = pkgs.stdenv.mkDerivation {
packages.default = buildZigPackage {
name = "aoc23";
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
nativeBuildInputs = [ zig.hook ];
meta = {
description = "Advent of Code 2023";
homepage = "https://git.xeal.me/xeals/aoc23";
license = nixpkgs.lib.licenses.mit;
inherit (zig.meta) platforms;
};
};
});
}

57
nix/build-zig-package.nix Normal file
View File

@ -0,0 +1,57 @@
{ 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;
})