shell.nix: run nix build as root

Variables mist be preserved so use `sudo -E`. Fixes #4.
This commit is contained in:
Timothy DeHerrera 2020-01-07 13:02:35 -07:00
parent 0bf18acdd4
commit 6d537c35c4
No known key found for this signature in database
GPG Key ID: 8985725DB5B0C122
2 changed files with 3 additions and 2 deletions

View File

@ -32,6 +32,7 @@ git add ./hosts/${new_host}.nix
# You can specify any of the host configurations living in the ./hosts
# directory. If omitted, it will default to your systems current hostname.
# This will be run as root.
rebuild $new_host switch
```

View File

@ -10,9 +10,9 @@ let
elif [[ $1 == "iso" ]]; then
nix build ${configs}.niximg.${build}.isoImage
elif [[ -z $2 ]]; then
nix run -vv ${configs}.${hostname}.${build}.toplevel -c switch-to-configuration $1
sudo -E nix run -vv ${configs}.${hostname}.${build}.toplevel -c switch-to-configuration $1
else
nix run -vv ${configs}.$1.${build}.toplevel -c switch-to-configuration $2
sudo -E nix run -vv ${configs}.$1.${build}.toplevel -c switch-to-configuration $2
fi
'';
in pkgs.mkShell {