Create rust template

This commit is contained in:
Alexander
2026-05-13 23:42:35 +02:00
commit 0d0aea2a97
3 changed files with 72 additions and 0 deletions
+61
View File
@@ -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
];
};
});
}