Create rust template
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
description = "A collection of flake templates";
|
||||||
|
|
||||||
|
outputs = { self }: {
|
||||||
|
rust = {
|
||||||
|
path = ./rust;
|
||||||
|
description = "Rust template";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
use flake
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
utils.url = "github:numtide/flake-utils";
|
||||||
|
git-hooks.url = "github:cachix/git-hooks.nix";
|
||||||
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, utils, git-hooks, rust-overlay }:
|
||||||
|
utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
overlays = [ (import rust-overlay) ];
|
||||||
|
pkgs = import nixpkgs { inherit system overlays; };
|
||||||
|
|
||||||
|
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
|
||||||
|
extensions = [ "rust-src" "rust-analyzer" "clippy" "rustfmt" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
pre-commit-check = git-hooks.lib.${system}.run {
|
||||||
|
src = ./.;
|
||||||
|
hooks = {
|
||||||
|
rustfmt = {
|
||||||
|
enable = true;
|
||||||
|
packageOverrides = {
|
||||||
|
cargo = rustToolchain;
|
||||||
|
rustfmt = rustToolchain;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
clippy = {
|
||||||
|
enable = true;
|
||||||
|
packageOverrides = {
|
||||||
|
cargo = rustToolchain;
|
||||||
|
clippy = rustToolchain;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
checks = {
|
||||||
|
inherit pre-commit-check;
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
inherit (pre-commit-check) shellHook;
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
pre-commit
|
||||||
|
gitleaks
|
||||||
|
|
||||||
|
rustToolchain
|
||||||
|
cargo-watch
|
||||||
|
crates-lsp
|
||||||
|
pkg-config
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
openssl
|
||||||
|
];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user