Depreciate the use of nix-env to install packages?

home-manager is the cross-distro alternative.

That said, yes installation via nix-env (and nix profile) cannot be removed from nix itself, because this is their use case. home-manager is not an official tool, and doesn’t really cover the same use case.

Lots of third party tools (such as the aforementiomed home-manager) also use them to actually do their jobs.

With that said, I’ve commented on one of those articles asking very much the same question - can we stop recommending this workflow? It’s harmful for the new user experience. At the very least, it should be “only use this when you’re using nix on MacOS” or something.

This is not the only problem. Unless you explicitly update using nix-env --upgrade, packages installed through it will never update. People will happily update their channels thinking it’s a full system update and end up unable to log in because their window manager is 4 NixOS releases behind.

This is a slow and insidious failure mode, because by the time it breaks you will have forgotten about it. Worse, in the mean time this leaves you up to all kinds of security issues (for worst cases, think e.g. about installing firefox via nix-env).

Using either nix-env or nixos-rebuild or home-manager isn’t per-se an issue. The problem is mixing all of these, and not understanding the implications, as new users reading those wiki entries will do.

A very large percentage of NixOS update failures come from mixing these, and this is why I will always tell new users to forget the nix-env command exists - more nuance than that is confusing and using it in a more nuanced fashion is clearly poor practice anyway.

This is better than having swathes of users get annoyed and give up after their first major version upgrade, thinking the basic promise of NixOS was a lie. It’s not, but mixing imperative and declarative practices leaves you vulnerable to mistakes that could be avoided entirely if you picked one approach - it’s a shame we recommend both in the same wiki section.

9 Likes