shell.nix: Add update-sources script
This commit is contained in:
parent
208922d9f9
commit
d5cd67a5f2
13
shell.nix
13
shell.nix
|
@ -10,12 +10,23 @@ let
|
||||||
nixpkgs-fmt.enable = true;
|
nixpkgs-fmt.enable = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
update-sources = pkgs.writeShellScriptBin "update-sources" ''
|
||||||
|
set -e
|
||||||
|
git diff --exit-code -s nix/sources.json || (echo "File nix/sources.json has unstaged changes, refusing to update." >&2 && exit 1)
|
||||||
|
git diff --cached --exit-code -s nix/sources.json || (echo "File nix/sources.json has staged changes, refusing to update." >&2 && exit 1)
|
||||||
|
niv update
|
||||||
|
git diff --exit-code -s nix/sources.json && echo "Already up to date." && exit 0
|
||||||
|
git commit -m "Update sources" nix/sources.json
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = (with pkgs; [
|
||||||
git
|
git
|
||||||
niv
|
niv
|
||||||
nixpkgs-fmt
|
nixpkgs-fmt
|
||||||
|
]) ++ [
|
||||||
|
update-sources
|
||||||
];
|
];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
${pre-commit-check.shellHook}
|
${pre-commit-check.shellHook}
|
||||||
|
|
Loading…
Reference in a new issue