Skip to content

Commit 7606ac0

Browse files
committed
scaffold 2024
1 parent 08e3157 commit 7606ac0

File tree

10 files changed

+80
-5
lines changed

10 files changed

+80
-5
lines changed

2023/common/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
2-
name = "aoc-2023-common"
2+
name = "aoc-2024-common"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

2024/01/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "aoc-2024-01"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
aoc-2024-common = { path = "../common/" }

2024/01/input/1.txt

Whitespace-only changes.

2024/01/input/example.txt

Whitespace-only changes.

2024/01/src/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use aoc_2024_common::challenge_input;
2+
3+
fn main() {
4+
let input = challenge_input();
5+
// println!("hi");
6+
}

2024/Cargo.lock

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

2024/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[workspace]
2+
3+
resolver = "2"
4+
5+
members = [
6+
"common",
7+
"01",
8+
]

2024/common/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "aoc-2024-common"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]

2024/common/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use std::env;
2+
use std::fs;
3+
4+
#[must_use]
5+
pub fn challenge_input() -> String {
6+
let args: Vec<String> = env::args().collect();
7+
let file_path = &args
8+
.get(1)
9+
.expect("⚠️Please pass a path to an input file! ⚠️");
10+
11+
fs::read_to_string(file_path).expect("⚠️Unable to read input file! ⚠️")
12+
}

flake.nix

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
perSystem = { config, self', inputs', pkgs, system, ... }:
2121
let
2222
crane = rec {
23-
lib = self.inputs.crane.lib.${system};
23+
lib = self.inputs.crane.mkLib pkgs;
2424
stable = lib.overrideToolchain self'.packages.rust-stable;
2525
};
2626
days = map (pkgs.lib.fixedWidthNumber 2) (pkgs.lib.range 1 15);
27-
days2023 = map (pkgs.lib.fixedWidthNumber 2) (pkgs.lib.range 1 1);
27+
days2023 = map (pkgs.lib.fixedWidthNumber 2) (pkgs.lib.range 1 11);
28+
days2024 = map (pkgs.lib.fixedWidthNumber 2) (pkgs.lib.range 1 1);
2829
in {
2930
packages = {
3031
new-day = pkgs.writeShellApplication {
@@ -89,7 +90,26 @@
8990
'';
9091
};
9192

92-
}) days2023));
93+
}) days2023))
94+
// (builtins.listToAttrs (map (day: {
95+
name = "2024-${day}";
96+
value = let
97+
build = let pname = "aoc-2024-${day}"; in crane.stable.buildPackage {
98+
src = ./2024;
99+
cargoBuildCommand = "cargo build --release -p ${pname}";
100+
version = "0.1.0";
101+
inherit pname;
102+
};
103+
in pkgs.writeShellApplication {
104+
name = "aoc-2024-${day}";
105+
text = ''
106+
${build}/bin/aoc-2024-${day} "$@"
107+
'';
108+
};
109+
110+
}) days2024));
111+
112+
93113
devShells = {
94114
default = pkgs.mkShell {
95115
buildInputs = [ self'.packages.rust-stable self'.packages.new-day ]

0 commit comments

Comments
 (0)