summary refs log tree commit diff
path: root/modules/installer/tools/nixos-rebuild.sh
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2013-07-23 20:31:03 +0200
committeraszlig <aszlig@redmoonstudios.org>2013-07-26 06:23:49 +0200
commit5a2390327dc990145317e34cce87debf1ab59a9e (patch)
treeaa15d559d9f18f406ce7ed30bbf9e436d82d13b0 /modules/installer/tools/nixos-rebuild.sh
parentef5e2be3390a45b90912c95a6db9de93485d322a (diff)
downloadnixpkgs-5a2390327dc990145317e34cce87debf1ab59a9e.tar
nixpkgs-5a2390327dc990145317e34cce87debf1ab59a9e.tar.gz
nixpkgs-5a2390327dc990145317e34cce87debf1ab59a9e.tar.bz2
nixpkgs-5a2390327dc990145317e34cce87debf1ab59a9e.tar.lz
nixpkgs-5a2390327dc990145317e34cce87debf1ab59a9e.tar.xz
nixpkgs-5a2390327dc990145317e34cce87debf1ab59a9e.tar.zst
nixpkgs-5a2390327dc990145317e34cce87debf1ab59a9e.zip
nixos-rebuild: Allow to use --repair.
Unfortunately, the flag only works directly and without the daemon, so
this adds an extra variable $repair, to avoid the daemon. This is to
avoid to iterate through the $extraBuildFlags just to test whether
"--repair" exists.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'modules/installer/tools/nixos-rebuild.sh')
-rw-r--r--modules/installer/tools/nixos-rebuild.sh9
1 files changed, 8 insertions, 1 deletions
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