`nix-env --upgrade` installs wrong package
When upgrading a package installed with nix-env, the wrong package may be upgraded if the package name is ambiguous. I present two examples.
In this example, I install nixos.helm, an audio synthesizer, then I perform an upgrade and it is replaced with kubernetes helm chart tool, nixos.kubernetes-helm.
$ nox helm
Refreshing cache
1 helm-0.9.0 (nixos.helm)
A free, cross-platform, polyphonic synthesizer
<snipped>
4 helm-2.14.3 (nixos.kubernetes-helm)
A package manager for kubernetes
^C
$ nix-env -iA nixos.helm
installing 'helm-0.9.0'
<snipped>
$ nix-env -u
upgrading 'helm-0.9.0' to 'helm-2.14.3'
<snipped>
Another example, for which I won't paste all the text, is nixos.cura (version 4.21) which when upgraded gets replaced with nixos.cura_stable (version 15.04) which is actually a major *downgrade (edit: technically a different package entirely as with the previous example)
This is because nix-env -u uses the same heuristic as nix-env -i and matches the package name instead of the attribute name (which makes it slow because it has to evaluate all the packages to find the ones with the same name).
The best thing to do right now is to fix those nixpkgs packages so that the derivation name matches the attribute name.
To really fix this, the manifest.nix format needs to be extended to also include the attribute name.
@zimbatm is there a work-around you can suggest to allow me to reliably upgrade packages installed with nix-env -i?
One way to do it is to wrap all those programs into another derivations.
"my-programs.nix"
with import <nixpkgs> {};
buildEnv {
name = "my-programs";
paths = [
emacs
vim
# ...
];
For example put that file in a git repo that contains all your configs.
Then to update everything run: nix-env -f my-programs.nix -i. This will install a single package called "my-packages" that includes all the other derivation. When running nix-env -q, a new "my-programs" entry will appear.
Before installing, make sure to nix-env -e the derivations that you are about to install. For example if vim is in the "paths" list, nix-env -e vim, then install the "my-programs" package. Otherwise nix is going to complain that both there is a conflict because both the "vim" package and the "my-programs" packages have "bin/vim" in their outputs.
@zimbatm Thanks, that makes sense - I will do that until the real fix is in. Very much appreciated.
I have been having a similar problem with nixpkgs.chromium and nixpkgs.ungoogled-chromium I am trying to stay on ungoogled chromium, but auto updates are difficult.
Writing your own my-config.nix file, how do you update your packages?
I marked this as stale due to inactivity. → More info
I've had this problem with obsidian
Closing as stale. Re-open if needed.