shell.nix: Make scripts definition more dynamic
This commit is contained in:
parent
89d9af9834
commit
e68bf4f2b6
22
shell.nix
22
shell.nix
|
@ -11,23 +11,23 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
update-sources = pkgs.writeShellScriptBin "update-sources" ''
|
scripts = {
|
||||||
set -e
|
update-sources = ''
|
||||||
git diff --exit-code -s nix/sources.json || (echo "File nix/sources.json has unstaged changes, refusing to update." >&2 && exit 1)
|
set -e
|
||||||
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 --exit-code -s nix/sources.json || (echo "File nix/sources.json has unstaged changes, refusing to update." >&2 && exit 1)
|
||||||
niv update
|
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 --exit-code -s nix/sources.json && echo "Already up to date." && exit 0
|
niv update
|
||||||
git commit -m "Update sources" nix/sources.json
|
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 {
|
||||||
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}
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in a new issue