diff options
author | Federico Igne <undyamon@disroot.org> | 2023-12-09 12:28:31 +0100 |
---|---|---|
committer | Federico Igne <undyamon@disroot.org> | 2023-12-09 12:28:31 +0100 |
commit | 537d4dd6f26757ff0bfa8627dc5ecb1ecb43705f (patch) | |
tree | 2a1b60f304e751e0cdae6b836e4d7d8b5c4dd739 | |
parent | ed12a710910aef9fff41bcd0e6cab033f49c9fc8 (diff) | |
download | aoc-537d4dd6f26757ff0bfa8627dc5ecb1ecb43705f.tar.gz aoc-537d4dd6f26757ff0bfa8627dc5ecb1ecb43705f.zip |
feat(flake): automatically download input for the day
-rw-r--r-- | .secret/session.txt | bin | 0 -> 151 bytes | |||
-rw-r--r-- | 2023/flake.nix | 9 |
2 files changed, 7 insertions, 2 deletions
diff --git a/.secret/session.txt b/.secret/session.txt new file mode 100644 index 0000000..60c106e --- /dev/null +++ b/.secret/session.txt | |||
Binary files differ | |||
diff --git a/2023/flake.nix b/2023/flake.nix index 1586422..654f196 100644 --- a/2023/flake.nix +++ b/2023/flake.nix | |||
@@ -16,11 +16,12 @@ | |||
16 | inherit system; | 16 | inherit system; |
17 | overlays = [ devshell.overlays.default ]; | 17 | overlays = [ devshell.overlays.default ]; |
18 | }; | 18 | }; |
19 | year = 2023; | ||
19 | in pkgs.devshell.mkShell { | 20 | in pkgs.devshell.mkShell { |
20 | 21 | ||
21 | devshell = { | 22 | devshell = { |
22 | motd = '' | 23 | motd = '' |
23 | {bold}{3}🎄 Advent of Code 2023 🎄{reset} | 24 | {bold}{3}🎄 Advent of Code ${year} 🎄{reset} |
24 | $(for CMD in g++ make gdb clangd ; do | 25 | $(for CMD in g++ make gdb clangd ; do |
25 | "$CMD" --version | head -n1 | 26 | "$CMD" --version | head -n1 |
26 | done) | 27 | done) |
@@ -34,7 +35,7 @@ | |||
34 | }; | 35 | }; |
35 | 36 | ||
36 | packages = with pkgs; [ | 37 | packages = with pkgs; [ |
37 | gcc gnumake gdb clang-tools bear | 38 | gcc gnumake gdb clang-tools bear curl |
38 | ]; | 39 | ]; |
39 | 40 | ||
40 | #env = [ | 41 | #env = [ |
@@ -52,6 +53,10 @@ | |||
52 | mkdir -p "$BASE" && cd $_ | 53 | mkdir -p "$BASE" && cd $_ |
53 | mkdir -p src resources | 54 | mkdir -p src resources |
54 | 55 | ||
56 | ${pkgs.curl}/bin/curl "https://adventofcode.com/${year}/day/$1/input" \ | ||
57 | --cookie "session=$(cat ../../.secret/session.txt)" --silent | ||
58 | --output-dir resources --output input.txt | ||
59 | |||
55 | cat << EOF >> src/part1.cpp | 60 | cat << EOF >> src/part1.cpp |
56 | #include <iostream> | 61 | #include <iostream> |
57 | #include <fstream> | 62 | #include <fstream> |