nixos-rebuild: Propagate various flake lock file flags

And also --refresh and --no-net.
This commit is contained in:
Eelco Dolstra 2020-02-05 16:00:58 +01:00
parent 60330b6065
commit c08930874a

View File

@ -16,6 +16,7 @@ showSyntax() {
# Parse the command line. # Parse the command line.
origArgs=("$@") origArgs=("$@")
extraBuildFlags=() extraBuildFlags=()
lockFlags=()
action= action=
buildNix=1 buildNix=1
fast= fast=
@ -61,7 +62,7 @@ while [ "$#" -gt 0 ]; do
j="$1"; shift 1 j="$1"; shift 1
extraBuildFlags+=("$i" "$j") extraBuildFlags+=("$i" "$j")
;; ;;
--show-trace|--keep-failed|-K|--keep-going|-k|--verbose|-v|-vv|-vvv|-vvvv|-vvvvv|--fallback|--repair|--no-build-output|-Q|-j*|-L) --show-trace|--keep-failed|-K|--keep-going|-k|--verbose|-v|-vv|-vvv|-vvvv|-vvvvv|--fallback|--repair|--no-build-output|-Q|-j*|-L|--refresh|--no-net)
extraBuildFlags+=("$i") extraBuildFlags+=("$i")
;; ;;
--option) --option)
@ -100,6 +101,18 @@ while [ "$#" -gt 0 ]; do
flake="$1" flake="$1"
shift 1 shift 1
;; ;;
--recreate-lock-file|--no-update-lock-file|--no-write-lock-file|--no-registries|--commit-lock-file)
lockFlags+=("$i")
;;
--update-input)
j="$1"; shift 1
lockFlags+=("$i" "$j")
;;
--override-input)
j="$1"; shift 1
k="$1"; shift 1
lockFlags+=("$i" "$j" "$k")
;;
*) *)
echo "$0: unknown option \`$i'" echo "$0: unknown option \`$i'"
exit 1 exit 1
@ -268,7 +281,7 @@ fi
# Resolve the flake. # Resolve the flake.
if [[ -n $flake ]]; then if [[ -n $flake ]]; then
flake=$(nix flake info --json "${extraBuildFlags[@]}" -- "$flake" | jq -r .url) flake=$(nix flake info --json "${extraBuildFlags[@]}" "${lockFlags[@]}" -- "$flake" | jq -r .url)
fi fi
# Find configuration.nix and open editor instead of building. # Find configuration.nix and open editor instead of building.
@ -402,7 +415,7 @@ if [ -z "$rollback" ]; then
else else
outLink=$tmpDir/result outLink=$tmpDir/result
nix build "$flake#$flakeAttr.config.system.build.toplevel" \ nix build "$flake#$flakeAttr.config.system.build.toplevel" \
--keep-going "${extraBuildFlags[@]}" --out-link $outLink --keep-going "${extraBuildFlags[@]}" "${lockFlags[@]}" --out-link $outLink
pathToConfig="$(readlink -f $outLink)" pathToConfig="$(readlink -f $outLink)"
fi fi
copyToTarget "$pathToConfig" copyToTarget "$pathToConfig"
@ -411,7 +424,7 @@ if [ -z "$rollback" ]; then
if [[ -z $flake ]]; then if [[ -z $flake ]]; then
pathToConfig="$(nixBuild '<nixpkgs/nixos>' -A system -k "${extraBuildFlags[@]}")" pathToConfig="$(nixBuild '<nixpkgs/nixos>' -A system -k "${extraBuildFlags[@]}")"
else else
nix build "$flake#$flakeAttr.config.system.build.toplevel" --keep-going "${extraBuildFlags[@]}" nix build "$flake#$flakeAttr.config.system.build.toplevel" --keep-going "${extraBuildFlags[@]}" "${lockFlags[@]}"
pathToConfig="$(readlink -f ./result)" pathToConfig="$(readlink -f ./result)"
fi fi
elif [ "$action" = build-vm ]; then elif [ "$action" = build-vm ]; then