2024-06-03 05:30:03 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2024-06-07 07:34:51 +00:00
|
|
|
showHelp() {
|
|
|
|
echo "update: updates flake inputs"
|
|
|
|
echo "usage: update [flags] [input [input ...]]"
|
|
|
|
echo ""
|
|
|
|
echo "flags:"
|
|
|
|
echo " --help"
|
|
|
|
echo " --dry-run"
|
|
|
|
echo "inputs:"
|
|
|
|
echo " all: update every input"
|
|
|
|
echo " safe: update inputs which rarely break the build, or are trivial to patch"
|
|
|
|
echo " unsafe: update inputs which may be annoying to patch if they break the build"
|
|
|
|
echo " nixpkgs"
|
|
|
|
echo " next"
|
|
|
|
}
|
|
|
|
|
2024-06-03 05:30:03 +00:00
|
|
|
inputs=()
|
2024-06-07 07:34:51 +00:00
|
|
|
dryRun=
|
|
|
|
|
|
|
|
parseArgs() {
|
|
|
|
for arg in "$@"; do
|
|
|
|
case $arg in
|
|
|
|
(--help)
|
|
|
|
showHelp
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
(--dry-run)
|
|
|
|
dryRun=1
|
|
|
|
;;
|
|
|
|
(*)
|
|
|
|
addInputs "$arg"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
# if no inputs were specified, assume "all"
|
|
|
|
if [ ${#inputs} -eq 0 ]; then
|
|
|
|
addInputs all
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# add $1 to `inputs` array, after parsing it
|
2024-06-03 05:30:03 +00:00
|
|
|
addInputs() {
|
|
|
|
case $1 in
|
2024-06-07 07:34:51 +00:00
|
|
|
(all)
|
|
|
|
addInputs safe
|
|
|
|
addInputs unsafe
|
|
|
|
;;
|
|
|
|
(next)
|
|
|
|
addInputs nixpkgs-next-unpatched
|
|
|
|
addInputs nixpkgs-staging-unpatched
|
|
|
|
;;
|
2024-06-03 05:30:03 +00:00
|
|
|
(safe)
|
2024-06-07 07:34:51 +00:00
|
|
|
addInputs next
|
|
|
|
addInputs nixpkgs-unpatched
|
|
|
|
addInputs sops-nix
|
|
|
|
addInputs uninsane-dot-org
|
2024-06-03 05:30:03 +00:00
|
|
|
;;
|
|
|
|
(unsafe)
|
|
|
|
# these tend to break more frequently
|
2024-06-07 07:34:51 +00:00
|
|
|
addInputs mobile-nixos
|
|
|
|
addInputs nixpkgs-wayland
|
|
|
|
;;
|
|
|
|
(mobile-nixos|nixpkgs-next-unpatched|nixpkgs-staging-unpatched|nixpkgs-unpatched|nixpkgs-wayland|sops-nix|uninsane-dot-org)
|
|
|
|
inputs+=("$1")
|
2024-06-03 05:30:03 +00:00
|
|
|
;;
|
|
|
|
(*)
|
|
|
|
echo "unknown input '$1'"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2024-06-07 07:34:51 +00:00
|
|
|
# exec $@, unless we're in a dry-run in which case just print what would be done
|
|
|
|
doEffect() {
|
|
|
|
if [ -n "$dryRun" ]; then
|
|
|
|
echo "dry-run: $*"
|
|
|
|
else
|
|
|
|
"$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
parseArgs "$@"
|
2024-06-03 05:30:03 +00:00
|
|
|
|
|
|
|
echo "updating:" "${inputs[@]}"
|
|
|
|
nixFlags=()
|
|
|
|
for i in "${inputs[@]}"; do
|
|
|
|
nixFlags+=("--update-input" "$i")
|
|
|
|
done
|
2024-06-07 07:34:51 +00:00
|
|
|
|
|
|
|
doEffect nix flake lock "${nixFlags[@]}"
|