templates/rust-flake/flake.nix

32 lines
914 B
Nix
Raw Normal View History

2022-09-06 00:01:28 +03:00
{
inputs = {
2022-09-06 00:04:31 +03:00
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
2022-09-06 00:01:28 +03:00
};
outputs = { self, nixpkgs, utils }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
2022-09-06 00:07:33 +03:00
cargoToml = with builtins; (fromTOML (readFile ./Cargo.toml));
2022-09-06 00:01:28 +03:00
in
2022-09-06 00:08:03 +03:00
rec {
2022-09-06 00:01:28 +03:00
packages.default = pkgs.rustPlatform.buildRustPackage {
inherit (cargoToml.package) name version;
src = nixpkgs.lib.cleanSource ./.;
doCheck = true;
cargoLock.lockFile = ./Cargo.lock;
};
apps.default = utils.lib.mkApp {
inherit (cargoToml.package) name;
drv = packages.default;
};
devShell = with pkgs; mkShell {
packages = [ cargo rustc rustfmt clippy rust-analyzer ];
RUST_SRC_PATH = rustPlatform.rustLibSrc;
};
});
}