diff --git a/shell.nix b/shell.nix index 3faf34b..93eb166 100644 --- a/shell.nix +++ b/shell.nix @@ -11,23 +11,23 @@ let }; }; - 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 - ''; + scripts = { + 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 pkgs.mkShell { buildInputs = (with pkgs; [ git niv nixpkgs-fmt - ]) ++ [ - update-sources - ]; + ]) ++ (builtins.attrValues (builtins.mapAttrs pkgs.writeShellScriptBin scripts)); shellHook = '' ${pre-commit-check.shellHook} '';