Skip to content

Commit 6b5b65e

Browse files
committed
Package up day 16 in a Nix flake/derivation
1 parent 3cb1823 commit 6b5b65e

File tree

6 files changed

+78
-3
lines changed

6 files changed

+78
-3
lines changed

.github/workflows/run.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
os: ['ubuntu-latest', 'macos-latest']
14-
day: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15']
14+
day: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16']
1515
exclude:
1616
# TODO: Investigate why building Zig on macOS fails
1717
# https://github.com/fwcd/advent-of-code-2024/actions/runs/12202208638/job/34042374507

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ My solutions to the [Advent of Code 2024](https://adventofcode.com/2024), writte
2121
- [x] [**Day 13**](day13): [Python](day13/src/day13.py)
2222
- [x] [**Day 14**](day14): [Haskell](day14/src/Day14.hs)
2323
- [x] [**Day 15**](day15): [C++](day15/src/day15.cpp)
24-
- [ ] [**Day 16**](day16): [Kotlin](day16/src/day16.kts)
24+
- [x] [**Day 16**](day16): [Kotlin](day16/src/day16.kts)
2525

2626
## Development
2727

day16/derivation.nix

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{ stdenv, kotlin }:
2+
stdenv.mkDerivation {
3+
name = "advent-of-code-2024-day16";
4+
src = ./src;
5+
6+
buildInputs = [
7+
kotlin
8+
];
9+
10+
installPhase = ''
11+
mkdir -p $out/{bin,share}
12+
cp day16.kts $out/share
13+
14+
cat <<EOF > $out/bin/day16
15+
exec "${kotlin.outPath}/bin/kotlin" "\$(dirname "\$0")/../share/day16.kts" "\$@"
16+
EOF
17+
chmod +x $out/bin/day16
18+
'';
19+
}

day16/flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

day16/flake.nix

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
description = "Advent of Code 2024 - Day 16 solution";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6+
};
7+
8+
outputs = { self, nixpkgs }:
9+
let
10+
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
11+
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
12+
in {
13+
packages = forAllSystems (system:
14+
let
15+
pkgs = import nixpkgs { inherit system; };
16+
in {
17+
default = pkgs.callPackage ./derivation.nix {};
18+
}
19+
);
20+
21+
apps = forAllSystems (system: {
22+
default = {
23+
type = "app";
24+
program = "${self.packages.${system}.default}/bin/day16";
25+
};
26+
});
27+
};
28+
}

paths.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
"codemirror": "kotlin",
125125
"name": "Kotlin"
126126
},
127-
"path": "day16/src/day16.kts"
127+
"path": "day16/src/day16.kts",
128+
"completed": true
128129
}
129130
]

0 commit comments

Comments
 (0)