From 6d537c35c4bebc57740e2ab9b92acac99abdad6b Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Tue, 7 Jan 2020 13:02:35 -0700 Subject: [PATCH] shell.nix: run nix build as root Variables mist be preserved so use `sudo -E`. Fixes #4. --- README.md | 1 + shell.nix | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c2d130e..ec47e1e 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/shell.nix b/shell.nix index 95264c1..a8af3c7 100644 --- a/shell.nix +++ b/shell.nix @@ -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 {