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