diff --git a/modules/installer/tools/nixos-rebuild.sh b/modules/installer/tools/nixos-rebuild.sh index 7fd0908a935..9bb13061ed9 100644 --- a/modules/installer/tools/nixos-rebuild.sh +++ b/modules/installer/tools/nixos-rebuild.sh @@ -49,6 +49,7 @@ action= buildNix=1 rollback= upgrade= +repair= while [ "$#" -gt 0 ]; do i="$1"; shift 1 @@ -71,6 +72,10 @@ while [ "$#" -gt 0 ]; do --upgrade) upgrade=1 ;; + --repair) + repair=1 + extraBuildFlags+=("$i") + ;; --show-trace|--no-build-hook|--keep-failed|-K|--keep-going|-k|--verbose|-v|--fallback|--repair) extraBuildFlags+=("$i") ;; @@ -111,7 +116,9 @@ trap 'rm -rf "$tmpDir"' EXIT # This matters if the new Nix in Nixpkgs has a schema change. It # would upgrade the schema, which should only happen once we actually # switch to the new configuration. -if systemctl show nix-daemon.socket nix-daemon.service | grep -q ActiveState=active; then +# If --repair is given, don't try to use the Nix daemon, because the +# flag can only be used directly. +if [ -z "$repair" ] && systemctl show nix-daemon.socket nix-daemon.service | grep -q ActiveState=active; then export NIX_REMOTE=${NIX_REMOTE:-daemon} fi