add rust-flake template

This commit is contained in:
Dmitriy Pleshevskiy 2022-09-06 00:01:28 +03:00
parent 03ede4536c
commit 2db5ad16cd
Signed by: pleshevskiy
GPG Key ID: 1B59187B161C0215
3 changed files with 36 additions and 0 deletions

View File

@ -7,6 +7,10 @@
path = ./base-flake;
description = "An empty flake for each default system";
};
rust-flake = {
path = ./rust-flake;
description = "Flake to develop, build and run a rust application";
};
};
defaultTemplate = self.templates.base-flake;
};

1
rust-flake/.envrc Normal file
View File

@ -0,0 +1 @@
use flake

31
rust-flake/flake.nix Normal file
View File

@ -0,0 +1,31 @@
{
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixpkgs-unstable;
utils.url = github:numtide/flake-utils;
};
outputs = { self, nixpkgs, utils }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
cargoToml = with builtins; (fromTOML (readFile ./dexios/Cargo.toml));
in
{
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;
};
});
}