Files
aoc-2023/flake.nix
2023-12-28 13:47:30 +01:00

37 lines
1012 B
Nix

{
description = "Advent Of Code 2023";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
forAllSystems = function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-darwin"
] (system: function nixpkgs.legacyPackages.${system});
in
{
devShells = forAllSystems (pkgs: with pkgs; {
default = mkShell {
nativeBuildInputs = [ rustc cargo clippy ];
buildInputs = [ hyperfine glow libiconv ];
RUST_SRC_PATH = "${rustPlatform.rustLibSrc}";
shellHook = ''
bench() {
cargo build --release
DAY=$((($(date +%s)-$(date +%s --date "2023-11-30"))/(3600*24)))
hyperfine --parameter-list day $(seq --format "%02.f" 1 $DAY | paste -sd ',' -) "./target/release/day{day} ./data/{day}.in" --runs 20 --warmup 10 --shell=none --export-markdown ./target/bench-output.md 2> /dev/null
glow ./target/bench-output.md
}
'';
};
});
};
}