mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 14:40:29 +00:00
Avoid undefined variables in activation script
This commit is contained in:
parent
fea693ba16
commit
4f1eec8180
3 changed files with 17 additions and 8 deletions
|
@ -47,10 +47,15 @@ else
|
|||
fi
|
||||
|
||||
$VERBOSE_ECHO "Activation variables:"
|
||||
$VERBOSE_ECHO " oldGenNum=$oldGenNum"
|
||||
$VERBOSE_ECHO " newGenNum=$newGenNum"
|
||||
$VERBOSE_ECHO " oldGenPath=$oldGenPath"
|
||||
if [[ -v oldGenNum ]] ; then
|
||||
$VERBOSE_ECHO " oldGenNum=$oldGenNum"
|
||||
$VERBOSE_ECHO " oldGenPath=$oldGenPath"
|
||||
else
|
||||
$VERBOSE_ECHO " oldGenNum undefined (first run?)"
|
||||
$VERBOSE_ECHO " oldGenPath undefined (first run?)"
|
||||
fi
|
||||
$VERBOSE_ECHO " newGenPath=$newGenPath"
|
||||
$VERBOSE_ECHO " newGenNum=$newGenNum"
|
||||
$VERBOSE_ECHO " newGenProfilePath=$newGenProfilePath"
|
||||
$VERBOSE_ECHO " newGenGcPath=$newGenGcPath"
|
||||
$VERBOSE_ECHO " genProfilePath=$genProfilePath"
|
||||
|
|
|
@ -281,7 +281,7 @@ in
|
|||
}
|
||||
|
||||
function cleanOldGen() {
|
||||
if [[ -z "$oldGenPath" ]] ; then
|
||||
if [[ ! -v oldGenPath ]] ; then
|
||||
return
|
||||
fi
|
||||
|
||||
|
@ -294,7 +294,7 @@ in
|
|||
| xargs -0 bash ${cleanup} "$newGenFiles" "$oldGenFiles"
|
||||
}
|
||||
|
||||
if [[ "$oldGenPath" != "$newGenPath" ]] ; then
|
||||
if [[ ! -v oldGenPath || "$oldGenPath" != "$newGenPath" ]] ; then
|
||||
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenProfilePath"
|
||||
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenProfilePath" "$genProfilePath"
|
||||
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenGcPath"
|
||||
|
|
|
@ -74,17 +74,21 @@ in
|
|||
local workDir
|
||||
workDir="$(mktemp -d)"
|
||||
|
||||
if [[ -v oldGenPath ]] ; then
|
||||
local oldUserServicePath="$oldGenPath/home-files/.config/systemd/user"
|
||||
fi
|
||||
|
||||
local newUserServicePath="$newGenPath/home-files/.config/systemd/user"
|
||||
local oldServiceFiles="$workDir/old-files"
|
||||
local newServiceFiles="$workDir/new-files"
|
||||
local servicesDiffFile="$workDir/diff-files"
|
||||
|
||||
if [[ ! -d "$oldUserServicePath" && ! -d "$newUserServicePath" ]]; then
|
||||
if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") \
|
||||
&& ! -d "$newUserServicePath" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ ! -d "$oldUserServicePath" ]]; then
|
||||
if [[ ! (-v oldUserServicePath && -d "$oldUserServicePath") ]]; then
|
||||
touch "$oldServiceFiles"
|
||||
else
|
||||
find "$oldUserServicePath" \
|
||||
|
|
Loading…
Reference in a new issue