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>
This commit is contained in:
aszlig 2013-07-23 20:31:03 +02:00
parent ef5e2be339
commit 5a2390327d
No known key found for this signature in database
GPG Key ID: D0EBD0EC8C2DC961

View File

@ -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