diff options
| author | Franck Cuny <franck@fcuny.net> | 2022-11-01 17:31:41 -0700 |
|---|---|---|
| committer | Franck Cuny <franck@fcuny.net> | 2022-11-01 18:48:56 -0700 |
| commit | 03a62e4114ab546c3b3eec8f83403e06341aed85 (patch) | |
| tree | dcccc87763db6506e75a9bd607ca00cc1f5e9eef /src/x509-info/flake.nix | |
| parent | ci: rewrite GitHub actions to use `nix develop|build` (diff) | |
| download | x-03a62e4114ab546c3b3eec8f83403e06341aed85.tar.gz | |
build: add pre-commit checks
Diffstat (limited to 'src/x509-info/flake.nix')
| -rw-r--r-- | src/x509-info/flake.nix | 35 |
1 files changed, 31 insertions, 4 deletions
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; }; }) // { |
