But what *is* a {system, user} package?

I am no Linux expert, but the basic premise seems simple and explained elsewhere:

  • A system package is installed sytem-wide, in particular they affect all users and environment variables.
  • A user package can be configured on a per-user basis (and available/ exposed to only a specific user?) and so on.

What I still do not understand is:

What should be considered a system or user package?

I am the only one using my laptop, but I have to wonder if there is still a distinction.

In any case, I hope changing stuff will be as easy as yanking some package names in my NixOS config, but I still would like to know the difference. For example, would it be fair to say the following?

“A user package is whatever I would be okay with using Flatpak for.”

In that case, I would guess that Emacs, fish, typst, latex, languages and their tooling (Rust, Python, …) would be better suited as system packages, whereas GUI apps can be thought as user packages.

  • But where does that leave a GUI based on a daemon, say Syncthing or KDE-Connect?
  • Is it okay to have a package both on a system and a user level? Which options/ configurations take precedence?
  • Is it okay to just use system packages for everything, since I am the only person on this computer?
  • What is the analogue for the distinction between user and system packages in traditional package managers or distributions?

Flatpak packages can be installed by a user without root, NixOS needs root privileges to change user.users.<name>.packages.

In addition Flatpak performs sandboxing, part of why most Flatpak packages are GUI applications. NixOS doesn’t sandbox programs and packages function just as well when in environment.systemPackages as they do in users.users.<name>.packages.

Given both of these differences, whether package suitable for flatpak isn’t a good way to determine whether to put it in users.users.<name>.packages.

That’s typically handled by a module for that daemon which adds the package to environment.systemPackages.

Yes and users.users.<user>.packages takes precedence as /etc/profiles/per-user/<user>/bin is listed before /run/current-system/sw/bin in the PATH environment variable.

Yes.

Most package managers don’t have rootful per-user packages.

The distinction I use is, if I want root and myuser to have access, then it should be a system package; if it should only be accessible to myuser then it should be a user package. For example, I have no reason to give root access to random compilers, so I would never put them in the system package list.

Note that this is not real security, since any user can access the nix store and execute whatever they want; it’s just to keep my PATH relatively clean.

There are some exceptions due to environment.pathsToLink, but this mostly works for my mental model.

Or, in other words, distinguishing between user and system packages only makes tab completion as root a bit faster sometimes. Install everything system-wide if you like, there’s no practical difference.

Well, yes, caveat other pathsToLink, but that just means there are some packages that must be installed system-wide and it’s not obvious which if you don’t know their contents intricately.

Forget the flatpak quote, it makes no sense without also defining why you are “comfortable” installing certain things as flatpaks and not others - flatpaks can also be installed system-wide or per-user, by the way, and technically a flatpak-based compiler is completely feasible and fine to use.

I personally ended up just installing as much as possible for my user instead of the system, mainly for portability reasons. Makes it easy to install most of your packages when you’re on a foreign distro as well. I usually only install packages system-wide if it is really necessary for them to be installed system-wide to function properly, or if it doesn’t make sense to even install them on a foreign distro since they would need more privileges anyway (or maybe they have to install udev rules or things like that, technically you could do that manually as well and then still install the package on the user level, but i feel like you may as well just install it natively on the host system at that point).

Or you could use system-manager on the foreign distro to install them!

My main laptop runs on Pop!_OS+system-manager+home-manager because I gradually transitioned onto Nix and didn’t want to reinstall on my 1 machine with all my files.

KISS - Keep It Simple S…

Think like mac os - gui apps are for all users on the system. Done.

Users - customize how they want GUI apps arranged - eg on your dock. - so export the dconf database will save that per user setup I have a tool nix-my-gnome which does that for you then use home-manager per user. Done.

Terminal apps are a mix of both depending on what is needed for all users vs a specific user but that comes down to need and experience.

to keep it simple for you the solo user let home-manager manage all your user settings and system-level packages/nix-flatpak for GUI apps (optional choice) deal with the system wide stuff

Although I don’t have much experience with NixOS, I strictly distinguish between system level and user level. And my principle is to put everything at the user level if possible (of course, the actual operation is not to add packages under users in the NixOS configuration, but to use home-manager). It includes all the mentioned stuffs (emacs, fish, typst, latex, and etc.); these in fact all “should” be at the user level, because they do not require any privileges.

Second, if something can only be done with the corresponding privileges, then I will consider starting a daemon at the system level and releasing the specialized capability to users. A typical manifestation of this is my NixDaemonProxy. It exposes an interface at the system level for adjusting the network proxy used by nix-daemon, and users in a specific group can switch the proxy to a specified SOCKS5 proxy or something else. This allows me to put more at user level: The system only provides the ability to switch the proxy, and how the specific proxy service is started and configured is left to the user to decide.

This also makes it so that almost all of my operations can be completed by the user. Apart from nixos-rebuild switch, I almost never use sudo. So for me, at least “providing certain tool to root” is not a very good reason, because I simply do not operate as root.

In fact, this is also one of the reasons I chose NixOS. On many distributions, installing a package that requires no privileges at all may still require privilege escalation (e.g. sudo apt install, although you can install it from source or unpack it yourself). I think… that is too dirty. (However, one of the bad thing about Nix is ​​its dependency on /nix. It makes Nix hard to use on other distributions if the administrator does not pre-install it. But there’s nothing we can do about it.)

As for what must be configured at the system level, it is those things that truly require privileges, including disks, networking, bootloader, kernel parameters, and etc. Rather than saying I choose to configure it at the system level, I would say I have to do that.