2017-01-16 19:26:42 +00:00
|
|
|
function setupVars() {
|
|
|
|
local profilesPath="/nix/var/nix/profiles/per-user/$USER"
|
|
|
|
local gcPath="/nix/var/nix/gcroots/per-user/$USER"
|
|
|
|
local greatestGenNum
|
|
|
|
|
|
|
|
greatestGenNum=$( \
|
|
|
|
find "$profilesPath" -name 'home-manager-*-link' \
|
|
|
|
| sed 's/^.*-\([0-9]*\)-link$/\1/' \
|
|
|
|
| sort -rn \
|
|
|
|
| head -1)
|
|
|
|
|
|
|
|
if [[ -n "$greatestGenNum" ]] ; then
|
|
|
|
oldGenNum=$greatestGenNum
|
|
|
|
newGenNum=$((oldGenNum + 1))
|
|
|
|
else
|
|
|
|
newGenNum=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -e "$gcPath/current-home" ]] ; then
|
|
|
|
oldGenPath="$(readlink -e "$gcPath/current-home")"
|
|
|
|
fi
|
|
|
|
|
2017-02-05 22:00:04 +00:00
|
|
|
genProfilePath="$profilesPath/home-manager"
|
2017-01-16 19:26:42 +00:00
|
|
|
newGenPath="@GENERATION_DIR@";
|
|
|
|
newGenProfilePath="$profilesPath/home-manager-$newGenNum-link"
|
|
|
|
newGenGcPath="$gcPath/current-home"
|
|
|
|
}
|
|
|
|
|
|
|
|
setupVars
|
|
|
|
|
|
|
|
echo "Starting home manager activation"
|
|
|
|
|
2017-03-25 20:48:17 +00:00
|
|
|
if [[ -v VERBOSE ]]; then
|
2017-01-21 11:27:50 +00:00
|
|
|
export VERBOSE_ECHO=echo
|
|
|
|
export VERBOSE_ARG="--verbose"
|
|
|
|
else
|
|
|
|
export VERBOSE_ECHO=true
|
2017-03-25 20:48:17 +00:00
|
|
|
export VERBOSE_ARG=""
|
2017-01-21 11:27:50 +00:00
|
|
|
fi
|
|
|
|
|
2017-03-25 20:48:17 +00:00
|
|
|
if [[ -v DRY_RUN ]] ; then
|
2017-08-17 08:16:30 +00:00
|
|
|
echo "This is a dry run"
|
2017-01-21 11:27:50 +00:00
|
|
|
export DRY_RUN_CMD=echo
|
2017-01-16 19:26:42 +00:00
|
|
|
else
|
2017-01-21 11:27:50 +00:00
|
|
|
$VERBOSE_ECHO "This is a live run"
|
2017-03-25 20:48:17 +00:00
|
|
|
export DRY_RUN_CMD=""
|
2017-01-16 19:26:42 +00:00
|
|
|
fi
|
|
|
|
|
2017-01-21 11:27:50 +00:00
|
|
|
$VERBOSE_ECHO "Activation variables:"
|
2017-03-28 22:10:30 +00:00
|
|
|
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
|
2017-01-21 11:27:50 +00:00
|
|
|
$VERBOSE_ECHO " newGenPath=$newGenPath"
|
2017-03-28 22:10:30 +00:00
|
|
|
$VERBOSE_ECHO " newGenNum=$newGenNum"
|
2017-01-21 11:27:50 +00:00
|
|
|
$VERBOSE_ECHO " newGenProfilePath=$newGenProfilePath"
|
|
|
|
$VERBOSE_ECHO " newGenGcPath=$newGenGcPath"
|
2017-02-05 22:00:04 +00:00
|
|
|
$VERBOSE_ECHO " genProfilePath=$genProfilePath"
|