Add Git pre-commit hooks via Nix
This commit is contained in:
parent
77386b0fce
commit
ce07e92a2e
|
|
@ -2,3 +2,4 @@
|
||||||
/radicle-cli/target
|
/radicle-cli/target
|
||||||
/build/artifacts
|
/build/artifacts
|
||||||
/build/*.tar.gz
|
/build/*.tar.gz
|
||||||
|
/.pre-commit-config.yaml
|
||||||
|
|
|
||||||
84
flake.lock
84
flake.lock
|
|
@ -31,6 +31,22 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flake-compat": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1696426674,
|
||||||
|
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
|
|
@ -49,7 +65,28 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"gitignore": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"pre-commit-hooks",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1709087332,
|
||||||
|
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-stable": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1740142985,
|
"lastModified": 1740142985,
|
||||||
"narHash": "sha256-fCPt2PVnQgiHXGlTRmU5/gFdG/+JT3ycpt+GxY1Vp+s=",
|
"narHash": "sha256-fCPt2PVnQgiHXGlTRmU5/gFdG/+JT3ycpt+GxY1Vp+s=",
|
||||||
|
|
@ -65,12 +102,55 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nixpkgs-unstable": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1740142985,
|
||||||
|
"narHash": "sha256-fCPt2PVnQgiHXGlTRmU5/gFdG/+JT3ycpt+GxY1Vp+s=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "1d1ce35bb6052a23f5692cd89b7cc49acdcb8d0e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "release-24.11",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pre-commit-hooks": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": "flake-compat",
|
||||||
|
"gitignore": "gitignore",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1742649964,
|
||||||
|
"narHash": "sha256-DwOTp7nvfi8mRfuL1escHDXabVXFGT1VlPD1JHrtrco=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "git-hooks.nix",
|
||||||
|
"rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "git-hooks.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"advisory-db": "advisory-db",
|
"advisory-db": "advisory-db",
|
||||||
"crane": "crane",
|
"crane": "crane",
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": [
|
||||||
|
"nixpkgs-stable"
|
||||||
|
],
|
||||||
|
"nixpkgs-stable": "nixpkgs-stable",
|
||||||
|
"nixpkgs-unstable": "nixpkgs-unstable",
|
||||||
|
"pre-commit-hooks": "pre-commit-hooks",
|
||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
43
flake.nix
43
flake.nix
|
|
@ -2,17 +2,20 @@
|
||||||
description = "Radicle";
|
description = "Radicle";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/release-24.11";
|
nixpkgs-unstable.url = "github:NixOS/nixpkgs/release-24.11";
|
||||||
|
nixpkgs-stable.url = "github:NixOS/nixpkgs/release-24.11";
|
||||||
|
nixpkgs.follows = "nixpkgs-stable";
|
||||||
|
|
||||||
crane = {
|
crane.url = "github:ipetkov/crane";
|
||||||
url = "github:ipetkov/crane";
|
|
||||||
|
pre-commit-hooks = {
|
||||||
|
url = "github:cachix/git-hooks.nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
rust-overlay = {
|
rust-overlay = {
|
||||||
url = "github:oxalica/rust-overlay";
|
url = "github:oxalica/rust-overlay";
|
||||||
inputs = {
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
|
@ -35,7 +38,7 @@
|
||||||
advisory-db,
|
advisory-db,
|
||||||
rust-overlay,
|
rust-overlay,
|
||||||
...
|
...
|
||||||
}:
|
} @ inputs:
|
||||||
flake-utils.lib.eachDefaultSystem (system: let
|
flake-utils.lib.eachDefaultSystem (system: let
|
||||||
lib = nixpkgs.lib;
|
lib = nixpkgs.lib;
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
|
|
@ -43,8 +46,8 @@
|
||||||
overlays = [(import rust-overlay)];
|
overlays = [(import rust-overlay)];
|
||||||
};
|
};
|
||||||
|
|
||||||
rustToolChain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||||
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolChain;
|
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
|
||||||
|
|
||||||
srcFilters = path: type:
|
srcFilters = path: type:
|
||||||
builtins.any (suffix: lib.hasSuffix suffix path) [
|
builtins.any (suffix: lib.hasSuffix suffix path) [
|
||||||
|
|
@ -105,6 +108,23 @@
|
||||||
|
|
||||||
# Set of checks that are run: `nix flake check`
|
# Set of checks that are run: `nix flake check`
|
||||||
checks = {
|
checks = {
|
||||||
|
pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
|
||||||
|
src = ./.;
|
||||||
|
settings.rust.check.cargoDeps = pkgs.rustPlatform.importCargoLock {lockFile = ./Cargo.lock;};
|
||||||
|
hooks = {
|
||||||
|
alejandra.enable = true;
|
||||||
|
rustfmt.enable = true;
|
||||||
|
cargo-check.enable = true;
|
||||||
|
clippy = {
|
||||||
|
enable = true;
|
||||||
|
settings.denyWarnings = true;
|
||||||
|
packageOverrides.cargo = rustToolchain;
|
||||||
|
packageOverrides.clippy = rustToolchain;
|
||||||
|
};
|
||||||
|
shellcheck.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
# Build the crate as part of `nix flake check` for convenience
|
# Build the crate as part of `nix flake check` for convenience
|
||||||
inherit (self.packages.${system}) radicle;
|
inherit (self.packages.${system}) radicle;
|
||||||
|
|
||||||
|
|
@ -230,6 +250,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.default = craneLib.devShell {
|
devShells.default = craneLib.devShell {
|
||||||
|
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
||||||
|
buildInputs = self.checks.${system}.pre-commit-check.enabledPackages;
|
||||||
|
|
||||||
# Extra inputs can be added here; cargo and rustc are provided by default.
|
# Extra inputs can be added here; cargo and rustc are provided by default.
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
cargo-audit
|
cargo-audit
|
||||||
|
|
@ -241,7 +264,7 @@
|
||||||
sqlite
|
sqlite
|
||||||
];
|
];
|
||||||
|
|
||||||
env.RUST_SRC_PATH = "${rustToolChain}/lib/rustlib/src/rust/library";
|
env.RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue