shell.nix: Make scripts definition more dynamic

restic-rest-server
Simon Bruder 2020-12-13 16:10:18 +01:00
parent 89d9af9834
commit e68bf4f2b6
No known key found for this signature in database
GPG Key ID: 6F03E0000CC5B62F
1 changed files with 11 additions and 11 deletions

View File

@ -11,7 +11,8 @@ let
}; };
}; };
update-sources = pkgs.writeShellScriptBin "update-sources" '' scripts = {
update-sources = ''
set -e 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 --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) git diff --cached --exit-code -s nix/sources.json || (echo "File nix/sources.json has staged changes, refusing to update." >&2 && exit 1)
@ -19,15 +20,14 @@ let
git diff --exit-code -s nix/sources.json && echo "Already up to date." && exit 0 git diff --exit-code -s nix/sources.json && echo "Already up to date." && exit 0
git commit -m "Update sources" nix/sources.json git commit -m "Update sources" nix/sources.json
''; '';
};
in in
pkgs.mkShell { pkgs.mkShell {
buildInputs = (with pkgs; [ buildInputs = (with pkgs; [
git git
niv niv
nixpkgs-fmt nixpkgs-fmt
]) ++ [ ]) ++ (builtins.attrValues (builtins.mapAttrs pkgs.writeShellScriptBin scripts));
update-sources
];
shellHook = '' shellHook = ''
${pre-commit-check.shellHook} ${pre-commit-check.shellHook}
''; '';