From dbe90a1643ca888fe2e0ce0d9e6f73b55515c82e Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Mon, 6 Mar 2023 22:21:48 -0500 Subject: [PATCH] systemd-initrd: dbus --- nixos/modules/services/system/dbus.nix | 21 ++++++++++++++++++++- nixos/modules/system/boot/networkd.nix | 3 +++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/system/dbus.nix b/nixos/modules/services/system/dbus.nix index c677088101f0c32..9d8a62ec78c5390 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 61c32cac586df97..9162df70990dd56 100644 --- a/nixos/modules/system/boot/networkd.nix +++ b/nixos/modules/system/boot/networkd.nix @@ -3149,6 +3149,9 @@ let systemd.package = pkgs.systemdStage1Network; + # For networkctl + systemd.dbus.enable = mkDefault true; + systemd.additionalUpstreamUnits = [ "systemd-networkd-wait-online.service" "systemd-networkd.service"