forked from extern/flakelight
Have devShell install git pre-commit hook
This commit is contained in:
parent
07e68ac51b
commit
9c40724207
@ -62,6 +62,14 @@ let
|
|||||||
+ optionalString (!pathExists (src + /.ecrc))
|
+ optionalString (!pathExists (src + /.ecrc))
|
||||||
" -disable-indent-size -disable-max-line-length";
|
" -disable-indent-size -disable-max-line-length";
|
||||||
});
|
});
|
||||||
|
shellHook = { lib, flakelite }: ''
|
||||||
|
if [ -f flake.nix ] && [ -d .git/hooks ] &&
|
||||||
|
[ ! -f .git/hooks/pre-commit ]; then
|
||||||
|
echo Installing git pre-commit hook...
|
||||||
|
cp ${lib.getExe flakelite.inputs'.flakelite.packages.pre-commit
|
||||||
|
} .git/hooks
|
||||||
|
fi
|
||||||
|
'';
|
||||||
devTools = pkgs: with pkgs; [ nixpkgs-fmt nodePackages.prettier ];
|
devTools = pkgs: with pkgs; [ nixpkgs-fmt nodePackages.prettier ];
|
||||||
formatters = {
|
formatters = {
|
||||||
"*.nix" = "nixpkgs-fmt";
|
"*.nix" = "nixpkgs-fmt";
|
||||||
|
@ -6,9 +6,10 @@
|
|||||||
inputs.nixpkgs.url = "nixpkgs/nixos-22.11";
|
inputs.nixpkgs.url = "nixpkgs/nixos-22.11";
|
||||||
outputs = inputs:
|
outputs = inputs:
|
||||||
let
|
let
|
||||||
lib = import ./. inputs;
|
flakelite.lib = import ./. inputs;
|
||||||
in
|
in
|
||||||
lib.mkFlake ./. {
|
flakelite.lib.mkFlake ./. {
|
||||||
outputs = { inherit lib; };
|
nixDir = ./.;
|
||||||
|
outputs = flakelite;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
5
packages/pre-commit
Normal file
5
packages/pre-commit
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
TREE=$(mktemp -d)
|
||||||
|
git archive "$(git write-tree)" | tar -xC "$TREE"
|
||||||
|
nix flake check "$TREE"
|
10
packages/pre-commit.nix
Normal file
10
packages/pre-commit.nix
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{ writeShellApplication
|
||||||
|
, nix
|
||||||
|
, git
|
||||||
|
, gnutar
|
||||||
|
}:
|
||||||
|
writeShellApplication {
|
||||||
|
name = "pre-commit";
|
||||||
|
runtimeInputs = [ nix git gnutar ];
|
||||||
|
text = builtins.readFile ./pre-commit;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user