NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.1k stars 14.15k forks source link

System service packages should not depend on `systemd` on non-NixOS Linux platforms #330821

Closed dpk closed 3 months ago

dpk commented 3 months ago

When installing packages which are usually long-running system services on Linux (I have tried postgres_16, mariadb, apacheHttpd, redict, postfix), very often they bring along systemd or systemd-minimal as dependencies or transitive dependencies. I assume nobody notices this on NixOS because it’s already part of the base system managed by NixOS and thus already installed.

On non-NixOS Linux platforms this is annoying for one or maybe two reasons:

  1. on systems that already manage services using their own version of systemd, I almost certainly want to the OS-managed systemd to run these services, not the version in Nix, otherwise I have two separate systemd processes for no reason. (I have no idea if that even works!)
  2. on systems such as Void (currently my preferred Linux distribution) which eschew systemd for more lightweight solutions making it more practical to use them in containers etc., I don’t want systemd at all. That’s the whole reason I picked this type of OS.

The mentioned packages do not intrinsically depend on systemd to work; on Darwin they obviously have no systemd dependency. There may be some other reason they depend on systemd on Linux, but this seems very doubtful to me personally, considering they install fine through xbps on Void which doesn’t have systemd.

This is not consistent across all ‘service’ type packages. Packages which can be long-running services but don’t drag in systemd or systemd-minimal on Linux include lighttpd, caddy, cockroachdb-bin, opensearch, … (this is not a scientific survey, I just tried some packages I thought of).

eclairevoyant commented 3 months ago
  1. I almost certainly want to the OS-managed systemd to run these services, not the version in Nix

A systemd service simply existing in a package will do absolutely nothing.

2. on systems such as Void (currently my preferred Linux distribution) which eschew systemd for more lightweight solutions making it more practical to use them in containers etc., I don’t want systemd at all.

Similarly, systemd existing in the nix store as a dependency will not change your init system.

YoshiRulz commented 3 months ago

See also #98094/#99240.

In my experience, adding systemd is often necessary to get libudev. (Indeed udev is an alias for systemdMinimal.)

SuperSandro2000 commented 3 months ago

on systems that already manage services using their own version of systemd

This assumption is wrong. Please familiarize yourself how systemd works and loads units. The packages most likely draws in a shared object like libudev (see comment above) or sd_notify functionality. Some packages have flags to compile the package without that library (or systemd at all) but the functionality is then missing and we cannot compile against the host library as that would be impure. Generally not every package will have such an option because our first priority is to compile packages for NixOS and only then for other OSs. Feel free to create PRs for more options to disable systemd as a dependency if that is something supported by upstream but providing this is not a top priority and those packages are currently not cached.