packages/pin: add update-all subcommand
This commit is contained in:
parent
14b9c287f5
commit
2eca973488
2 changed files with 20 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
writeShellApplication,
|
||||
nix, npins
|
||||
nix, npins, jq
|
||||
}:
|
||||
|
||||
writeShellApplication {
|
||||
|
@ -8,6 +8,7 @@ writeShellApplication {
|
|||
runtimeInputs = [
|
||||
nix
|
||||
npins
|
||||
jq
|
||||
];
|
||||
text = builtins.readFile ./pin.sh;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,28 @@
|
|||
REPO_ROOT="${REPO_ROOT:-.}"
|
||||
NPINS_DIRECTORY="${NPINS_DIRECTORY:-npins}"
|
||||
|
||||
cmd_update() {
|
||||
for pkg in "$@"; do
|
||||
oldver=$(nix eval --raw "${REPO_ROOT}#${pkg}.version")
|
||||
npins update "$pkg"
|
||||
newver=$(nix eval --raw "${REPO_ROOT}#${pkg}.version")
|
||||
git add "${NPINS_DIRECTORY}"
|
||||
git commit "${NPINS_DIRECTORY}" -m "packages/$pkg: $oldver -> $newver" || true
|
||||
done
|
||||
}
|
||||
|
||||
cmd_update_all() {
|
||||
# shellcheck disable=SC2046
|
||||
cmd_update $(jq < "${NPINS_DIRECTORY}/sources.json" -r '.pins | keys | .[]')
|
||||
}
|
||||
|
||||
cmd="$1"
|
||||
shift
|
||||
case $cmd in
|
||||
update)
|
||||
for pkg in "$@"; do
|
||||
oldver=$(nix eval --raw "${REPO_ROOT}#${pkg}.version")
|
||||
npins update "$pkg"
|
||||
newver=$(nix eval --raw "${REPO_ROOT}#${pkg}.version")
|
||||
git add "${NPINS_DIRECTORY}"
|
||||
git commit "${NPINS_DIRECTORY}" -m "packages/$pkg: $oldver -> $newver"
|
||||
done;;
|
||||
cmd_update "$@";;
|
||||
update-all)
|
||||
cmd_update_all "$@";;
|
||||
*)
|
||||
echo Unknown command: "$cmd";;
|
||||
esac
|
Loading…
Reference in a new issue