home-environment: extract common variable
This commit is contained in:
parent
afa573952c
commit
6de1cad8a1
|
@ -90,6 +90,8 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
homeFilePattern = "-home-manager-files/";
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -252,7 +254,6 @@ in
|
||||||
# overwrite an existing file.
|
# overwrite an existing file.
|
||||||
home.activation.checkLinkTargets = dagEntryBefore ["writeBoundary"] (
|
home.activation.checkLinkTargets = dagEntryBefore ["writeBoundary"] (
|
||||||
let
|
let
|
||||||
pattern = "-home-manager-files/";
|
|
||||||
check = pkgs.writeText "check" ''
|
check = pkgs.writeText "check" ''
|
||||||
. ${./lib-bash/color-echo.sh}
|
. ${./lib-bash/color-echo.sh}
|
||||||
|
|
||||||
|
@ -262,7 +263,7 @@ in
|
||||||
relativePath="''${sourcePath#$newGenFiles/}"
|
relativePath="''${sourcePath#$newGenFiles/}"
|
||||||
targetPath="$HOME/$relativePath"
|
targetPath="$HOME/$relativePath"
|
||||||
if [[ -e "$targetPath" \
|
if [[ -e "$targetPath" \
|
||||||
&& ! "$(readlink "$targetPath")" =~ "${pattern}" ]] ; then
|
&& ! "$(readlink "$targetPath")" =~ "${homeFilePattern}" ]] ; then
|
||||||
errorEcho "Existing file '$targetPath' is in the way"
|
errorEcho "Existing file '$targetPath' is in the way"
|
||||||
collision=1
|
collision=1
|
||||||
fi
|
fi
|
||||||
|
@ -288,8 +289,6 @@ in
|
||||||
|
|
||||||
home.activation.linkGeneration = dagEntryAfter ["writeBoundary"] (
|
home.activation.linkGeneration = dagEntryAfter ["writeBoundary"] (
|
||||||
let
|
let
|
||||||
pattern = "-home-manager-files/";
|
|
||||||
|
|
||||||
link = pkgs.writeText "link" ''
|
link = pkgs.writeText "link" ''
|
||||||
newGenFiles="$1"
|
newGenFiles="$1"
|
||||||
shift
|
shift
|
||||||
|
@ -312,7 +311,7 @@ in
|
||||||
targetPath="$HOME/$relativePath"
|
targetPath="$HOME/$relativePath"
|
||||||
if [[ -e "$newGenFiles/$relativePath" ]] ; then
|
if [[ -e "$newGenFiles/$relativePath" ]] ; then
|
||||||
$VERBOSE_ECHO "Checking $targetPath: exists"
|
$VERBOSE_ECHO "Checking $targetPath: exists"
|
||||||
elif [[ ! "$(readlink "$targetPath")" =~ "${pattern}" ]] ; then
|
elif [[ ! "$(readlink "$targetPath")" =~ "${homeFilePattern}" ]] ; then
|
||||||
warnEcho "Path '$targetPath' not link into Home Manager generation. Skipping delete."
|
warnEcho "Path '$targetPath' not link into Home Manager generation. Skipping delete."
|
||||||
else
|
else
|
||||||
$VERBOSE_ECHO "Checking $targetPath: gone (deleting)"
|
$VERBOSE_ECHO "Checking $targetPath: gone (deleting)"
|
||||||
|
|
Loading…
Reference in a new issue