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

home-manager: set profile path variables lazily

We only need the Home Manager path variables when performing a few
operations, so only set the variables for those operations.

This avoids problems on fresh installations, where no profile
directory exists.

Fixes #4403

(cherry picked from commit ae896c810f)
This commit is contained in:
e-nikolov 2023-09-14 04:13:15 +02:00 committed by Robert Helgesson
parent 04bac349d5
commit f51e5fdd70
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -623,6 +623,8 @@ function doSwitch() {
} }
function doListGens() { function doListGens() {
setHomeManagerPathVariables
# Whether to colorize the generations output. # Whether to colorize the generations output.
local color="never" local color="never"
if [[ ! -v NO_COLOR && -t 1 ]]; then if [[ ! -v NO_COLOR && -t 1 ]]; then
@ -640,6 +642,7 @@ function doListGens() {
# Removes linked generations. Takes as arguments identifiers of # Removes linked generations. Takes as arguments identifiers of
# generations to remove. # generations to remove.
function doRmGenerations() { function doRmGenerations() {
setHomeManagerPathVariables
setVerboseAndDryRun setVerboseAndDryRun
pushd "$HM_PROFILE_DIR" > /dev/null pushd "$HM_PROFILE_DIR" > /dev/null
@ -661,6 +664,8 @@ function doRmGenerations() {
} }
function doExpireGenerations() { function doExpireGenerations() {
setHomeManagerPathVariables
local generations local generations
generations="$( \ generations="$( \
find "$HM_PROFILE_DIR" -name 'home-manager-*-link' -not -newermt "$1" \ find "$HM_PROFILE_DIR" -name 'home-manager-*-link' -not -newermt "$1" \
@ -759,6 +764,7 @@ function doShowNews() {
} }
function doUninstall() { function doUninstall() {
setHomeManagerPathVariables
setVerboseAndDryRun setVerboseAndDryRun
setNixProfileCommands setNixProfileCommands
@ -893,8 +899,6 @@ COMMAND=""
COMMAND_ARGS=() COMMAND_ARGS=()
FLAKE_ARG="" FLAKE_ARG=""
setHomeManagerPathVariables
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
opt="$1" opt="$1"
shift shift