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; path = ./base-flake;
description = "An empty flake for each default system"; 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; 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;
};
});
}