Skip to content

Commit

Permalink
Merge pull request NixOS#258680 from lf-/jade/remove-multiuser-netonl…
Browse files Browse the repository at this point in the history
…ine-dep

nixos/systemd: don't require network-online.target for multi-user.target
  • Loading branch information
mweinelt authored Jan 19, 2024
2 parents a237397 + 1323e31 commit c2853e2
Show file tree
Hide file tree
Showing 102 changed files with 167 additions and 32 deletions.
7 changes: 7 additions & 0 deletions nixos/doc/manual/release-notes/rl-2405.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m
- `services.avahi.nssmdns` got split into `services.avahi.nssmdns4` and `services.avahi.nssmdns6` which enable the mDNS NSS switch for IPv4 and IPv6 respectively.
Since most mDNS responders only register IPv4 addresses, most users want to keep the IPv6 support disabled to avoid long timeouts.

- `multi-user.target` no longer depends on `network-online.target`.
This will potentially break services that assumed this was the case in the past.
This was changed for consistency with other distributions as well as improved boot times.

We have added a warning for services that are
`after = [ "network-online.target" ]` but do not depend on it (e.g. using `wants`).

- `networking.iproute2.enable` now does not set `environment.etc."iproute2/rt_tables".text`.

Setting `environment.etc."iproute2/{CONFIG_FILE_NAME}".text` will override the whole configuration file instead of appending it to the upstream configuration file.
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/audio/gmediarender.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ in
config = mkIf cfg.enable {
systemd = {
services.gmediarender = {
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
description = "gmediarender server daemon";
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/audio/jmusicbot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ in
config = mkIf cfg.enable {
systemd.services.jmusicbot = {
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
description = "Discord music bot that's easy to set up and run yourself!";
serviceConfig = mkMerge [{
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/audio/spotifyd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ in

systemd.services.spotifyd = {
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" "sound.target" ];
description = "spotifyd, a Spotify playing daemon";
environment.SHELL = "/bin/sh";
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/audio/ympd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ in {
description = "Standalone MPD Web GUI written in C";

wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];

serviceConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ in {
systemd.services.buildbot-master = {
description = "Buildbot Continuous Integration Server.";
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
path = cfg.packages ++ cfg.pythonPackages python.pkgs;
environment.PYTHONPATH = "${python.withPackages (self: cfg.pythonPackages self ++ [ package ])}/${python.sitePackages}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ in
nameValuePair "gitea-runner-${escapeSystemdPath name}" {
inherit (instance) enable;
description = "Gitea Actions Runner";
wants = [ "network-online.target" ];
after = [
"network-online.target"
] ++ optionals (wantsDocker) [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ in
systemd.services.hydra-evaluator =
{ wantedBy = [ "multi-user.target" ];
requires = [ "hydra-init.service" ];
wants = [ "network-online.target" ];
after = [ "hydra-init.service" "network.target" "network-online.target" ];
path = with pkgs; [ hydra-package nettools jq ];
restartTriggers = [ hydraConf ];
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/databases/lldap.nix
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ in
config = lib.mkIf cfg.enable {
systemd.services.lldap = {
description = "Lightweight LDAP server (lldap)";
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/databases/openldap.nix
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ in {
"man:slapd-mdb"
];
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
serviceConfig = {
User = cfg.user;
Expand Down
2 changes: 2 additions & 0 deletions nixos/modules/services/desktops/geoclue2.nix
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ in
};

systemd.services.geoclue = {
wants = lib.optionals cfg.enableWifi [ "network-online.target" ];
after = lib.optionals cfg.enableWifi [ "network-online.target" ];
# restart geoclue service when the configuration changes
restartTriggers = [
Expand All @@ -217,6 +218,7 @@ in
# we can't be part of a system service, and the agent should
# be okay with the main service coming and going
wantedBy = [ "default.target" ];
wants = lib.optionals cfg.enableWifi [ "network-online.target" ];
after = lib.optionals cfg.enableWifi [ "network-online.target" ];
unitConfig.ConditionUser = "!@system";
serviceConfig = {
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/home-automation/evcc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ in

config = mkIf cfg.enable {
systemd.services.evcc = {
wants = [ "network-online.target" ];
after = [
"network-online.target"
"mosquitto.target"
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/home-automation/home-assistant.nix
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ in {

systemd.services.home-assistant = {
description = "Home Assistant";
wants = [ "network-online.target" ];
after = [
"network-online.target"

Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/logging/journaldriver.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ in {
systemd.services.journaldriver = {
description = "Stackdriver Logging journal forwarder";
script = "${pkgs.journaldriver}/bin/journaldriver";
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];

Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/mail/roundcube.nix
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ in
path = [ config.services.postgresql.package ];
})
{
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
script = let
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/mail/sympa.nix
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ in

wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" ];
wants = sympaSubServices;
wants = sympaSubServices ++ [ "network-online.target" ];
before = sympaSubServices;
serviceConfig = sympaServiceConfig "sympa_msg";

Expand Down
2 changes: 2 additions & 0 deletions nixos/modules/services/matrix/synapse.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ in {

systemd.targets.matrix-synapse = lib.mkIf hasWorkers {
description = "Synapse Matrix parent target";
wants = [ "network-online.target" ];
after = [ "network-online.target" ] ++ optional hasLocalPostgresDB "postgresql.service";
wantedBy = [ "multi-user.target" ];
};
Expand All @@ -1071,6 +1072,7 @@ in {
requires = optional hasLocalPostgresDB "postgresql.service";
}
else {
wants = [ "network-online.target" ];
after = [ "network-online.target" ] ++ optional hasLocalPostgresDB "postgresql.service";
requires = optional hasLocalPostgresDB "postgresql.service";
wantedBy = [ "multi-user.target" ];
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/misc/amazon-ssm-agent.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ in {
# See https://github.com/aws/amazon-ssm-agent/blob/mainline/packaging/linux/amazon-ssm-agent.service
systemd.services.amazon-ssm-agent = {
inherit (cfg.package.meta) description;
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];

Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/misc/bcg.nix
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ in
in {
description = "BigClown Gateway";
wantedBy = [ "multi-user.target" ];
wants = mkIf config.services.mosquitto.enable [ "mosquitto.service" ];
wants = [ "network-online.target" ] ++ lib.optional config.services.mosquitto.enable "mosquitto.service";
after = [ "network-online.target" ];
preStart = ''
umask 077
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/misc/domoticz.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ in {
systemd.services."domoticz" = {
description = pkgDesc;
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
serviceConfig = {
DynamicUser = true;
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/misc/etesync-dav.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ in

systemd.services.etesync-dav = {
description = "etesync-dav - A CalDAV and CardDAV adapter for EteSync";
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
path = [ pkgs.etesync-dav ];
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/misc/mediatomb.nix
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ in {
description = "${cfg.serverName} media Server";
# Gerbera might fail if the network interface is not available on startup
# https://github.com/gerbera/gerbera/issues/1324
wants = [ "network-online.target" ];
after = [ "network.target" "network-online.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig.ExecStart = "${binaryCommand} --port ${toString cfg.port} ${interfaceFlag} ${configFlag} --home ${cfg.dataDir}";
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/misc/metabase.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ in {
systemd.services.metabase = {
description = "Metabase server";
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
environment = {
MB_PLUGINS_DIR = "${dataDir}/plugins";
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/misc/paperless.nix
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ in
wantedBy = [ "paperless-scheduler.service" ];
before = [ "paperless-scheduler.service" ];
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
serviceConfig = defaultServiceConfig // {
User = cfg.user;
Type = "oneshot";
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/monitoring/mackerel-agent.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ in {
# upstream service file in https://git.io/JUt4Q
systemd.services.mackerel-agent = {
description = "mackerel.io agent";
wants = [ "network-online.target" ];
after = [ "network-online.target" "nss-lookup.target" ];
wantedBy = [ "multi-user.target" ];
environment = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ in {

systemd.services.alertmanager = {
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
preStart = ''
${lib.getBin pkgs.envsubst}/bin/envsubst -o "/tmp/alert-manager-substituted.yaml" \
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/monitoring/teamviewer.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ in
description = "TeamViewer remote control daemon";

wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" "network.target" "dbus.service" ];
requires = [ "dbus.service" ];
preStart = "mkdir -pv /var/lib/teamviewer /var/log/teamviewer";
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/monitoring/telegraf.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ in {
in {
description = "Telegraf Agent";
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
path = lib.optional (config.services.telegraf.extraConfig.inputs ? procstat) pkgs.procps;
serviceConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ in
systemd.services.afsd = {
description = "AFS client";
wantedBy = [ "multi-user.target" ];
wants = lib.optional (!cfg.startDisconnected) "network-online.target";
after = singleton (if cfg.startDisconnected then "network.target" else "network-online.target");
serviceConfig = { RemainAfterExit = true; };
restartIfChanged = false;
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/networking/bitcoind.nix
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ in
'';
in {
description = "Bitcoin daemon";
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/networking/dante.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ in

systemd.services.dante = {
description = "Dante SOCKS v4 and v5 compatible proxy server";
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];

Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/networking/ergo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ in {
systemd.services.ergo = {
description = "ergo server";
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
serviceConfig = {
User = cfg.user;
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/networking/expressvpn.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ with lib;
RestartSec = 5;
};
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network.target" "network-online.target" ];
};
};
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/networking/headscale.nix
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ in {

systemd.services.headscale = {
description = "headscale coordination server for Tailscale";
wants = [ "network-online.target" ];
after = ["network-online.target"];
wantedBy = ["multi-user.target"];
restartTriggers = [configFile];
Expand Down
3 changes: 2 additions & 1 deletion nixos/modules/services/networking/ircd-hybrid/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ in

systemd.services.ircd-hybrid = {
description = "IRCD Hybrid server";
after = [ "started networking" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
script = "${ircdService}/bin/control start";
};
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/networking/ivpn.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ with lib;
systemd.services.ivpn-service = {
description = "iVPN daemon";
wantedBy = [ "multi-user.target" ];
wants = [ "network.target" ];
wants = [ "network.target" "network-online.target" ];
after = [
"network-online.target"
"NetworkManager.service"
Expand Down
7 changes: 7 additions & 0 deletions nixos/modules/services/networking/kea.nix
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ in
"network-online.target"
"time-sync.target"
];
wants = [
"network-online.target"
];
wantedBy = [
"multi-user.target"
];
Expand Down Expand Up @@ -372,6 +375,9 @@ in
"network-online.target"
"time-sync.target"
];
wants = [
"network-online.target"
];
wantedBy = [
"multi-user.target"
];
Expand Down Expand Up @@ -413,6 +419,7 @@ in
"https://kea.readthedocs.io/en/kea-${package.version}/arm/ddns.html"
];

wants = [ "network-online.target" ];
after = [
"network-online.target"
"time-sync.target"
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/networking/mosquitto.nix
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ in
systemd.services.mosquitto = {
description = "Mosquitto MQTT Broker Daemon";
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
serviceConfig = {
Type = "notify";
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/networking/mullvad-vpn.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ with lib;
systemd.services.mullvad-daemon = {
description = "Mullvad VPN daemon";
wantedBy = [ "multi-user.target" ];
wants = [ "network.target" ];
wants = [ "network.target" "network-online.target" ];
after = [
"network-online.target"
"NetworkManager.service"
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/networking/nbd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ in
boot.kernelModules = [ "nbd" ];

systemd.services.nbd-server = {
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
before = [ "multi-user.target" ];
wantedBy = [ "multi-user.target" ];
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/networking/ocserv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ in
systemd.services.ocserv = {
description = "OpenConnect SSL VPN server";
documentation = [ "man:ocserv(8)" ];
wants = [ "network-online.target" ];
after = [ "dbus.service" "network-online.target" ];
wantedBy = [ "multi-user.target" ];

Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/networking/pleroma.nix
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ in {

systemd.services.pleroma = {
description = "Pleroma social network";
wants = [ "network-online.target" ];
after = [ "network-online.target" "postgresql.service" ];
wantedBy = [ "multi-user.target" ];
restartTriggers = [ config.environment.etc."/pleroma/config.exs".source ];
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/networking/rosenpass.nix
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ in
in
rec {
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
path = [ cfg.package pkgs.wireguard-tools ];

Expand Down
Loading

0 comments on commit c2853e2

Please sign in to comment.