templates/rust/flake.nix

34 lines
934 B
Nix
Raw Normal View History

2023-10-12 16:03:51 +02:00
{
description = "A bare minimum Rust flake";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem (sys:
let pkgs = import nixpkgs {
system = sys;
overlays = [ (import rust-overlay) ];
};
rust = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" "rust-analyzer" ];
};
platform = pkgs.makeRustPlatform {
rustc = rust;
cargo = rust;
};
in rec {
packages.default = platform.buildRustPackage {
name = "my-cool-project";
src = ./.;
cargoLock = { lockFile = ./Cargo.lock; };
};
devShells.default = pkgs.mkShell {
packages = [ rust ];
};
}
);
}