scripts: add an "update" script to update all my packages
it probably doesnt update feeds yet, though
This commit is contained in:
parent
86adc38537
commit
2b11bac1eb
53
scripts/update
Executable file
53
scripts/update
Executable file
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p nix-update
|
||||
|
||||
usage() {
|
||||
echo "update: update rev/hash for one or more packages"
|
||||
echo "usage: update [attr-path]"
|
||||
echo ""
|
||||
echo "examples:"
|
||||
echo "update nixpkgs: update only the nixpkgs input"
|
||||
echo "update sane: update every package under the 'sane' attribute"
|
||||
echo "update: update everything i know how to update"
|
||||
}
|
||||
|
||||
warn() {
|
||||
echo "$@"
|
||||
}
|
||||
info() {
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
# usage: getPkgs outVar prefix
|
||||
getPkgs() {
|
||||
local -n attrsArr="$1"
|
||||
local attrPrefix="$2"
|
||||
if [ -z "$attrPrefix" ]; then
|
||||
attrPrefix=sane
|
||||
fi
|
||||
|
||||
local attrs="$(nix-env -f . --query --available --attr-path --no-name -A $attrPrefix)"
|
||||
attrsArr=($attrs)
|
||||
}
|
||||
|
||||
updateOnePkg() {
|
||||
local attrPath="$1"
|
||||
local updateScript="$(nix eval --raw -f . $attrPath.passthru.updateScript --apply 'builtins.concatStringsSep "'" "'"')"
|
||||
if [ -z "$updateScript" ]; then
|
||||
warn "don't know how to update '$attrPath'"
|
||||
return
|
||||
fi
|
||||
local UPDATE_NIX_NAME="$(nix eval --raw -f . $attrPath.name)"
|
||||
local UPDATE_NIX_PNAME="$(nix eval --raw -f . $attrPath.pname)"
|
||||
local UPDATE_NIX_OLD_VERSION="$(nix eval --raw -f . $attrPath.version)"
|
||||
info "updating: '$attrPath'"
|
||||
# we lose spaces inside the exec args... could `nix eval` without `--raw` to fix that.
|
||||
UPDATE_NIX_NAME="$UPDATE_NIX_NAME" UPDATE_NIX_PNAME="$UPDATE_NIX_PNAME" UPDATE_NIX_OLD_VERSION="$UPDATE_NIX_OLD_VERSION" UPDATE_NIX_ATTR_PATH="$attrPath" eval $updateScript
|
||||
}
|
||||
|
||||
pkgsToUpdate=()
|
||||
getPkgs pkgsToUpdate
|
||||
|
||||
for p in "${pkgsToUpdate[@]}"; do
|
||||
updateOnePkg "$p"
|
||||
done
|
Loading…
Reference in New Issue
Block a user