flake: add pre-commit-hooks

Instead of havin the tool manage versions, use a pinned version.
This commit is contained in:
Bruno BELANYI 2021-05-31 23:04:08 +02:00
parent 15db81eb3b
commit 59cb038045
3 changed files with 52 additions and 22 deletions

View file

@ -1,21 +0,0 @@
repos:
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: 'v2.3.0'
hooks:
- id: 'trailing-whitespace'
- id: 'end-of-file-fixer'
- id: 'check-yaml'
- id: 'check-added-large-files'
- repo: 'https://github.com/jumanjihouse/pre-commit-hooks'
rev: '2.1.4'
hooks:
- id: 'forbid-binary'
- repo: 'local'
hooks:
- id: 'nixpkgs-fmt'
name: 'nixpkgs-fmt'
description: 'Format nix code with nixpkgs-fmt'
entry: 'nixpkgs-fmt'
language: 'system'
files: '\.nix$'
always_run: true

View file

@ -69,12 +69,37 @@
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-utils": [
"futils"
],
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1621411868,
"narHash": "sha256-R+7OQ2JYFCb3E7Jl7LhRifzMVCR6Gl8R98zYsNhZtJ8=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "2e7fac06108b4fc81f5ff9ed9a02bc4f6ede7001",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "master",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"futils": "futils",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs",
"nur": "nur"
"nur": "nur",
"pre-commit-hooks": "pre-commit-hooks"
}
}
},

View file

@ -31,6 +31,17 @@
repo = "NUR";
ref = "master";
};
pre-commit-hooks = {
type = "github";
owner = "cachix";
repo = "pre-commit-hooks.nix";
ref = "master";
inputs = {
flake-utils.follows = "futils";
nixpkgs.follows = "nixpkgs";
};
};
};
outputs =
@ -40,6 +51,7 @@
, home-manager
, nixpkgs
, nur
, pre-commit-hooks
}:
let
inherit (futils.lib) eachDefaultSystem;
@ -96,6 +108,18 @@
diff-flake = futils.lib.mkApp { drv = packages.diff-flake; };
};
checks = {
pre-commit = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt = {
enable = true;
};
};
};
};
defaultApp = apps.diff-flake;
devShell = pkgs.mkShell {
@ -107,6 +131,8 @@
gnupg
nixpkgs-fmt
];
inherit (self.checks.${system}.pre-commit) shellHook;
};
packages = import ./pkgs { inherit pkgs; };