diff options
author | Peter Hoeg <peter@speartail.com> | 2016-09-20 15:21:08 +0800 |
---|---|---|
committer | Domen Kožar <domen@dev.si> | 2016-09-30 13:14:53 +0200 |
commit | 639e5401ff51d4c0075b5ceffcbdbfec64c67db3 (patch) | |
tree | 7cb5566c83ce58d4084401185421b790a3d36298 /nixos/modules/services/system/dbus.nix | |
parent | 2a53b06e0661758ff2c206aa7e41764f1081c9b3 (diff) |
dbus: add socket activation but do not enable it
The following changes are included: 1) install user unit files from upstream dbus 2) use absolute paths to config for --system and --session instances 3) make socket activation of user units configurable There has been a number of PRs to address this, so this one does the bare minimum, which is to make the functionality available and configurable but defaults to off. Related PRs: - #18382 - #18222 (cherry picked from commit f7215c9b5b47dfb0a6dbe87ff33d7730729a32e5) Signed-off-by: Domen Kožar <domen@dev.si>
Diffstat (limited to 'nixos/modules/services/system/dbus.nix')
-rw-r--r-- | nixos/modules/services/system/dbus.nix | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/nixos/modules/services/system/dbus.nix b/nixos/modules/services/system/dbus.nix index 0f20725a9e4a7..a7cf74c15cc57 100644 --- a/nixos/modules/services/system/dbus.nix +++ b/nixos/modules/services/system/dbus.nix @@ -8,7 +8,7 @@ let cfg = config.services.dbus; - homeDir = "/var/run/dbus"; + homeDir = "/run/dbus"; systemExtraxml = concatStrings (flip concatMap cfg.packages (d: [ "<servicedir>${d}/share/dbus-1/system-services</servicedir>" @@ -20,6 +20,8 @@ let "<includedir>${d}/etc/dbus-1/session.d</includedir>" ])); + daemonArgs = "--address=systemd: --nofork --nopidfile --systemd-activation"; + configDir = pkgs.runCommand "dbus-conf" { preferLocalBuild = true; allowSubstitutes = false; @@ -27,6 +29,14 @@ let '' mkdir -p $out + cp ${pkgs.dbus.out}/share/dbus-1/{system,session}.conf $out + + # avoid circular includes + sed -ri 's@(<include ignore_missing="yes">/etc/dbus-1/(system|session)\.conf</include>)@<!-- \1 -->@g' $out/{system,session}.conf + + # include by full path + sed -ri "s@/etc/dbus-1/(system|session)-@$out/\1-@" $out/{system,session}.conf + sed '${./dbus-system-local.conf.in}' \ -e 's,@servicehelper@,${config.security.wrapperDir}/dbus-daemon-launch-helper,g' \ -e 's,@extra@,${systemExtraxml},' \ @@ -72,11 +82,16 @@ in ''; }; + socketActivated = mkOption { + type = types.bool; + default = false; + description = '' + Make the user instance socket activated. + ''; + }; }; - }; - ###### implementation config = mkIf cfg.enable { @@ -114,13 +129,29 @@ in config.system.path ]; - # Don't restart dbus-daemon. Bad things tend to happen if we do. - systemd.services.dbus.reloadIfChanged = true; + systemd.services.dbus = { + # Don't restart dbus-daemon. Bad things tend to happen if we do. + reloadIfChanged = true; + restartTriggers = [ configDir ]; + serviceConfig.ExecStart = [ + "" + "${lib.getBin pkgs.dbus}/bin/dbus-daemon --config-file=${configDir}/system.conf ${daemonArgs}" + ]; + }; - systemd.services.dbus.restartTriggers = [ configDir ]; + systemd.user = { + services.dbus = { + # Don't restart dbus-daemon. Bad things tend to happen if we do. + reloadIfChanged = true; + restartTriggers = [ configDir ]; + serviceConfig.ExecStart = [ + "" + "${lib.getBin pkgs.dbus}/bin/dbus-daemon --config-file=${configDir}/session.conf ${daemonArgs}" + ]; + }; + sockets.dbus.wantedBy = mkIf cfg.socketActivated [ "sockets.target" ]; + }; environment.pathsToLink = [ "/etc/dbus-1" "/share/dbus-1" ]; - }; - } |