Skip to content

Commit 68202fe

Browse files
authored
Add a hook to check that flake.lock is in sync
1 parent b7ca8f6 commit 68202fe

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

modules/hooks.nix

+20
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,26 @@ in
692692
entry = "${tools.nixpkgs-fmt}/bin/nixpkgs-fmt";
693693
files = "\\.nix$";
694694
};
695+
nix-flake-lock =
696+
{
697+
name = "nix-flake-lock";
698+
description = "Check that flake.lock is up to date";
699+
types = [ "file" ];
700+
pass_filenames = false;
701+
files = "flake.*$";
702+
entry = lib.getExe (pkgs.writeShellApplication {
703+
name = "nix-flake-lock";
704+
text = ''
705+
echo "Checking that flake.lock is up to date"
706+
if nix flake lock --no-update-lock-file; then
707+
echo "flake.lock is up to date"
708+
else
709+
echo "flake.lock is not up to date. Run 'nix flake lock' to update it."
710+
exit 1
711+
fi
712+
'';
713+
});
714+
};
695715
statix =
696716
{
697717
name = "statix";

0 commit comments

Comments
 (0)