I need a method which will work on linux distrubutions other than nixos (I’m currently on artix). Also, I plan on using the same method as root to manage global packages.
Which will work for my use case and what are the tradeoffs?
Only method I’m aware of is to use NixOS with configuration.nix, which will configure the system as a whole.
This looks like a user command, and I assume you probably had to run this per-user to get the updates. This would be similar to home-manager, in which you would do:
home-manager -f=/path/to/home.nix switch
to get a user to have all the same packages.
I would highly recommend not using nix-env to manage per-package installs. I’ve never used it to install a set of packages though.
Packages root installs are global on any multi-user installation, at least according to my understanding of the cheatsheet.
Packages root installs are system-wide. It does so through /etc/nixos/configuration.nix. If root installs packages the same way users do, through ~/.nixpkgs/config.nix, they are also global. Root’s default profile is the system-wide default profile.
I’m not on NixOS. If this weren’t true nix would be a bit less useful for me.
Anyway, I’m still in the dark. Which of these methods work for my use-case, and what are the tradeoffs?
My use case:
I’m not on NixOS
I plan on using the same method to manage global packages
1 and 5 are the same thing. I’m not sure home-manager can be used as root to affect all users (@rycee can probably confirm/correct!). Expression for a buildEnv-based declarative user environment. · GitHub, where I describe the buildEnv approach, also contains a short feature comparison between the two nix-env approaches and home-manager.
buildEnv writes manifest.nix to your .nix-profile, which does this:
throw ''
Your user environment is a buildEnv which is incompatible with
nix-envs built-in env builder. Edit your home expression and run
update-profile instead!
''
It’s designed to lock you into buildEnv’s way of package management, but it’s a bit too indiscriminate for my liking, as queries no longer work.
EDIT: nix search ... still works, though. I’ll stick with it for now.
The attrset overlay approach has worked well for me for a long time. And it’s convenient to be able to do once-off nix-env -iA commands, in particular if one of my current packages is temporarily broken and can’t update (and therefore I can’t rebuild my whole environment), but I need to install or update a separate one.