about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorWill Fancher <elvishjerricco@gmail.com>2024-01-25 14:23:56 -0500
committerWill Fancher <elvishjerricco@gmail.com>2024-01-25 15:53:52 -0500
commit0d85bf0efed41a37feb2f61a702a15a83427f348 (patch)
tree6d734e830edd3ef566f2fb5d76528beb06a67716 /nixos
parente041a4bbea28101582ba3429d02b5e6febcf4bfc (diff)
downloadnixlib-0d85bf0efed41a37feb2f61a702a15a83427f348.tar
nixlib-0d85bf0efed41a37feb2f61a702a15a83427f348.tar.gz
nixlib-0d85bf0efed41a37feb2f61a702a15a83427f348.tar.bz2
nixlib-0d85bf0efed41a37feb2f61a702a15a83427f348.tar.lz
nixlib-0d85bf0efed41a37feb2f61a702a15a83427f348.tar.xz
nixlib-0d85bf0efed41a37feb2f61a702a15a83427f348.tar.zst
nixlib-0d85bf0efed41a37feb2f61a702a15a83427f348.zip
nixos/systemd: Temporarily bring back multi-user -> network-online
There were several modules, critically including NetworkManager, which
were not prepared for this change. Most of the change was good,
however. Let's bring back the dependency and change the assertion to a
warning for now.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/doc/manual/release-notes/rl-2405.section.md10
-rw-r--r--nixos/modules/system/boot/systemd.nix64
2 files changed, 35 insertions, 39 deletions
diff --git a/nixos/doc/manual/release-notes/rl-2405.section.md b/nixos/doc/manual/release-notes/rl-2405.section.md
index d5fafcf44706..f85d9c7f17e6 100644
--- a/nixos/doc/manual/release-notes/rl-2405.section.md
+++ b/nixos/doc/manual/release-notes/rl-2405.section.md
@@ -138,12 +138,10 @@ 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`).
+- A warning has been added for services that are
+  `after = [ "network-online.target" ]` but do not depend on it (e.g. using
+  `wants`), because the dependency that `multi-user.target` has on
+  `network-online.target` is planned for removal.
 
 - `services.archisteamfarm` no longer uses the abbreviation `asf` for its state directory (`/var/lib/asf`), user and group (both `asf`). Instead the long name `archisteamfarm` is used.
   Configurations with `system.stateVersion` 23.11 or earlier, default to the old stateDirectory until the 24.11 release and must either set the option explicitly or move the data to the new directory.
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index 331ca5103ba6..e29fa49ea23b 100644
--- a/nixos/modules/system/boot/systemd.nix
+++ b/nixos/modules/system/boot/systemd.nix
@@ -428,7 +428,13 @@ in
 
   config = {
 
-    warnings = concatLists (
+    warnings = let
+      mkOneNetOnlineWarn = typeStr: name: def: lib.optional
+        (lib.elem "network-online.target" def.after && !(lib.elem "network-online.target" (def.wants ++ def.requires ++ def.bindsTo)))
+        "${name}.${typeStr} is ordered after 'network-online.target' but doesn't depend on it";
+      mkNetOnlineWarns = typeStr: defs: lib.concatLists (lib.mapAttrsToList (mkOneNetOnlineWarn typeStr) defs);
+      mkMountNetOnlineWarns = typeStr: defs: lib.concatLists (map (m: mkOneNetOnlineWarn typeStr m.what m) defs);
+    in concatLists (
       mapAttrsToList
         (name: service:
           let
@@ -449,40 +455,31 @@ in
             ]
         )
         cfg.services
+    )
+    ++ (mkNetOnlineWarns "target" cfg.targets)
+    ++ (mkNetOnlineWarns "service" cfg.services)
+    ++ (mkNetOnlineWarns "socket" cfg.sockets)
+    ++ (mkNetOnlineWarns "timer" cfg.timers)
+    ++ (mkNetOnlineWarns "path" cfg.paths)
+    ++ (mkMountNetOnlineWarns "mount" cfg.mounts)
+    ++ (mkMountNetOnlineWarns "automount" cfg.automounts)
+    ++ (mkNetOnlineWarns "slice" cfg.slices);
+
+    assertions = concatLists (
+      mapAttrsToList
+        (name: service:
+          map (message: {
+            assertion = false;
+            inherit message;
+          }) (concatLists [
+            (optional ((builtins.elem "network-interfaces.target" service.after) || (builtins.elem "network-interfaces.target" service.wants))
+              "Service '${name}.service' is using the deprecated target network-interfaces.target, which no longer exists. Using network.target is recommended instead."
+            )
+          ])
+        )
+        cfg.services
     );
 
-    assertions = let
-      mkOneAssert = typeStr: name: def: {
-        assertion = lib.elem "network-online.target" def.after -> lib.elem "network-online.target" (def.wants ++ def.requires ++ def.bindsTo);
-        message = "${name}.${typeStr} is ordered after 'network-online.target' but doesn't depend on it";
-      };
-      mkAsserts = typeStr: lib.mapAttrsToList (mkOneAssert typeStr);
-      mkMountAsserts = typeStr: map (m: mkOneAssert typeStr m.what m);
-    in mkMerge [
-      (concatLists (
-        mapAttrsToList
-          (name: service:
-            map (message: {
-              assertion = false;
-              inherit message;
-            }) (concatLists [
-              (optional ((builtins.elem "network-interfaces.target" service.after) || (builtins.elem "network-interfaces.target" service.wants))
-                "Service '${name}.service' is using the deprecated target network-interfaces.target, which no longer exists. Using network.target is recommended instead."
-              )
-            ])
-          )
-          cfg.services
-      ))
-      (mkAsserts "target" cfg.targets)
-      (mkAsserts "service" cfg.services)
-      (mkAsserts "socket" cfg.sockets)
-      (mkAsserts "timer" cfg.timers)
-      (mkAsserts "path" cfg.paths)
-      (mkMountAsserts "mount" cfg.mounts)
-      (mkMountAsserts "automount" cfg.automounts)
-      (mkAsserts "slice" cfg.slices)
-    ];
-
     system.build.units = cfg.units;
 
     system.nssModules = [ cfg.package.out ];
@@ -658,6 +655,7 @@ in
     systemd.services.systemd-udev-settle.restartIfChanged = false; # Causes long delays in nixos-rebuild
     systemd.targets.local-fs.unitConfig.X-StopOnReconfiguration = true;
     systemd.targets.remote-fs.unitConfig.X-StopOnReconfiguration = true;
+    systemd.targets.network-online.wantedBy = [ "multi-user.target" ];
     systemd.services.systemd-importd.environment = proxy_env;
     systemd.services.systemd-pstore.wantedBy = [ "sysinit.target" ]; # see #81138