1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-12 21:46:01 +01:00

Properly migrate the existing profiles

Make sure that the default profile (including all its generations) are
still available after we move it to the user’s home directory
This commit is contained in:
Théophane Hufschmitt 2022-04-11 10:20:36 +02:00
parent be28cb9262
commit a2bcf35e0d

View file

@ -305,11 +305,16 @@ Path getDefaultProfile()
if (!pathExists(profileLink)
|| (isLink(profileLink)
&& readLink(profileLink) == legacyProfile)) {
warn("Migrating the default profile");
replaceSymlink(newProfile, profileLink);
replaceSymlink(legacyProfile, newProfile);
if (pathExists(legacyProfile)) {
for (auto & oldGen : findGenerations(legacyProfile).first) {
replaceSymlink(
oldGen.path,
newProfile + "/" + std::string(baseNameOf(oldGen.path)));
dirOf(newProfile) + "/"
+ std::string(baseNameOf(oldGen.path)));
}
}
}
return absPath(readLink(profileLink), dirOf(profileLink));