aoc/2022/d9/flake.nix

74 lines
2.3 KiB
Nix
Raw Normal View History

2022-12-09 06:02:30 +00:00
{
description = "D4 AOC with Lua!";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
2022-12-14 06:03:15 +00:00
rust-overlay.url = "github:oxalica/rust-overlay";
2022-12-09 06:02:30 +00:00
};
2022-12-14 06:03:15 +00:00
outputs = { nixpkgs, flake-utils, rust-overlay, ... } @ inputs:
2022-12-09 06:02:30 +00:00
flake-utils.lib.eachSystem flake-utils.lib.defaultSystems (sys:
let
2022-12-14 06:03:15 +00:00
overlays = [ rust-overlay.overlays.default ];
2022-12-09 06:02:30 +00:00
pkgs = import nixpkgs { system = sys; overlays = overlays; };
shellHookAfter = ''
echo "The input files should be placed under ./data/{submission,example}.txt"
echo "This problem shares one input between two parts"
'';
py_pkgs = [ pkgs.python310 ];
2022-12-14 06:03:15 +00:00
rs_pkgs = [
pkgs.openssl
pkgs.pkg-config
# Add rust-src, which rust-analyzer seems to rely upon
(pkgs.rust-bin.selectLatestNightlyWith
(
toolchain:
toolchain.default.override {
extensions = [ "rust-src" ];
}
))
];
2022-12-09 06:02:30 +00:00
in
{
# Jack of all trades
devShell = pkgs.mkShell
{
2022-12-14 06:03:15 +00:00
buildInputs = py_pkgs ++ rs_pkgs;
2022-12-09 06:02:30 +00:00
shellHook = ''
2022-12-14 06:03:15 +00:00
echo "> Default runtime. This contains both rust and python3 env"
echo "Run ./run-py.sh for Python's output and ./run-rs.sh for Rust's output"
2022-12-09 06:02:30 +00:00
'' + shellHookAfter;
};
devShells = {
# nix develop ./#lua
# lua = pkgs.mkShell {
# nativeBuildInputs = lua_pkgs;
# shellHook = ''
# echo "> Lua runtime"
# echo "Run ./run-lua.sh to see the output of the solution"
# '' + shellHookAfter;
# };
# nix develop ./#fennel
# nix develop ./#python
2022-12-14 06:03:15 +00:00
rust = pkgs.mkShell {
nativeBuildInputs = rs_pkgs;
shellHook = ''
echo "> Rust runtime"
echo "Run ./run-rs.sh to see output of the solution"
'' + shellHookAfter;
};
2022-12-09 06:02:30 +00:00
python = pkgs.mkShell {
nativeBuildInputs = py_pkgs;
shellHook = ''
echo "> Python3 runtime"
echo "Run ./run-py.sh to see the output of the solution"
'' + shellHookAfter;
};
};
}
);
}