update-flake-lock/update-flake-lock.sh
DavHau 81892d6fc9 support updating multiple flake directories simultaneously
This is useful for monorepos containing multiple flakes. For example it might be desired for a nixpkgs update to happen on all sub-flakes at the same time.

Added a new option `flake-dirs` allowing to specify multiple flake directories to be updated simultaneously via a single PR
2024-03-07 13:07:24 +07:00

34 lines
747 B
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
update(){
if [[ -n "${TARGETS:-}" ]]; then
inputs=()
for input in $TARGETS; do
inputs+=("--update-input" "$input")
done
nix "${options[@]}" flake lock "${inputs[@]}" --commit-lock-file --commit-lockfile-summary "$COMMIT_MSG"
else
nix "${options[@]}" flake update --commit-lock-file --commit-lockfile-summary "$COMMIT_MSG"
fi
}
options=()
if [[ -n "${NIX_OPTIONS:-}" ]]; then
for option in $NIX_OPTIONS; do
options+=("${option}")
done
fi
if [[ -n "${PATH_TO_FLAKE_DIR:-}" ]]; then
cd "$PATH_TO_FLAKE_DIR"
update
elif [[ -n "${FLAKE_DIRS:-}" ]]; then
for flake_dir in $FLAKE_DIRS; do
cd "$flake_dir"
update
done
else
update
fi