diff options
author | Dmitry Kalinkin <dmitry.kalinkin@gmail.com> | 2020-04-25 12:24:13 -0400 |
---|---|---|
committer | Robert Helgesson <robert@rycee.net> | 2020-06-14 20:41:55 +0200 |
commit | dc227b579d71f92e24717dac09bbe3846d5a6597 (patch) | |
tree | 9c2cf547257d1261d3dfa84a4656bb5322821dbf | |
parent | 7682eb88c496a4ab700b225630589c96cee64600 (diff) |
home-manager: respect NIX_STATE_DIR
This allows to install home-manager on a system without root access.
PR #1196
-rw-r--r-- | home-manager/home-manager | 12 | ||||
-rwxr-xr-x | modules/lib-bash/activation-init.sh | 5 |
2 files changed, 10 insertions, 7 deletions
diff --git a/home-manager/home-manager b/home-manager/home-manager index 84daffe0498..6903c7bfeeb 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -221,7 +221,7 @@ function doListGens() { color="always" fi - pushd "/nix/var/nix/profiles/per-user/$USER" > /dev/null + pushd "$NIX_STATE_DIR/profiles/per-user/$USER" > /dev/null # shellcheck disable=2012 ls --color=$color -gG --time-style=long-iso --sort time home-manager-*-link \ | cut -d' ' -f 4- \ @@ -234,7 +234,7 @@ function doListGens() { function doRmGenerations() { setVerboseAndDryRun - pushd "/nix/var/nix/profiles/per-user/$USER" > /dev/null + pushd "$NIX_STATE_DIR/profiles/per-user/$USER" > /dev/null for generationId in "$@"; do local linkName="home-manager-$generationId-link" @@ -254,11 +254,11 @@ function doRmGenerations() { function doRmAllGenerations() { $DRY_RUN_CMD rm $VERBOSE_ARG \ - "/nix/var/nix/profiles/per-user/$USER/home-manager"* + "$NIX_STATE_DIR/profiles/per-user/$USER/home-manager"* } function doExpireGenerations() { - local profileDir="/nix/var/nix/profiles/per-user/$USER" + local profileDir="$NIX_STATE_DIR/profiles/per-user/$USER" local generations generations="$( \ @@ -372,7 +372,7 @@ function doUninstall() { $DRY_RUN_CMD rm $VERBOSE_ARG -r \ "${XDG_DATA_HOME:-$HOME/.local/share}/home-manager" $DRY_RUN_CMD rm $VERBOSE_ARG \ - "/nix/var/nix/gcroots/per-user/$USER/current-home" + "$NIX_STATE_DIR/gcroots/per-user/$USER/current-home" ;; *) echo "Yay!" @@ -454,6 +454,8 @@ function doHelp() { echo " uninstall Remove Home Manager" } +readonly NIX_STATE_DIR="${NIX_STATE_DIR:-/nix/var/nix}" + EXTRA_NIX_PATH=() HOME_MANAGER_CONFIG_ATTRIBUTE="" PASSTHROUGH_OPTS=() diff --git a/modules/lib-bash/activation-init.sh b/modules/lib-bash/activation-init.sh index ecf1f550c3e..f95008ee75b 100755 --- a/modules/lib-bash/activation-init.sh +++ b/modules/lib-bash/activation-init.sh @@ -1,8 +1,9 @@ #!/usr/bin/env bash function setupVars() { - local profilesPath="/nix/var/nix/profiles/per-user/$USER" - local gcPath="/nix/var/nix/gcroots/per-user/$USER" + local nixStateDir="${NIX_STATE_DIR:-/nix/var/nix}" + local profilesPath="$nixStateDir/profiles/per-user/$USER" + local gcPath="$nixStateDir/gcroots/per-user/$USER" genProfilePath="$profilesPath/home-manager" newGenPath="@GENERATION_DIR@"; |