This commit is contained in:
Spectre 2024-12-02 23:24:40 +01:00
parent e1ca0d5f61
commit 73e90776ed
9 changed files with 455 additions and 241 deletions

View file

@ -1,7 +1,9 @@
{
description = "A Nix-flake-based Rust development environment";
description = "Dev Shell for AdventOfCode by lilith";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
@ -9,42 +11,35 @@
};
outputs = {
self,
nixpkgs,
rust-overlay,
}: let
overlays = [
rust-overlay.overlays.default
(final: prev: {
rustToolchain = let
rust = prev.rust-bin;
in
if builtins.pathExists ./rust-toolchain.toml
then rust.fromRustupToolchainFile ./rust-toolchain.toml
else if builtins.pathExists ./rust-toolchain
then rust.fromRustupToolchainFile ./rust-toolchain
else rust.stable.latest.default;
})
];
supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
forEachSupportedSystem = f:
nixpkgs.lib.genAttrs supportedSystems (system:
f {
pkgs = import nixpkgs {inherit overlays system;};
});
in {
devShells = forEachSupportedSystem ({pkgs}: {
default = pkgs.mkShell {
packages = with pkgs; [
rustToolchain
openssl
pkg-config
cargo-deny
cargo-edit
cargo-watch
rust-analyzer
];
};
});
};
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {
inherit system overlays;
};
in {
devShells.default = with pkgs;
mkShell {
buildInputs = [
openssl
pkg-config
cargo-deny
cargo-edit
cargo-watch
rust-analyzer
(
rust-bin.selectLatestNightlyWith (toolchain:
toolchain.default.override {
extensions = ["rust-src"];
})
)
];
};
}
);
}