about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorWill Fancher <elvishjerricco@gmail.com>2023-03-06 22:21:48 -0500
committerWill Fancher <elvishjerricco@gmail.com>2023-04-17 16:41:36 -0400
commit85982346510230f7bfe1aeabfa2f9382c8192ad8 (patch)
treed89076b712804a71077e177441adcd3c0a6eabaa /nixos
parent834ec135ce71cdc93aba9e98cf67f42e41502f32 (diff)
systemd-initrd: dbus
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/system/dbus.nix21
-rw-r--r--nixos/modules/system/boot/networkd.nix3
2 files changed, 23 insertions, 1 deletions
diff --git a/nixos/modules/services/system/dbus.nix b/nixos/modules/services/system/dbus.nix
index c677088101f0c..9d8a62ec78c53 100644
--- a/nixos/modules/services/system/dbus.nix
+++ b/nixos/modules/services/system/dbus.nix
@@ -14,13 +14,17 @@ let
     serviceDirectories = cfg.packages;
   };
 
-  inherit (lib) mkOption mkIf mkMerge types;
+  inherit (lib) mkOption mkEnableOption mkIf mkMerge types;
 
 in
 
 {
   options = {
 
+    boot.initrd.systemd.dbus = {
+      enable = mkEnableOption (lib.mdDoc "dbus in stage 1") // { visible = false; };
+    };
+
     services.dbus = {
 
       enable = mkOption {
@@ -111,6 +115,21 @@ in
       ];
     }
 
+    (mkIf config.boot.initrd.systemd.dbus.enable {
+      boot.initrd.systemd = {
+        users.messagebus = { };
+        groups.messagebus = { };
+        contents."/etc/dbus-1".source = pkgs.makeDBusConf {
+          inherit (cfg) apparmor;
+          suidHelper = "/bin/false";
+          serviceDirectories = [ pkgs.dbus ];
+        };
+        packages = [ pkgs.dbus ];
+        storePaths = [ "${pkgs.dbus}/bin/dbus-daemon" ];
+        targets.sockets.wants = [ "dbus.socket" ];
+      };
+    })
+
     (mkIf (cfg.implementation == "dbus") {
       environment.systemPackages = [
         pkgs.dbus
diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix
index e325a33a9e377..d2a8a28c4e695 100644
--- a/nixos/modules/system/boot/networkd.nix
+++ b/nixos/modules/system/boot/networkd.nix
@@ -3155,6 +3155,9 @@ let
 
       systemd.package = pkgs.systemdStage1Network;
 
+      # For networkctl
+      systemd.dbus.enable = mkDefault true;
+
       systemd.additionalUpstreamUnits = [
         "systemd-networkd-wait-online.service"
         "systemd-networkd.service"