From 6794efdf68941a114b79d11d92e43c34b756cc60 Mon Sep 17 00:00:00 2001
From: Robert Helgesson <robert@rycee.net>
Date: Sun, 5 Feb 2017 23:00:04 +0100
Subject: [PATCH] home-environment: add link for current profile

This link is needed to make the `delete-older-than` option for
`nix-collect-garbage` work as expected.
---
 modules/activation-init.sh   | 2 ++
 modules/home-environment.nix | 1 +
 2 files changed, 3 insertions(+)

diff --git a/modules/activation-init.sh b/modules/activation-init.sh
index 51c359686..d92dccb8c 100755
--- a/modules/activation-init.sh
+++ b/modules/activation-init.sh
@@ -20,6 +20,7 @@ function setupVars() {
         oldGenPath="$(readlink -e "$gcPath/current-home")"
     fi
 
+    genProfilePath="$profilesPath/home-manager"
     newGenPath="@GENERATION_DIR@";
     newGenProfilePath="$profilesPath/home-manager-$newGenNum-link"
     newGenGcPath="$gcPath/current-home"
@@ -52,3 +53,4 @@ $VERBOSE_ECHO "  oldGenPath=$oldGenPath"
 $VERBOSE_ECHO "  newGenPath=$newGenPath"
 $VERBOSE_ECHO "  newGenProfilePath=$newGenProfilePath"
 $VERBOSE_ECHO "  newGenGcPath=$newGenGcPath"
+$VERBOSE_ECHO "  genProfilePath=$genProfilePath"
diff --git a/modules/home-environment.nix b/modules/home-environment.nix
index 5a4fb4cfc..e3d9f23bf 100644
--- a/modules/home-environment.nix
+++ b/modules/home-environment.nix
@@ -276,6 +276,7 @@ in
 
           if [[ "$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"
             linkNewGen
             cleanOldGen