1
0

Compare commits

..

2 Commits

Author SHA1 Message Date
9286a82d86
Add LICENSE
All checks were successful
Build and test / test (push) Successful in 2m44s
2023-11-30 12:57:50 +11:00
52371f9e13
Remove build-zig-package
Turns out this actually is already implemented upstream.
2023-11-30 12:52:45 +11:00
3 changed files with 32 additions and 62 deletions

22
LICENSE Normal file
View File

@ -0,0 +1,22 @@
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,19 +11,24 @@
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";
license = nixpkgs.lib.licenses.mit;
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;
})