2024-12-06 07:13:59 +00:00
|
|
|
{
|
|
|
|
description = "A very basic flake";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
|
|
|
tix.url = "git+https://git.tristans.cloud/tristan/tix";
|
2024-12-10 09:04:17 +00:00
|
|
|
/*
|
|
|
|
* sharing your puzzle inputs is discouraged:
|
|
|
|
* https://adventofcode.com/about#faq_copying
|
|
|
|
*
|
|
|
|
* so on a new day, paste the input into
|
|
|
|
* /tmp/aoc-inputs/${day number}
|
|
|
|
*
|
|
|
|
* and run
|
|
|
|
* nix flake update aoc-inputs
|
|
|
|
*/
|
|
|
|
aoc-inputs = {
|
|
|
|
url = "path:/tmp/aoc-inputs";
|
|
|
|
flake = false;
|
|
|
|
};
|
2024-12-06 07:13:59 +00:00
|
|
|
};
|
|
|
|
|
2024-12-10 09:04:17 +00:00
|
|
|
outputs = { aoc-inputs, nixpkgs, tix, ... }: let
|
2024-12-06 07:13:59 +00:00
|
|
|
pkgs = import nixpkgs {system = "x86_64-linux";};
|
2024-12-10 09:04:17 +00:00
|
|
|
inherit (pkgs) lib;
|
2024-12-06 07:13:59 +00:00
|
|
|
|
|
|
|
|
2024-12-10 09:04:17 +00:00
|
|
|
in (lib.range 1 8
|
|
|
|
|> 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}");
|
2024-12-08 13:08:57 +00:00
|
|
|
in {
|
2024-12-08 15:01:56 +00:00
|
|
|
example = solution example;
|
|
|
|
real = solution input;
|
2024-12-08 13:08:57 +00:00
|
|
|
test = tix.run [
|
2024-12-10 09:04:17 +00:00
|
|
|
"./${id}/solution.test.nix"
|
2024-12-08 13:08:57 +00:00
|
|
|
];
|
|
|
|
};
|
2024-12-10 09:04:17 +00:00
|
|
|
})
|
|
|
|
|> builtins.listToAttrs
|
|
|
|
) // {
|
2024-12-08 13:08:57 +00:00
|
|
|
|
2024-12-10 09:04:17 +00:00
|
|
|
day-09 = let
|
2024-12-09 14:32:12 +00:00
|
|
|
solution = import ./09/bad.solution.nix pkgs;
|
|
|
|
example = (pkgs.lib.readFile ./09/example.txt);
|
2024-12-10 09:04:17 +00:00
|
|
|
input = "${aoc-inputs}/09";
|
2024-12-09 14:32:12 +00:00
|
|
|
in {
|
|
|
|
example = solution example;
|
|
|
|
real.part1result = "My solution doesn't work on the real input :(";
|
2024-12-10 09:04:17 +00:00
|
|
|
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;
|
|
|
|
};
|
2024-12-09 14:32:12 +00:00
|
|
|
test = tix.run [
|
|
|
|
./09/solution.test.nix
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-12-06 07:13:59 +00:00
|
|
|
};
|
|
|
|
}
|