nixpkgs: update
[julm/julm-nix.git] / install
diff --git a/install b/install
index 73a137c94c987f7a701119714598d3e2d73fe70e..fa3c41c2a276b6c6cc09cbbd0cdb7a28888d44c9 100755 (executable)
--- a/install
+++ b/install
@@ -1,3 +1,12 @@
 #!/bin/sh -eux
-sudo nixos-rebuild switch --flake "${0%/*}"/ "$@"
-sudo nix-env --delete-generations +2 --profile /nix/var/nix/profiles/system
+if test "$(id -u)" != 0
+then sudo "$0" "$@"
+else
+  cd "${0%/*}"
+  chmod -R g-rwx,o-rwx "$PWD/private/root"
+  ln -sfn "$PWD/private/root" /root/private
+  trap 'git reset private/root' EXIT
+  git rm -rf --cached --ignore-unmatch private/root # prevent copying to /nix/store
+  nixos-rebuild switch --flake . "$@"
+  nix-env --delete-generations +9 --profile /nix/var/nix/profiles/system
+fi