-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
33 lines (33 loc) · 1.15 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
let
pkgs = import <nixpkgs> {};
lib = pkgs.lib;
utils = import ./utils.nix { lib = lib; };
in
lib.pipe (builtins.readDir ./.) [
(lib.filterAttrs (name: type: lib.hasPrefix "day" name && type == "directory"))
(lib.mapAttrs (name: _: let
day = (import ./${name});
invoke = input: day.solution {
input = input;
lib = pkgs.lib;
utils = utils;
};
part = num': let num = toString num'; in {
tests = map (test:
if # Skip tests that are actively disabled for this part.
test."part${num}" == null
then true
else let
result = (invoke test.input)."part${num}";
in
if result == test."part${num}" then true else result
) day.tests;
result = (invoke (lib.readFile ./${name}/input.txt))."part${num}";
};
in { part1 = part 1; part2 = part 2; }))
] // {
repl = {
lib = lib;
utils = utils;
};
}