scripts/update: implement -j option to control the number of parallel update jobs
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
#!nix-shell -i bash -p findutils -p nix-update
|
#!nix-shell -i bash -p findutils -p nix-update
|
||||||
|
|
||||||
NIX_FILES_TOP=/home/colin/nixos
|
NIX_FILES_TOP=/home/colin/nixos
|
||||||
|
# each update job has to do an entire nix eval, which can be memory intensive; be careful when tuning this
|
||||||
|
PARALLELISM=8
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "update: update rev/hash for one or more packages"
|
echo "update: update rev/hash for one or more packages"
|
||||||
@@ -10,6 +12,7 @@ usage() {
|
|||||||
echo "options:"
|
echo "options:"
|
||||||
echo "- --dry-run"
|
echo "- --dry-run"
|
||||||
echo "- --verbose"
|
echo "- --verbose"
|
||||||
|
echo "- -j <n> (default: $PARALLELISM)"
|
||||||
echo ""
|
echo ""
|
||||||
echo "examples:"
|
echo "examples:"
|
||||||
echo "- update nixpkgs: update only the nixpkgs input"
|
echo "- update nixpkgs: update only the nixpkgs input"
|
||||||
@@ -82,8 +85,8 @@ updateOnePkg() {
|
|||||||
updatePkgsInParallel() {
|
updatePkgsInParallel() {
|
||||||
debug "updating packages in parallel using xargs"
|
debug "updating packages in parallel using xargs"
|
||||||
debug "- $@"
|
debug "- $@"
|
||||||
debug "- xargs -n 1 -P 4 $0 ${scriptFlags[*]}"
|
debug "- xargs -n 1 -P $PARALLELISM $0 ${scriptFlags[*]}"
|
||||||
echo "$@" | xargs -n 1 -P 4 "$0" "${scriptFlags[@]}"
|
echo "$@" | xargs -n 1 -P "$PARALLELISM" "$0" "${scriptFlags[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
scriptFlags=()
|
scriptFlags=()
|
||||||
@@ -107,6 +110,10 @@ parseArgs() {
|
|||||||
scriptFlags+=(--verbose)
|
scriptFlags+=(--verbose)
|
||||||
verbose=1
|
verbose=1
|
||||||
;;
|
;;
|
||||||
|
(-j)
|
||||||
|
PARALLELISM=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
(--*)
|
(--*)
|
||||||
nixFlags+=("$arg")
|
nixFlags+=("$arg")
|
||||||
;;
|
;;
|
||||||
|
Reference in New Issue
Block a user