nixos/systemd-unit-options: document correct wantedBy default for user units (#199007)

Until this commit, the documentation suggested `multi-user.target`
as `wantedBy` for all services.
Since `multi-user.target` is not available for user services,
propose a different default for those in the documentation.

Co-authored-by: Naïm Favier <n@monade.li>
Co-authored-by: Florian Warzecha <liketechnik@disroot.org>
This commit is contained in:
Jörg Thalheim 2022-11-02 08:03:22 +01:00 committed by GitHub
parent 17847f2940
commit 951f81c0cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -68,10 +68,9 @@ in rec {
default = []; default = [];
type = types.listOf unitNameType; type = types.listOf unitNameType;
description = lib.mdDoc '' description = lib.mdDoc ''
Units that require (i.e. depend on and need to go down with) Units that require (i.e. depend on and need to go down with) this unit.
this unit. The discussion under `wantedBy` As discussed in the `wantedBy` option description this also creates
applies here as well: inverse `.requires` `.requires` symlinks automatically.
symlinks are established.
''; '';
}; };
@ -79,16 +78,17 @@ in rec {
default = []; default = [];
type = types.listOf unitNameType; type = types.listOf unitNameType;
description = lib.mdDoc '' description = lib.mdDoc ''
Units that want (i.e. depend on) this unit. The standard way Units that want (i.e. depend on) this unit. The default method for
to make a unit start by default at boot is to set this option starting a unit by default at boot time is to set this option to
to `[ "multi-user.target" ]`. That's despite '["multi-user.target"]' for system services. Likewise for user units
the fact that the systemd.unit(5) manpage says this option (`systemd.user.<name>.*`) set it to `["default.target"]` to make a unit
goes in the `[Install]` section that controls start by default when the user `<name>` logs on.
the behaviour of `systemctl enable`. Since
such a process is stateful and thus contrary to the design of This option creates a `.wants` symlink in the given target that exists
NixOS, setting this option instead causes the equivalent statelessly without the need for running `systemctl enable`.
inverse `.wants` symlink to be present, The in systemd.unit(5) manpage described `[Install]` section however is
establishing the same desired relationship in a stateless way. not supported because it is a stateful process that does not fit well
into the NixOS design.
''; '';
}; };