­why options for non-admin programs in Nixpkgs and not Home Manager?

Nix allows users to manage their own packages without root privileges. it’s my understanding that configuration.nix is only for system-wide options, and i should use Home Manager for the rest as much as possible.

why then are there so many options in Nixpkgs that seem like they should be in Home Manager?

  • why is services.desktopManager.gnome.enable a system-wide option? it seems to have no equivalent in Home Manager?
  • why is programs.sway.enable a system-wide option? is Home Manager’s wayland.windowManager.sway.enable a per-user equivalent? how do i choose between them?

i ax myself: does installing this require rebuilding the system? with GNOME or Sway, i feel like the answer is no. therefore i’m surprised that these are system-wide options.

Installing a Wayland session requires putting a file into /usr/share/wayland-sessions so the display manager can pick it up. Same for X11 and /usr/share/xsessions. Generally, use the NixOS module if there’s one available to do the system-wide setup, and use the HM modules for per-user configuration or things that can be installed purely per-user.

As for configuring GNOME with home-manager, you may want to look at this post, as well as HM’s programs.gnome-shell option:

GNOME actually does a fair bit of system-wide setup, especially to enable helpful system services like udisks2 by default:

Sway not so much, but it still needs to have an .desktop file in /usr/share/wayland-sessions.

i skimmed the gnome.nix module you linked, but got overwhelmed with the sheer amount of allegedly helpful additions, so i couldn’t immediately appreciate whether or not i really need any of them. so let me consider things one at a time, eg· starting with the display manager:

Installing a Wayland session requires putting a file into /usr/share/wayland-sessions so the display manager can pick it up.

personally, i wouldn’t want to install GNOME or Sway and have the display manager start offering it to every other user. it makes more sense to me that a user first logs in, and then chooses which DE/WM to run based on what they’ve installed for themself. does this mean that with my mental model i shouldn’t be using programs.sway.enable after all, and instead installing it with Home Manager? or am i missing something more essential here that makes GNOME or Sway a fundamentally system-wide package?

They are separate projects, so overlap is expected; you can use NixOS without needing to use Home Manager and achieve user specific configuration. There is for example, users.users.<name>.packages, which is in NixOS; quoting the documentation “The set of packages that should be made available to the user. This is in contrast to environment.systemPackages, which adds packages to all users.”. There are also alternative projects to Home Manager such as hjem.

There are cases where you would not want this to happen (user choice that is) and you want what you install to apply to all users. Consider if you were administering the configuration for a fleet of computers for non-technical persons in a business; it is much easy to provide support for a single display manager for every user; such as Plasma.

I agree that your mental model of having support for per-user sessions is cleaner, especially with Nix where per-user packages are a core feature! Unfortunately, that’s not the way that display managers work on Linux currently.

If you’re fine with starting sessions from the TTY, Sway can just be started as sway, GNOME requires a more complicated hack (not sure what the declarative Nix way to do this is) and is missing some features (like the default screen locker) unless started from GDM.