flake: add pre-commit-hooks

This commit is contained in:
Bruno BELANYI 2021-07-20 20:25:51 +02:00
parent f56712227e
commit c740207824
2 changed files with 66 additions and 3 deletions

View file

@ -32,10 +32,35 @@
"type": "github" "type": "github"
} }
}, },
"pre-commit-hooks": {
"inputs": {
"flake-utils": [
"futils"
],
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1624971177,
"narHash": "sha256-Amf/nBj1E77RmbSSmV+hg6YOpR+rddCbbVgo5C7BS0I=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "397f0713d007250a2c7a745e555fa16c5dc8cadb",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "master",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"futils": "futils", "futils": "futils",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
} }
} }
}, },

View file

@ -15,10 +15,21 @@
repo = "nixpkgs"; repo = "nixpkgs";
ref = "nixpkgs-unstable"; ref = "nixpkgs-unstable";
}; };
pre-commit-hooks = {
type = "github";
owner = "cachix";
repo = "pre-commit-hooks.nix";
ref = "master";
inputs = {
flake-utils.follows = "futils";
nixpkgs.follows = "nixpkgs";
};
};
}; };
outputs = { self, nixpkgs, futils } @ inputs: outputs = { self, futils, nixpkgs, pre-commit-hooks } @ inputs:
futils.lib.eachSystem futils.lib.allSystems (system: futils.lib.eachDefaultSystem (system:
let let
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
@ -37,9 +48,36 @@
]; ];
in in
{ {
checks = {
pre-commit = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt = {
enable = true;
};
markdown-lint = {
enable = true;
name = "Lint each post's markdown";
entry =
let
pkg = pkgs.nodePackages.markdownlint-cli;
in
"${pkg}/bin/markdownlint";
types = [ "markdown" ];
};
};
};
};
devShell = pkgs.mkShell { devShell = pkgs.mkShell {
name = "report"; name = "report";
inherit buildInputs; inherit buildInputs;
inherit (self.checks.${system}.pre-commit) shellHook;
}; };
defaultPackage = pkgs.stdenvNoCC.mkDerivation { defaultPackage = pkgs.stdenvNoCC.mkDerivation {