diff options
Diffstat (limited to 'src/nix/upgrade-nix.cc')
-rw-r--r-- | src/nix/upgrade-nix.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/nix/upgrade-nix.cc b/src/nix/upgrade-nix.cc index 3417adb62c9f..72b298283a60 100644 --- a/src/nix/upgrade-nix.cc +++ b/src/nix/upgrade-nix.cc @@ -103,11 +103,18 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand if (hasPrefix(where, "/run/current-system")) throw Error("Nix on NixOS must be upgraded via 'nixos-rebuild'"); - Path profileDir; - Path userEnv; + Path profileDir = dirOf(where); + + // Resolve profile to /nix/var/nix/profiles/<name> link. + while (baseNameOf(dirOf(canonPath(profileDir))) != "profiles") + profileDir = readLink(profileDir); + + printInfo("found profile '%s'", profileDir); + + Path userEnv = canonPath(profileDir, true); if (baseNameOf(where) != "bin" || - !hasSuffix(userEnv = canonPath(profileDir = dirOf(where), true), "user-environment")) + !hasSuffix(userEnv, "user-environment")) throw Error("directory '%s' does not appear to be part of a Nix profile", where); if (!store->isValidPath(userEnv)) |