From ae896c810f501bf0c3a2fd7fc2de094dd0addf01 Mon Sep 17 00:00:00 2001 From: e-nikolov Date: Thu, 14 Sep 2023 04:13:15 +0200 Subject: [PATCH] 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 --- home-manager/home-manager | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/home-manager/home-manager b/home-manager/home-manager index 5486b4eb..513d2f88 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -648,6 +648,8 @@ function doSwitch() { } function doListGens() { + setHomeManagerPathVariables + # Whether to colorize the generations output. local color="never" if [[ ! -v NO_COLOR && -t 1 ]]; then @@ -665,6 +667,7 @@ function doListGens() { # Removes linked generations. Takes as arguments identifiers of # generations to remove. function doRmGenerations() { + setHomeManagerPathVariables setVerboseAndDryRun pushd "$HM_PROFILE_DIR" > /dev/null @@ -686,6 +689,8 @@ function doRmGenerations() { } function doExpireGenerations() { + setHomeManagerPathVariables + local generations generations="$( \ find "$HM_PROFILE_DIR" -name 'home-manager-*-link' -not -newermt "$1" \ @@ -810,6 +815,7 @@ function doShowNews() { } function doUninstall() { + setHomeManagerPathVariables setVerboseAndDryRun setNixProfileCommands @@ -945,8 +951,6 @@ COMMAND="" COMMAND_ARGS=() FLAKE_ARG="" -setHomeManagerPathVariables - while [[ $# -gt 0 ]]; do opt="$1" shift