Skip to content

Commit cfc0d6b

Browse files
nixos/dbus: add package options
1 parent 172f25b commit cfc0d6b

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

nixos/modules/services/system/dbus.nix

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ let
88

99
configDir = pkgs.makeDBusConf.override {
1010
inherit (cfg) apparmor;
11+
dbus = cfg.dbusPackage;
1112
suidHelper = "${config.security.wrapperDir}/dbus-daemon-launch-helper";
1213
serviceDirectories = cfg.packages;
1314
};
@@ -35,6 +36,10 @@ in
3536
'';
3637
};
3738

39+
dbusPackage = lib.mkPackageOption pkgs "dbus" {};
40+
41+
brokerPackage = lib.mkPackageOption pkgs "dbus-broker" {};
42+
3843
implementation = mkOption {
3944
type = types.enum [ "dbus" "broker" ];
4045
default = "dbus";
@@ -44,7 +49,6 @@ in
4449
performance and reliability, while keeping compatibility to the D-Bus
4550
reference implementation.
4651
'';
47-
4852
};
4953

5054
packages = mkOption {
@@ -101,16 +105,16 @@ in
101105

102106
# Install dbus for dbus tools even when using dbus-broker
103107
environment.systemPackages = [
104-
pkgs.dbus
108+
cfg.dbusPackage
105109
];
106110

107111
# You still need the dbus reference implementation installed to use dbus-broker
108112
systemd.packages = [
109-
pkgs.dbus
113+
cfg.dbusPackage
110114
];
111115

112116
services.dbus.packages = [
113-
pkgs.dbus
117+
cfg.dbusPackage
114118
config.system.path
115119
];
116120

@@ -125,12 +129,13 @@ in
125129
groups.messagebus = { };
126130
contents."/etc/dbus-1".source = pkgs.makeDBusConf.override {
127131
inherit (cfg) apparmor;
132+
dbus = cfg.dbusPackage;
128133
suidHelper = "/bin/false";
129-
serviceDirectories = [ pkgs.dbus config.boot.initrd.systemd.package ];
134+
serviceDirectories = [ cfg.dbusPackage config.boot.initrd.systemd.package ];
130135
};
131-
packages = [ pkgs.dbus ];
136+
packages = [ cfg.dbusPackage ];
132137
storePaths = [
133-
"${pkgs.dbus}/bin/dbus-daemon"
138+
"${cfg.dbusPackage}/bin/dbus-daemon"
134139
"${config.boot.initrd.systemd.package}/share/dbus-1/system-services"
135140
"${config.boot.initrd.systemd.package}/share/dbus-1/system.d"
136141
];
@@ -140,7 +145,7 @@ in
140145

141146
(mkIf (cfg.implementation == "dbus") {
142147
security.wrappers.dbus-daemon-launch-helper = {
143-
source = "${pkgs.dbus}/libexec/dbus-daemon-launch-helper";
148+
source = "${cfg.dbusPackage}/libexec/dbus-daemon-launch-helper";
144149
owner = "root";
145150
group = "messagebus";
146151
setuid = true;
@@ -179,11 +184,11 @@ in
179184

180185
(mkIf (cfg.implementation == "broker") {
181186
environment.systemPackages = [
182-
pkgs.dbus-broker
187+
cfg.brokerPackage
183188
];
184189

185190
systemd.packages = [
186-
pkgs.dbus-broker
191+
cfg.brokerPackage
187192
];
188193

189194
# Just to be sure we don't restart through the unit alias

0 commit comments

Comments
 (0)