summary refs log tree commit diff
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorKlemens Nanni <klemens@posteo.de>2022-05-10 19:01:48 +0200
committerKlemens Nanni <klemens@posteo.de>2022-05-16 16:52:25 +0200
commitcbcc746f8f521849687d225c4a3f85b2beb24168 (patch)
treed5f3fbf36716d76ebfbfd7841110795959f582b3 /nixos/modules/system
parent3e789af26cb39c8e25678616c184579532562058 (diff)
downloadnixpkgs-cbcc746f8f521849687d225c4a3f85b2beb24168.tar
nixpkgs-cbcc746f8f521849687d225c4a3f85b2beb24168.tar.gz
nixpkgs-cbcc746f8f521849687d225c4a3f85b2beb24168.tar.bz2
nixpkgs-cbcc746f8f521849687d225c4a3f85b2beb24168.tar.lz
nixpkgs-cbcc746f8f521849687d225c4a3f85b2beb24168.tar.xz
nixpkgs-cbcc746f8f521849687d225c4a3f85b2beb24168.tar.zst
nixpkgs-cbcc746f8f521849687d225c4a3f85b2beb24168.zip
nixos/systemd: Package only built component units
Account for all `with*` options causing their respective unit files to
not be built, just like the current code `withCryptsetup` already does.

This fixes build errors like the following:
```
missing /nix/store/5fafsfms64fn3ywv274ky7arhm9yq2if-systemd-250.4/example/systemd/system/systemd-importd.service
error: builder for '/nix/store/67rdli5q5akzwmqgf8q0a1yp76jgr0px-system-units.drv' failed with exit code 1
```

Found by using a customised systemd package as follows:
```
systemd.package = pkgs.systemd-small;

nixpkgs.config.packageOverrides = pkgs: {

  "systemd-small" = pkgs.systemd.override {
    withImportd = false;
    withMachined = false;
    ...
  };

};
```
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/boot/systemd.nix17
-rw-r--r--nixos/modules/system/boot/systemd/logind.nix3
2 files changed, 15 insertions, 5 deletions
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index 2c9ee9fc319..679c5210a6b 100644
--- a/nixos/modules/system/boot/systemd.nix
+++ b/nixos/modules/system/boot/systemd.nix
@@ -35,11 +35,11 @@ let
       "nss-lookup.target"
       "nss-user-lookup.target"
       "time-sync.target"
-    ] ++ (optionals cfg.package.withCryptsetup [
+    ] ++ optionals cfg.package.withCryptsetup [
       "cryptsetup.target"
       "cryptsetup-pre.target"
       "remote-cryptsetup.target"
-    ]) ++ [
+    ] ++ [
       "sigpwr.target"
       "timers.target"
       "paths.target"
@@ -133,20 +133,27 @@ let
 
       # Slices / containers.
       "slices.target"
+    ] ++ optionals cfg.package.withImportd [
+      "systemd-importd.service"
+    ] ++ optionals cfg.package.withMachined [
       "machine.slice"
       "machines.target"
-      "systemd-importd.service"
       "systemd-machined.service"
+    ] ++ [
       "systemd-nspawn@.service"
 
       # Misc.
       "systemd-sysctl.service"
+    ] ++ optionals cfg.package.withTimedated [
       "dbus-org.freedesktop.timedate1.service"
-      "dbus-org.freedesktop.locale1.service"
-      "dbus-org.freedesktop.hostname1.service"
       "systemd-timedated.service"
+    ] ++ optionals cfg.package.withLocaled [
+      "dbus-org.freedesktop.locale1.service"
       "systemd-localed.service"
+    ] ++ optionals cfg.package.withHostnamed [
+      "dbus-org.freedesktop.hostname1.service"
       "systemd-hostnamed.service"
+    ] ++ [
       "systemd-exit.service"
       "systemd-update-done.service"
     ] ++ cfg.additionalUpstreamSystemUnits;
diff --git a/nixos/modules/system/boot/systemd/logind.nix b/nixos/modules/system/boot/systemd/logind.nix
index c1e6cfe61d0..97ac588bce1 100644
--- a/nixos/modules/system/boot/systemd/logind.nix
+++ b/nixos/modules/system/boot/systemd/logind.nix
@@ -81,8 +81,11 @@ in
       "systemd-logind.service"
       "autovt@.service"
       "systemd-user-sessions.service"
+    ] ++ optionals config.systemd.package.withImportd [
       "dbus-org.freedesktop.import1.service"
+    ] ++ optionals config.systemd.package.withMachined [
       "dbus-org.freedesktop.machine1.service"
+    ] ++ [
       "dbus-org.freedesktop.login1.service"
       "user@.service"
       "user-runtime-dir@.service"