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