2010-07-13 10:22:52 +01:00
|
|
|
# D-Bus configuration and system bus daemon.
|
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2007-06-08 19:56:55 +01:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2008-11-23 01:28:58 +00:00
|
|
|
|
|
|
|
let
|
2009-08-10 19:25:09 +01:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
cfg = config.services.dbus;
|
|
|
|
|
2007-06-08 19:56:55 +01:00
|
|
|
homeDir = "/var/run/dbus";
|
|
|
|
|
2016-03-07 01:38:53 +00:00
|
|
|
systemExtraxml = concatStrings (flip concatMap cfg.packages (d: [
|
|
|
|
"<servicedir>${d}/share/dbus-1/system-services</servicedir>"
|
|
|
|
"<includedir>${d}/etc/dbus-1/system.d</includedir>"
|
|
|
|
]));
|
|
|
|
|
|
|
|
sessionExtraxml = concatStrings (flip concatMap cfg.packages (d: [
|
|
|
|
"<servicedir>${d}/share/dbus-1/services</servicedir>"
|
|
|
|
"<includedir>${d}/etc/dbus-1/session.d</includedir>"
|
|
|
|
]));
|
|
|
|
|
2009-08-16 22:46:26 +01:00
|
|
|
configDir = pkgs.stdenv.mkDerivation {
|
2007-06-08 19:56:55 +01:00
|
|
|
name = "dbus-conf";
|
2015-07-07 14:01:36 +01:00
|
|
|
|
2012-05-09 22:35:47 +01:00
|
|
|
preferLocalBuild = true;
|
2015-07-07 14:01:36 +01:00
|
|
|
allowSubstitutes = false;
|
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
buildCommand = ''
|
2014-06-30 13:56:10 +01:00
|
|
|
mkdir -p $out
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2016-03-07 01:38:53 +00:00
|
|
|
sed '${./dbus-system-local.conf.in}' \
|
|
|
|
-e 's,@servicehelper@,${config.security.wrapperDir}/dbus-daemon-launch-helper,g' \
|
|
|
|
-e 's,@extra@,${systemExtraxml},' \
|
|
|
|
> "$out/system-local.conf"
|
2010-07-13 10:22:52 +01:00
|
|
|
|
2016-03-07 01:38:53 +00:00
|
|
|
sed '${./dbus-session-local.conf.in}' \
|
|
|
|
-e 's,@extra@,${sessionExtraxml},' \
|
|
|
|
> "$out/session-local.conf"
|
|
|
|
'';
|
2007-06-08 19:56:55 +01:00
|
|
|
};
|
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
in
|
2007-06-08 19:56:55 +01:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
{
|
2007-06-08 19:56:55 +01:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
###### interface
|
2007-06-08 19:56:55 +01:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
options = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
services.dbus = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
2013-10-28 15:14:15 +00:00
|
|
|
type = types.bool;
|
2016-03-07 01:38:53 +00:00
|
|
|
default = false;
|
2015-08-24 13:36:21 +01:00
|
|
|
internal = true;
|
2009-08-10 19:25:09 +01:00
|
|
|
description = ''
|
|
|
|
Whether to start the D-Bus message bus daemon, which is
|
|
|
|
required by many other system services and applications.
|
|
|
|
'';
|
|
|
|
};
|
2007-06-08 19:56:55 +01:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
packages = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
type = types.listOf types.path;
|
2016-03-07 01:38:53 +00:00
|
|
|
default = [ ];
|
2009-08-10 19:25:09 +01:00
|
|
|
description = ''
|
|
|
|
Packages whose D-Bus configuration files should be included in
|
2016-06-21 20:51:47 +01:00
|
|
|
the configuration of the D-Bus system-wide or session-wide
|
|
|
|
message bus. Specifically, files in the following directories
|
|
|
|
will be included into their respective DBus configuration paths:
|
2009-08-10 19:25:09 +01:00
|
|
|
<filename><replaceable>pkg</replaceable>/etc/dbus-1/system.d</filename>
|
2016-06-21 20:51:47 +01:00
|
|
|
<filename><replaceable>pkg</replaceable>/share/dbus-1/system-services</filename>
|
|
|
|
<filename><replaceable>pkg</replaceable>/etc/dbus-1/session.d</filename>
|
|
|
|
<filename><replaceable>pkg</replaceable>/share/dbus-1/services</filename>
|
2009-08-10 19:25:09 +01:00
|
|
|
'';
|
|
|
|
};
|
2007-06-08 19:56:55 +01:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
###### implementation
|
2008-11-23 01:28:58 +00:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
config = mkIf cfg.enable {
|
2008-11-23 01:28:58 +00:00
|
|
|
|
2014-04-22 14:36:39 +01:00
|
|
|
environment.systemPackages = [ pkgs.dbus.daemon pkgs.dbus_tools ];
|
2009-08-10 19:25:09 +01:00
|
|
|
|
2009-08-16 22:46:26 +01:00
|
|
|
environment.etc = singleton
|
|
|
|
{ source = configDir;
|
|
|
|
target = "dbus-1";
|
|
|
|
};
|
|
|
|
|
2013-08-23 10:33:24 +01:00
|
|
|
users.extraUsers.messagebus = {
|
|
|
|
uid = config.ids.uids.messagebus;
|
|
|
|
description = "D-Bus system message bus daemon user";
|
|
|
|
home = homeDir;
|
|
|
|
group = "messagebus";
|
|
|
|
};
|
2009-08-16 22:46:26 +01:00
|
|
|
|
2013-08-23 10:33:24 +01:00
|
|
|
users.extraGroups.messagebus.gid = config.ids.gids.messagebus;
|
2009-08-10 19:25:09 +01:00
|
|
|
|
2014-04-22 14:36:39 +01:00
|
|
|
systemd.packages = [ pkgs.dbus.daemon ];
|
2012-06-14 23:44:56 +01:00
|
|
|
|
2009-08-16 22:46:26 +01:00
|
|
|
security.setuidOwners = singleton
|
|
|
|
{ program = "dbus-daemon-launch-helper";
|
2016-04-26 14:10:30 +01:00
|
|
|
source = "${pkgs.dbus_daemon.out}/libexec/dbus-daemon-launch-helper";
|
2009-08-16 22:46:26 +01:00
|
|
|
owner = "root";
|
|
|
|
group = "messagebus";
|
|
|
|
setuid = true;
|
|
|
|
setgid = false;
|
|
|
|
permissions = "u+rx,g+rx,o-rx";
|
|
|
|
};
|
|
|
|
|
2016-03-07 01:38:53 +00:00
|
|
|
services.dbus.packages = [
|
2016-05-18 20:57:35 +01:00
|
|
|
pkgs.dbus.out
|
2016-03-07 01:38:53 +00:00
|
|
|
config.system.path
|
|
|
|
];
|
2010-07-26 15:10:04 +01:00
|
|
|
|
2015-04-01 15:28:18 +01:00
|
|
|
# Don't restart dbus-daemon. Bad things tend to happen if we do.
|
|
|
|
systemd.services.dbus.reloadIfChanged = true;
|
|
|
|
|
2015-04-16 18:10:11 +01:00
|
|
|
systemd.services.dbus.restartTriggers = [ configDir ];
|
|
|
|
|
2010-08-09 12:42:32 +01:00
|
|
|
environment.pathsToLink = [ "/etc/dbus-1" "/share/dbus-1" ];
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2007-06-08 19:56:55 +01:00
|
|
|
}
|