diff options
author | Qyriad <qyriad@qyriad.me> | 2024-05-25 02:20:24 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@lix-systems> | 2024-05-25 02:20:24 +0000 |
commit | 5b4b216facfb8af2f08c25a4b50fba1e197ca06e (patch) | |
tree | c852bb0cb159214caba2954e55bee2e5964d40ce /src | |
parent | 1c0f3c540ed222cc7ab460785f07837091642b1e (diff) | |
parent | f3f68fcfac50ff6ee73152e32848a4a6f2acd021 (diff) |
Merge "nix3-upgrade-nix: fix when there are differing pnames" into main
Diffstat (limited to 'src')
-rw-r--r-- | src/nix/upgrade-nix.cc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/nix/upgrade-nix.cc b/src/nix/upgrade-nix.cc index 55f833833..3e47fc8f0 100644 --- a/src/nix/upgrade-nix.cc +++ b/src/nix/upgrade-nix.cc @@ -111,7 +111,23 @@ struct CmdUpgradeNix : MixDryRun, EvalCommand if (pathExists(canonProfileDir + "/manifest.nix")) { - std::string nixEnvCmd = settings.nixBinDir + "/nix-env"; + // {settings.nixBinDir}/nix-env is a symlink to a {settings.nixBinDir}/nix, which *then* + // is a symlink to /nix/store/meow-nix/bin/nix. We want /nix/store/meow-nix/bin/nix-env. + Path const nixInStore = canonPath(settings.nixBinDir + "/nix-env", true); + Path const nixEnvCmd = dirOf(nixInStore) + "/nix-env"; + + // First remove the existing Nix, then use that Nix by absolute path to + // install the new one, in case the new and old versions aren't considered + // to be "the same package" by nix-env's logic (e.g., if their pnames differ). + Strings removeArgs = { + "--uninstall", + nixEnvCmd, + "--profile", + this->profileDir, + }; + printTalkative("running %s %s", nixEnvCmd, concatStringsSep(" ", removeArgs)); + runProgram(nixEnvCmd, false, removeArgs); + Strings upgradeArgs = { "--profile", this->profileDir, |