nix: add pre-commit-hooks

This commit is contained in:
Bruno BELANYI 2021-05-31 22:01:28 +02:00
parent 140726a6ff
commit a57a6d38bd
2 changed files with 53 additions and 3 deletions

View file

@ -32,10 +32,35 @@
"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",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
}
},

View file

@ -16,15 +16,38 @@
repo = "nixpkgs";
ref = "nixos-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, futils, nixpkgs } @ inputs:
futils.lib.eachSystem futils.lib.allSystems (system:
outputs = { self, futils, nixpkgs, pre-commit-hooks } @ inputs:
futils.lib.eachDefaultSystem (system:
let
inherit (nixpkgs) lib;
pkgs = nixpkgs.legacyPackages.${system};
in
{
checks = {
pre-commit = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt = {
enable = true;
};
};
};
};
devShell = pkgs.mkShell {
name = "blog";
@ -32,6 +55,8 @@
gnumake
hugo
];
inherit (self.checks.${system}.pre-commit) shellHook;
};
}
);