tidy up flake.nix

This commit is contained in:
tristan 2024-12-11 23:08:31 +00:00
parent ad5b412c3a
commit 2db8edb087
5 changed files with 33 additions and 27 deletions

View file

@ -114,9 +114,6 @@ in {
inherit data disk defrag defragged checksum fullDisk;
part1result = defragged |> checksum;
# defraggedFullDisk = defragFullDisk fullDisk;
# part1result = (defragFullDisk fullDisk).acc |> checksumFullDisk;
part2result = "My solution is too slow for part 2";
}

13
2024/09/solution.nix Normal file
View file

@ -0,0 +1,13 @@
pkgs: input: let
inherit (pkgs) lib;
nix-solution = import ./bad.solution.nix pkgs input;
input-file = pkgs.writeText "input.txt" input;
bun-run = js-file: pkgs.runCommand "2024day9" {} ''
${lib.getExe pkgs.bun} ${js-file} ${input-file} > $out
'' |> builtins.readFile |> lib.trim;
in nix-solution // {
javascript = {
part1result = bun-run ./solution.js;
part2result = bun-run ./solution2.js;
};
}

18
2024/default.nix Normal file
View file

@ -0,0 +1,18 @@
{pkgs ? import <nixpkgs> {}, aoc-inputs ? "/tmp/aoc-inputs"}:
let
inherit (pkgs) lib;
in
(lib.range 1 11
|> map (i: let id = lib.fixedWidthNumber 2 i; in {
name = "day-${id}";
value = let
solution = import ./${id}/solution.nix pkgs;
example = (pkgs.lib.readFile ./${id}/example.txt);
input = (pkgs.lib.readFile "${aoc-inputs}/${id}");
in {
example = solution example;
real = solution input;
};
})
|> builtins.listToAttrs
)

View file

@ -41,27 +41,5 @@
};
})
|> builtins.listToAttrs
) // {
day-09 = let
solution = import ./09/bad.solution.nix pkgs;
example = (pkgs.lib.readFile ./09/example.txt);
input = "${aoc-inputs}/09";
in {
example = solution example;
real.part1result = "My solution doesn't work on the real input :(";
javascript = {
part1result = pkgs.runCommand "2024day9part1" {} ''
${lib.getExe pkgs.bun} ${./09/solution.js} ${input} > $out
'' |> builtins.readFile;
part2result = pkgs.runCommand "2024day9part1" {} ''
${lib.getExe pkgs.bun} ${./09/solution2.js} ${input} > $out
'' |> builtins.readFile;
};
test = tix.run [
./09/solution.test.nix
];
};
};
);
}