mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
files: fix order of activation actions
Specifically, move the cleanup phase to before we switch over the generation links in `gcroots` and `profiles`. Fixes https://github.com/rycee/home-manager/issues/134
This commit is contained in:
parent
130e33a4e7
commit
9206f363ff
1 changed files with 23 additions and 1 deletions
|
@ -99,6 +99,27 @@ in
|
|||
''
|
||||
);
|
||||
|
||||
# This activation script will
|
||||
#
|
||||
# 1. Remove files from the old generation that are not in the new
|
||||
# generation.
|
||||
#
|
||||
# 2. Switch over the Home Manager gcroot and current profile
|
||||
# links.
|
||||
#
|
||||
# 3. Symlink files from the new generation into $HOME.
|
||||
#
|
||||
# This order is needed to ensure that we always know which links
|
||||
# belong to which generation. Specifically, if we're moving from
|
||||
# generation A to generation B having sets of home file links FA
|
||||
# and FB, respectively then cleaning before linking produces state
|
||||
# transitions similar to
|
||||
#
|
||||
# FA → FA ∩ FB → (FA ∩ FB) ∪ FB = FB
|
||||
#
|
||||
# and a failure during the intermediate state FA ∩ FB will not
|
||||
# result in lost links because this set of links are in both the
|
||||
# source and target generation.
|
||||
home.activation.linkGeneration = dagEntryAfter ["writeBoundary"] (
|
||||
let
|
||||
link = pkgs.writeText "link" ''
|
||||
|
@ -171,6 +192,8 @@ in
|
|||
| xargs -0 bash ${cleanup} "$newGenFiles"
|
||||
}
|
||||
|
||||
cleanOldGen
|
||||
|
||||
if [[ ! -v oldGenPath || "$oldGenPath" != "$newGenPath" ]] ; then
|
||||
echo "Creating profile generation $newGenNum"
|
||||
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenProfilePath"
|
||||
|
@ -181,7 +204,6 @@ in
|
|||
fi
|
||||
|
||||
linkNewGen
|
||||
cleanOldGen
|
||||
''
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue