nix icon indicating copy to clipboard operation
nix copied to clipboard

`nix-env --upgrade` installs wrong package

Open arizonahanson opened this issue 6 years ago • 9 comments

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)

arizonahanson avatar Dec 20 '19 16:12 arizonahanson

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.

zimbatm avatar Dec 21 '19 08:12 zimbatm

To really fix this, the manifest.nix format needs to be extended to also include the attribute name.

zimbatm avatar Dec 21 '19 08:12 zimbatm

@zimbatm is there a work-around you can suggest to allow me to reliably upgrade packages installed with nix-env -i?

arizonahanson avatar Dec 21 '19 16:12 arizonahanson

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 avatar Dec 23 '19 08:12 zimbatm

@zimbatm Thanks, that makes sense - I will do that until the real fix is in. Very much appreciated.

arizonahanson avatar Dec 23 '19 16:12 arizonahanson

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?

truesilver92 avatar May 27 '20 20:05 truesilver92

I marked this as stale due to inactivity. → More info

stale[bot] avatar Feb 13 '21 20:02 stale[bot]

I've had this problem with obsidian

pbsds avatar Apr 10 '22 19:04 pbsds

Closing as stale. Re-open if needed.

tomberek avatar Aug 13 '26 21:08 tomberek