2010-07-13 09:22:52 +00:00
|
|
|
# D-Bus configuration and system bus daemon.
|
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2007-06-08 18:56:55 +00:00
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2008-11-23 01:28:58 +00:00
|
|
|
|
|
|
|
let
|
2009-08-10 18:25:09 +00:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
cfg = config.services.dbus;
|
|
|
|
|
2007-06-08 18:56:55 +00:00
|
|
|
homeDir = "/var/run/dbus";
|
|
|
|
|
2009-08-16 21:46:26 +00:00
|
|
|
configDir = pkgs.stdenv.mkDerivation {
|
2007-06-08 18:56:55 +00:00
|
|
|
name = "dbus-conf";
|
2015-07-07 13:01:36 +00:00
|
|
|
|
2012-05-09 21:35:47 +00:00
|
|
|
preferLocalBuild = true;
|
2015-07-07 13:01:36 +00:00
|
|
|
allowSubstitutes = false;
|
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
buildCommand = ''
|
2014-06-30 12:56:10 +00:00
|
|
|
mkdir -p $out
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2014-04-22 13:36:39 +00:00
|
|
|
cp -v ${pkgs.dbus.daemon}/etc/dbus-1/system.conf $out/system.conf
|
2009-08-16 21:46:26 +00:00
|
|
|
|
2010-07-13 09:22:52 +00:00
|
|
|
# !!! Hm, these `sed' calls are rather error-prone...
|
|
|
|
|
2009-08-16 21:46:26 +00:00
|
|
|
# Tell the daemon where the setuid wrapper around
|
2011-09-14 18:20:50 +00:00
|
|
|
# dbus-daemon-launch-helper lives.
|
2009-08-16 21:46:26 +00:00
|
|
|
sed -i $out/system.conf \
|
|
|
|
-e 's|<servicehelper>.*/libexec/dbus-daemon-launch-helper|<servicehelper>${config.security.wrapperDir}/dbus-daemon-launch-helper|'
|
|
|
|
|
2010-07-13 09:22:52 +00:00
|
|
|
# Add the system-services and system.d directories to the system
|
|
|
|
# bus search path.
|
2009-08-16 21:46:26 +00:00
|
|
|
sed -i $out/system.conf \
|
2010-07-26 14:10:04 +00:00
|
|
|
-e 's|<standard_system_servicedirs/>|${systemServiceDirs}|' \
|
|
|
|
-e 's|<includedir>system.d</includedir>|${systemIncludeDirs}|'
|
2010-07-13 09:22:52 +00:00
|
|
|
|
2014-04-22 13:36:39 +00:00
|
|
|
cp ${pkgs.dbus.daemon}/etc/dbus-1/session.conf $out/session.conf
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2010-07-13 09:22:52 +00:00
|
|
|
# Add the services and session.d directories to the session bus
|
|
|
|
# search path.
|
|
|
|
sed -i $out/session.conf \
|
2011-09-07 23:07:05 +00:00
|
|
|
-e 's|<standard_session_servicedirs />|${sessionServiceDirs}&|' \
|
2010-07-26 14:10:04 +00:00
|
|
|
-e 's|<includedir>session.d</includedir>|${sessionIncludeDirs}|'
|
2009-08-10 18:25:09 +00:00
|
|
|
''; # */
|
2007-06-08 18:56:55 +00:00
|
|
|
};
|
|
|
|
|
2009-08-16 21:46:26 +00:00
|
|
|
systemServiceDirs = concatMapStrings
|
|
|
|
(d: "<servicedir>${d}/share/dbus-1/system-services</servicedir> ")
|
|
|
|
cfg.packages;
|
|
|
|
|
2010-07-26 14:10:04 +00:00
|
|
|
systemIncludeDirs = concatMapStrings
|
|
|
|
(d: "<includedir>${d}/etc/dbus-1/system.d</includedir> ")
|
|
|
|
cfg.packages;
|
|
|
|
|
2010-07-13 09:22:52 +00:00
|
|
|
sessionServiceDirs = concatMapStrings
|
|
|
|
(d: "<servicedir>${d}/share/dbus-1/services</servicedir> ")
|
|
|
|
cfg.packages;
|
|
|
|
|
2010-07-26 14:10:04 +00:00
|
|
|
sessionIncludeDirs = concatMapStrings
|
|
|
|
(d: "<includedir>${d}/etc/dbus-1/session.d</includedir> ")
|
|
|
|
cfg.packages;
|
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
in
|
2007-06-08 18:56:55 +00:00
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
{
|
2007-06-08 18:56:55 +00:00
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
###### interface
|
2007-06-08 18:56:55 +00:00
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
options = {
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
services.dbus = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
2013-10-28 15:14:15 +00:00
|
|
|
type = types.bool;
|
2009-08-10 18:25:09 +00:00
|
|
|
default = true;
|
2015-08-24 12:36:21 +00:00
|
|
|
internal = true;
|
2009-08-10 18:25:09 +00:00
|
|
|
description = ''
|
|
|
|
Whether to start the D-Bus message bus daemon, which is
|
|
|
|
required by many other system services and applications.
|
|
|
|
'';
|
|
|
|
};
|
2007-06-08 18:56:55 +00:00
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
packages = mkOption {
|
2013-10-30 16:37:45 +00:00
|
|
|
type = types.listOf types.path;
|
2009-08-10 18:25:09 +00:00
|
|
|
default = [];
|
|
|
|
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 18:56:55 +00:00
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
###### implementation
|
2008-11-23 01:28:58 +00:00
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
config = mkIf cfg.enable {
|
2008-11-23 01:28:58 +00:00
|
|
|
|
2014-04-22 13:36:39 +00:00
|
|
|
environment.systemPackages = [ pkgs.dbus.daemon pkgs.dbus_tools ];
|
2009-08-10 18:25:09 +00:00
|
|
|
|
2009-08-16 21:46:26 +00:00
|
|
|
environment.etc = singleton
|
|
|
|
{ source = configDir;
|
|
|
|
target = "dbus-1";
|
|
|
|
};
|
|
|
|
|
2013-08-23 09:33:24 +00:00
|
|
|
users.extraUsers.messagebus = {
|
|
|
|
uid = config.ids.uids.messagebus;
|
|
|
|
description = "D-Bus system message bus daemon user";
|
|
|
|
home = homeDir;
|
|
|
|
group = "messagebus";
|
|
|
|
};
|
2009-08-16 21:46:26 +00:00
|
|
|
|
2013-08-23 09:33:24 +00:00
|
|
|
users.extraGroups.messagebus.gid = config.ids.gids.messagebus;
|
2009-08-10 18:25:09 +00:00
|
|
|
|
2014-04-22 13:36:39 +00:00
|
|
|
systemd.packages = [ pkgs.dbus.daemon ];
|
2012-06-14 22:44:56 +00:00
|
|
|
|
2009-08-16 21:46:26 +00:00
|
|
|
security.setuidOwners = singleton
|
|
|
|
{ program = "dbus-daemon-launch-helper";
|
2016-04-26 13:10:30 +00:00
|
|
|
source = "${pkgs.dbus_daemon.out}/libexec/dbus-daemon-launch-helper";
|
2009-08-16 21:46:26 +00:00
|
|
|
owner = "root";
|
|
|
|
group = "messagebus";
|
|
|
|
setuid = true;
|
|
|
|
setgid = false;
|
|
|
|
permissions = "u+rx,g+rx,o-rx";
|
|
|
|
};
|
|
|
|
|
2010-07-26 14:10:04 +00:00
|
|
|
services.dbus.packages =
|
2011-10-30 15:19:58 +00:00
|
|
|
[ "/nix/var/nix/profiles/default"
|
2010-07-26 14:10:04 +00:00
|
|
|
config.system.path
|
|
|
|
];
|
|
|
|
|
2015-04-01 14:28:18 +00:00
|
|
|
# Don't restart dbus-daemon. Bad things tend to happen if we do.
|
|
|
|
systemd.services.dbus.reloadIfChanged = true;
|
|
|
|
|
2015-04-16 17:10:11 +00:00
|
|
|
systemd.services.dbus.restartTriggers = [ configDir ];
|
|
|
|
|
2010-08-09 11:42:32 +00:00
|
|
|
environment.pathsToLink = [ "/etc/dbus-1" "/share/dbus-1" ];
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2007-06-08 18:56:55 +00:00
|
|
|
}
|