diff --git a/answers.nix b/answers.nix index 10c4370..f309255 100644 --- a/answers.nix +++ b/answers.nix @@ -2,13 +2,22 @@ day1 = { part1 = "53194"; part2 = "54249"; + checkHaskell = true; + checkBash = true; + checkRust = true; }; day2 = { part1 = "2406"; part2 = "78375"; + checkHaskell = true; + checkBash = true; + checkRust = true; }; day3 = { part1 = "531932"; part2 = "73646890"; + checkHaskell = true; + checkBash = false; + checkRust = false; }; } diff --git a/flake.nix b/flake.nix index 9b031ef..5efa668 100644 --- a/flake.nix +++ b/flake.nix @@ -56,31 +56,38 @@ filter = path: type: let baseName = baseNameOf (toString path); in pkgs.lib.cleanSourceFilter path type && - (pkgs.lib.strings.hasInfix "rust" path || - baseName == "Cargo.toml" || - baseName == "Cargo.lock"); + (pkgs.lib.strings.hasInfix "rust" path || + baseName == "Cargo.toml" || + baseName == "Cargo.lock"); }; cargoSha256 = "sha256-e27WE9K2yby+6vzu0cDojtG0+aTdED7vt7wFgEd2dAw="; }; }; checks = - let mkCheck = (lang: exec: day: parts: { - name = "${lang}-${day}"; - value = pkgs.testers.testEqualContents { - assertion = "${lang}: ${day}"; - expected = pkgs.writeText "expected" '' - Part 1 Answer: ${parts.part1} - Part 2 Answer: ${parts.part2} - ''; - actual = pkgs.runCommandLocal "actual" {} '' - "${exec}" "${day}" < "${./input}/${day}" >$out - ''; - }; - }); + let mkCheck = (lang: exec: day: assertions: + if assertions."check${lang}" then { + name = "${lang}-${day}"; + value = pkgs.testers.testEqualContents { + assertion = "${lang}: ${day}"; + expected = pkgs.writeText "expected" '' + Part 1 Answer: ${assertions.part1} + Part 2 Answer: ${assertions.part2} + ''; + actual = pkgs.runCommandLocal "actual" {} '' + "${exec}" "${day}" < "${./input}/${day}" >$out + ''; + }; + } + else { + name = "${lang}-${day}-skipped"; + value = pkgs.hello; + } + ); - 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 - // pkgs.lib.attrsets.mapAttrs' (mkCheck "rust" "${packages.aoc2023-rust}/bin/aoc2023") answers; + 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 + // pkgs.lib.attrsets.mapAttrs' (mkCheck "Rust" "${packages.aoc2023-rust}/bin/aoc2023") answers; defaultPackage = packages.dev-env; }); }