aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/x509-info/.gitignore1
-rw-r--r--src/x509-info/flake.lock24
-rw-r--r--src/x509-info/flake.nix35
3 files changed, 56 insertions, 4 deletions
diff --git a/src/x509-info/.gitignore b/src/x509-info/.gitignore
index d787b70..53e2c1a 100644
--- a/src/x509-info/.gitignore
+++ b/src/x509-info/.gitignore
@@ -1,2 +1,3 @@
/target
/result
+/.pre-commit-config.yaml
diff --git a/src/x509-info/flake.lock b/src/x509-info/flake.lock
index 9080ba8..af07128 100644
--- a/src/x509-info/flake.lock
+++ b/src/x509-info/flake.lock
@@ -45,10 +45,34 @@
"type": "github"
}
},
+ "pre-commit-hooks": {
+ "inputs": {
+ "flake-utils": [
+ "flake-utils"
+ ],
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1666604592,
+ "narHash": "sha256-Bxy7xeVAwC0yxFaeYZM7N9Us/ebxpMC9TCceKEFeay4=",
+ "owner": "cachix",
+ "repo": "pre-commit-hooks.nix",
+ "rev": "1b436f36e2812c589e6d830e3223059ea9661100",
+ "type": "github"
+ },
+ "original": {
+ "owner": "cachix",
+ "repo": "pre-commit-hooks.nix",
+ "type": "github"
+ }
+ },
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
+ "pre-commit-hooks": "pre-commit-hooks",
"rust-overlay": "rust-overlay"
}
},
diff --git a/src/x509-info/flake.nix b/src/x509-info/flake.nix
index ca1762f..5948fa8 100644
--- a/src/x509-info/flake.nix
+++ b/src/x509-info/flake.nix
@@ -6,7 +6,16 @@
nixpkgs.url = "github:NixOS/nixpkgs";
rust-overlay = {
url = "github:oxalica/rust-overlay";
- inputs.nixpkgs.follows = "nixpkgs";
+ inputs = {
+ nixpkgs.follows = "nixpkgs";
+ };
+ };
+ pre-commit-hooks = {
+ url = "github:cachix/pre-commit-hooks.nix";
+ inputs = {
+ flake-utils.follows = "flake-utils";
+ nixpkgs.follows = "nixpkgs";
+ };
};
};
@@ -15,6 +24,7 @@
, flake-utils
, nixpkgs
, rust-overlay
+ , pre-commit-hooks
}:
let
# Borrow project metadata from the Rust config
@@ -48,6 +58,25 @@
};
};
+ checks = {
+ pre-commit = pre-commit-hooks.lib.${system}.run {
+ src = ./.;
+ hooks = {
+ clippy = {
+ enable = true;
+ entry = pkgs.lib.mkForce "cargo clippy -- -D warnings";
+ };
+ nixpkgs-fmt = {
+ enable = true;
+ };
+ rustfmt = {
+ enable = true;
+ entry = pkgs.lib.mkForce "cargo fmt -- --check --color always";
+ };
+ };
+ };
+ };
+
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
rustToolchain
@@ -56,9 +85,7 @@
rust-analyzer
];
- shellHook = ''
- cargo --version
- '';
+ inherit (self.checks.${system}.pre-commit) shellHook;
};
})
// {