forked from pub-solar/os
shell: use devshell-native pre-commit hooks
This commit is contained in:
parent
a1fade8411
commit
2126268791
|
@ -1,5 +0,0 @@
|
||||||
repos:
|
|
||||||
- repo: https://github.com/nix-community/nixpkgs-fmt
|
|
||||||
rev: master
|
|
||||||
hooks:
|
|
||||||
- id: nixpkgs-fmt
|
|
|
@ -23,11 +23,11 @@
|
||||||
},
|
},
|
||||||
"devshell": {
|
"devshell": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1607956014,
|
"lastModified": 1611739118,
|
||||||
"narHash": "sha256-kcmh1ZO56GFYStDeM2VngJSvx/e8aKhFSYqLwfiq+Es=",
|
"narHash": "sha256-QjLEfLSiiWDdURFMkke/W7iJsA0unI3pg+91ubvmjbI=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "devshell",
|
"repo": "devshell",
|
||||||
"rev": "17f46732ce299daa2977be2978f60d258c2d1b41",
|
"rev": "d7a5ebc22aa89a40a96b413a8fc616178920567c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -34,7 +34,7 @@ let
|
||||||
|
|
||||||
name = "flk";
|
name = "flk";
|
||||||
in
|
in
|
||||||
pkgs.mkDevShell {
|
pkgs.devshell.mkShell {
|
||||||
inherit name;
|
inherit name;
|
||||||
|
|
||||||
packages = with pkgs; with installPkgs; [
|
packages = with pkgs; with installPkgs; [
|
||||||
|
@ -48,6 +48,28 @@ pkgs.mkDevShell {
|
||||||
|
|
||||||
env = { inherit name; };
|
env = { inherit name; };
|
||||||
|
|
||||||
|
git.hooks = with pkgs; {
|
||||||
|
enable = true;
|
||||||
|
pre-commit.text = ''
|
||||||
|
if ${git}/bin/git rev-parse --verify HEAD >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
against=HEAD
|
||||||
|
else
|
||||||
|
# Initial commit: diff against an empty tree object
|
||||||
|
against=$(${git}/bin/git hash-object -t tree /dev/null)
|
||||||
|
fi
|
||||||
|
# Redirect output to stderr.
|
||||||
|
exec 1>&2
|
||||||
|
|
||||||
|
# Format staged nix files.
|
||||||
|
exec ${nixpkgs-fmt}/bin/nixpkgs-fmt \
|
||||||
|
$(
|
||||||
|
${git}/bin/git diff-index --name-only --cached $against -- \
|
||||||
|
| ${ripgrep}/bin/rg '\.nix$'
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
commands = with pkgs; [
|
commands = with pkgs; [
|
||||||
{
|
{
|
||||||
name = nixpkgs-fmt.pname;
|
name = nixpkgs-fmt.pname;
|
||||||
|
@ -61,11 +83,6 @@ pkgs.mkDevShell {
|
||||||
category = "main";
|
category = "main";
|
||||||
package = flk;
|
package = flk;
|
||||||
}
|
}
|
||||||
{
|
|
||||||
name = "hooks";
|
|
||||||
help = "install git hooks";
|
|
||||||
command = "pre-commit install";
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
name = "grip";
|
name = "grip";
|
||||||
help = python38Packages.grip.meta.description;
|
help = python38Packages.grip.meta.description;
|
||||||
|
|
Loading…
Reference in a new issue