1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

home-manager: respect NIX_STATE_DIR

This allows to install home-manager on a system without root access.

PR #1196
This commit is contained in:
Dmitry Kalinkin 2020-04-25 12:24:13 -04:00 committed by Robert Helgesson
parent 7682eb88c4
commit dc227b579d
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
2 changed files with 10 additions and 7 deletions

View file

@ -221,7 +221,7 @@ function doListGens() {
color="always" color="always"
fi fi
pushd "/nix/var/nix/profiles/per-user/$USER" > /dev/null pushd "$NIX_STATE_DIR/profiles/per-user/$USER" > /dev/null
# shellcheck disable=2012 # shellcheck disable=2012
ls --color=$color -gG --time-style=long-iso --sort time home-manager-*-link \ ls --color=$color -gG --time-style=long-iso --sort time home-manager-*-link \
| cut -d' ' -f 4- \ | cut -d' ' -f 4- \
@ -234,7 +234,7 @@ function doListGens() {
function doRmGenerations() { function doRmGenerations() {
setVerboseAndDryRun 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 for generationId in "$@"; do
local linkName="home-manager-$generationId-link" local linkName="home-manager-$generationId-link"
@ -254,11 +254,11 @@ function doRmGenerations() {
function doRmAllGenerations() { function doRmAllGenerations() {
$DRY_RUN_CMD rm $VERBOSE_ARG \ $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() { function doExpireGenerations() {
local profileDir="/nix/var/nix/profiles/per-user/$USER" local profileDir="$NIX_STATE_DIR/profiles/per-user/$USER"
local generations local generations
generations="$( \ generations="$( \
@ -372,7 +372,7 @@ function doUninstall() {
$DRY_RUN_CMD rm $VERBOSE_ARG -r \ $DRY_RUN_CMD rm $VERBOSE_ARG -r \
"${XDG_DATA_HOME:-$HOME/.local/share}/home-manager" "${XDG_DATA_HOME:-$HOME/.local/share}/home-manager"
$DRY_RUN_CMD rm $VERBOSE_ARG \ $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!" echo "Yay!"
@ -454,6 +454,8 @@ function doHelp() {
echo " uninstall Remove Home Manager" echo " uninstall Remove Home Manager"
} }
readonly NIX_STATE_DIR="${NIX_STATE_DIR:-/nix/var/nix}"
EXTRA_NIX_PATH=() EXTRA_NIX_PATH=()
HOME_MANAGER_CONFIG_ATTRIBUTE="" HOME_MANAGER_CONFIG_ATTRIBUTE=""
PASSTHROUGH_OPTS=() PASSTHROUGH_OPTS=()

View file

@ -1,8 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
function setupVars() { function setupVars() {
local profilesPath="/nix/var/nix/profiles/per-user/$USER" local nixStateDir="${NIX_STATE_DIR:-/nix/var/nix}"
local gcPath="/nix/var/nix/gcroots/per-user/$USER" local profilesPath="$nixStateDir/profiles/per-user/$USER"
local gcPath="$nixStateDir/gcroots/per-user/$USER"
genProfilePath="$profilesPath/home-manager" genProfilePath="$profilesPath/home-manager"
newGenPath="@GENERATION_DIR@"; newGenPath="@GENERATION_DIR@";