···
echo "''${days[@]}" | tr ' ' '\n' | sort
29
-
# Run a specific day's solution
30
-
runDay = day: lang: ''
31
-
if [ "$lang" = "ts" ] && [ -f "ts/${day}/index.ts" ]; then
32
-
${gum}/bin/gum style --border rounded --border-foreground 212 --padding "0 1" --margin "1 0" "Day ${day} (TypeScript)"
33
-
(cd ts/${day} && ${pkgs.bun}/bin/bun run index.ts)
34
-
elif [ "$lang" = "nix" ] && [ -f "nix/${day}/solution.nix" ]; then
35
-
${gum}/bin/gum style --border rounded --border-foreground 212 --padding "0 1" --margin "1 0" "Day ${day} (Nix)"
36
-
result=$(${pkgs.nix}/bin/nix-instantiate --eval --strict --json nix/${day}/solution.nix)
37
-
part1=$(echo "$result" | ${pkgs.jq}/bin/jq -r '.part1')
38
-
part2=$(echo "$result" | ${pkgs.jq}/bin/jq -r '.part2')
39
-
echo "part 1: $part1"
40
-
echo "part 2: $part2"
# Interactive runner with gum
runner = pkgs.writeShellScriptBin "aoc" ''
···
"$(${gum}/bin/gum style --foreground 212 '🎄 Advent of Code 2025 🎄')"
56
-
action=$(${gum}/bin/gum choose "Run specific day" "Run all solutions" "Exit")
41
+
action=$(${gum}/bin/gum choose "Run specific day" "Run all solutions" "Init new day" "Exit")
···
132
+
# Get all existing days
134
+
for dir in ts/* nix/* shared/*; do
135
+
if [ -d "$dir" ]; then
136
+
day=$(basename "$dir")
137
+
if [[ "$day" =~ ^[0-9]+$ ]]; then
143
+
# Find next day number
145
+
if [ ''${#all_days[@]} -gt 0 ]; then
146
+
max_day=$(printf '%s\n' "''${all_days[@]}" | sort -n | tail -1)
147
+
next_day=$(printf "%02d" $((10#$max_day + 1)))
150
+
# Show form with prefilled day
151
+
${gum}/bin/gum style --foreground 212 "Initializing new day"
154
+
day=$(${gum}/bin/gum input --placeholder "Day number" --value "$next_day" --prompt "Day: ")
156
+
# Validate day is a number
157
+
if ! [[ "$day" =~ ^[0-9]+$ ]]; then
158
+
${gum}/bin/gum style --foreground 196 "Invalid day number!"
162
+
# Format with leading zero
163
+
day=$(printf "%02d" $((10#$day)))
165
+
# Check if day already exists
166
+
if [ -d "ts/$day" ] || [ -d "nix/$day" ] || [ -d "shared/$day" ]; then
167
+
${gum}/bin/gum style --foreground 196 "Day $day already exists!"
171
+
# Create directories
173
+
mkdir -p "nix/$day"
174
+
mkdir -p "shared/$day"
176
+
# Fetch input from adventofcode.com
177
+
${gum}/bin/gum style --foreground 212 "Fetching input from adventofcode.com..."
179
+
# Check for session cookie
181
+
if [ -f ".aoc-session" ]; then
182
+
session_cookie=$(cat .aoc-session)
184
+
${gum}/bin/gum style --foreground 196 "No .aoc-session file found!"
185
+
${gum}/bin/gum style "Create .aoc-session with your session cookie from adventofcode.com"
190
+
day_num=$((10#$day))
191
+
${pkgs.curl}/bin/curl -s -b "session=$session_cookie" \
192
+
"https://adventofcode.com/2025/day/$day_num/input" \
193
+
-o "shared/$day/input.txt"
195
+
if [ $? -ne 0 ] || [ ! -s "shared/$day/input.txt" ]; then
196
+
${gum}/bin/gum style --foreground 196 "Failed to fetch input!"
197
+
rm -rf "ts/$day" "nix/$day" "shared/$day"
201
+
# Create TypeScript template
202
+
cat > "ts/$day/index.ts" << EOF
203
+
const file = await Bun.file("../../shared/$day/input.txt").text();
207
+
console.log("part 1:", 0);
212
+
console.log("part 2:", 0);
216
+
# Create Nix template
217
+
cat > "nix/$day/solution.nix" << EOF
219
+
input = builtins.readFile ../../shared/$day/input.txt;
220
+
lines = builtins.filter (s: builtins.isString s && s != "") (builtins.split "\n" input);
226
+
inherit part1 part2;
230
+
${gum}/bin/gum style --foreground 212 "✓ Day $day initialized!"
231
+
${gum}/bin/gum style " • ts/$day/index.ts"
232
+
${gum}/bin/gum style " • nix/$day/solution.nix"
233
+
${gum}/bin/gum style " • shared/$day/input.txt"