`nix-env -u` replaces `firefox` with `firefox-beta`

I’m on Debian 12, using the multi-user installation of Nix installed via the shell script from Download Nix / NixOS | Nix & NixOS.

I installed Firefox this morning via nix-env -iA nixpkgs.firefox. This evening, I ran nix-env -u to upgrade my packages, which displayed upgrading 'firefox-123.0' to 'firefox-123.0b9' and resulted in the firefox executable being replaced by firefox-beta.

How do I keep firefox at the latest stable version and prevent it from being upgraded to beta? Is this possible with nix-env, or should I be using a different method for installing packages?

You’d use a different way to install things.

nix-env is not aware of attribute paths, only names and versions, and if something with the same name has some version that it considers “newer” nix-env will update.

nix profile is smarter in that regard from what I have heard, but it has other flaws.

The favoured way would be to use some of the declarative means of package management.

One would be HM, the other is described in the nix or nixpkgs manual.

I will try to provide some links when I am at home.


This site covers the topic in detail: https://stop-using-nix-env.privatevoid.net/


The link that @TLATER provides was one of the links I wanted to provide as well.

The other link is towards a section in the nixpkgs manual that covers “declarative package management”. I am aware that it exists as I followed that approach for some experiments years ago.

I have no clue if this is still state of the art, or if there would be a “better” way using overlays today, as packageOverrides are known to be not composable.

This link also does not cover pinning the nixpkgs channel or any other input, which might or might not be something to consider for your usecase.

1 Like

Kind of a note to self rather than anything else, but it might be worth writing something up about the current state of the art one day, and contributing it to the anti-nix-env page, this is a very common question.

You can do some fun things with nix profile, too.