nix: Add checks
This commit is contained in:
parent
264846a521
commit
e7206e5aa2
6
answers.nix
Normal file
6
answers.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
day1 = {
|
||||
part1 = "53194";
|
||||
part2 = "54249";
|
||||
};
|
||||
}
|
35
flake.nix
35
flake.nix
|
@ -34,6 +34,7 @@
|
|||
ghc94Pkgs = pkgs.haskell.packages.ghc94.override {
|
||||
overrides = ghcOverrides;
|
||||
};
|
||||
answers = import ./answers.nix;
|
||||
in rec {
|
||||
packages = rec {
|
||||
dev-env = ghc94Pkgs.shellFor {
|
||||
|
@ -43,10 +44,42 @@
|
|||
(pkgs.haskell-language-server.override {supportedGhcVersions = ["948"];})
|
||||
pkgs.cabal2nix
|
||||
pkgs.ormolu
|
||||
pkgs.shellcheck
|
||||
];
|
||||
};
|
||||
aoc2023 = ghc94Pkgs.aoc2023;
|
||||
aoc2023-haskell = ghc94Pkgs.aoc2023;
|
||||
aoc2023-bash =
|
||||
let bashDir = pkgs.runCommand "aoc2023-bash" {} ''
|
||||
mkdir $out
|
||||
cp -r ${./bash} $out/bin
|
||||
chmod -R +w $out
|
||||
patchShebangs $out
|
||||
'';
|
||||
in pkgs.writeShellApplication {
|
||||
name = "aoc2023";
|
||||
runtimeInputs = [ pkgs.util-linux ];
|
||||
text = ''
|
||||
${bashDir}/bin/main.sh "''${@}"
|
||||
'';
|
||||
};
|
||||
};
|
||||
checks =
|
||||
let mkCheck = (prefix: exec: day: parts: {
|
||||
name = "${prefix}-${day}";
|
||||
value = pkgs.testers.testEqualContents {
|
||||
assertion = day;
|
||||
expected = pkgs.writeText "expected" ''
|
||||
Part 1 Answer: ${parts.part1}
|
||||
Part 2 Answer: ${parts.part2}
|
||||
'';
|
||||
actual = pkgs.runCommand "actual" {} ''
|
||||
"${exec}" "${day}" < "${./input}/${day}" >$out
|
||||
'';
|
||||
};
|
||||
});
|
||||
|
||||
in pkgs.lib.attrsets.mapAttrs' (mkCheck "haskell" "${packages.aoc2023-haskell}/bin/aoc2023") answers
|
||||
// pkgs.lib.attrsets.mapAttrs' (mkCheck "bash" "${packages.aoc2023-bash}/bin/aoc2023") answers;
|
||||
defaultPackage = packages.dev-env;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue