2010-07-13 11:22:52 +02:00
|
|
|
# D-Bus configuration and system bus daemon.
|
|
|
|
|
2020-10-22 20:24:41 +02:00
|
|
|
{ config, lib, options, pkgs, ... }:
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2008-11-23 02:28:58 +01:00
|
|
|
|
|
|
|
let
|
2009-08-10 20:25:09 +02:00
|
|
|
|
2008-11-23 02:28:58 +01:00
|
|
|
cfg = config.services.dbus;
|
|
|
|
|
2016-09-20 09:21:08 +02:00
|
|
|
homeDir = "/run/dbus";
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2017-02-16 12:56:45 +01:00
|
|
|
configDir = pkgs.makeDBusConf {
|
2020-11-02 22:42:55 +01:00
|
|
|
inherit (cfg) apparmor;
|
2017-02-16 12:56:45 +01:00
|
|
|
suidHelper = "${config.security.wrapperDir}/dbus-daemon-launch-helper";
|
|
|
|
serviceDirectories = cfg.packages;
|
|
|
|
};
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2009-08-10 20:25:09 +02:00
|
|
|
in
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2009-08-10 20:25:09 +02:00
|
|
|
{
|
|
|
|
###### interface
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2009-08-10 20:25:09 +02:00
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-08-10 20:25:09 +02:00
|
|
|
services.dbus = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
2013-10-28 16:14:15 +01:00
|
|
|
type = types.bool;
|
2016-03-07 02:38:53 +01:00
|
|
|
default = false;
|
2015-08-24 14:36:21 +02:00
|
|
|
internal = true;
|
2009-08-10 20:25:09 +02:00
|
|
|
description = ''
|
|
|
|
Whether to start the D-Bus message bus daemon, which is
|
|
|
|
required by many other system services and applications.
|
|
|
|
'';
|
|
|
|
};
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2009-08-10 20:25:09 +02:00
|
|
|
packages = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
type = types.listOf types.path;
|
2016-03-07 02:38:53 +01:00
|
|
|
default = [ ];
|
2009-08-10 20:25:09 +02:00
|
|
|
description = ''
|
|
|
|
Packages whose D-Bus configuration files should be included in
|
2016-06-21 21:51:47 +02: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 20:25:09 +02:00
|
|
|
<filename><replaceable>pkg</replaceable>/etc/dbus-1/system.d</filename>
|
2019-08-24 17:32:50 +02:00
|
|
|
<filename><replaceable>pkg</replaceable>/share/dbus-1/system.d</filename>
|
2016-06-21 21:51:47 +02:00
|
|
|
<filename><replaceable>pkg</replaceable>/share/dbus-1/system-services</filename>
|
|
|
|
<filename><replaceable>pkg</replaceable>/etc/dbus-1/session.d</filename>
|
2019-08-24 17:32:50 +02:00
|
|
|
<filename><replaceable>pkg</replaceable>/share/dbus-1/session.d</filename>
|
2016-06-21 21:51:47 +02:00
|
|
|
<filename><replaceable>pkg</replaceable>/share/dbus-1/services</filename>
|
2009-08-10 20:25:09 +02:00
|
|
|
'';
|
|
|
|
};
|
2020-10-22 20:24:41 +02:00
|
|
|
|
2020-11-02 22:42:55 +01:00
|
|
|
apparmor = mkOption {
|
|
|
|
type = types.enum [ "enabled" "disabled" "required" ];
|
|
|
|
description = ''
|
|
|
|
AppArmor mode for dbus.
|
|
|
|
|
|
|
|
<literal>enabled</literal> enables mediation when it's
|
|
|
|
supported in the kernel, <literal>disabled</literal>
|
|
|
|
always disables AppArmor even with kernel support, and
|
|
|
|
<literal>required</literal> fails when AppArmor was not found
|
|
|
|
in the kernel.
|
|
|
|
'';
|
|
|
|
default = "disabled";
|
|
|
|
};
|
|
|
|
|
2020-10-22 20:24:41 +02:00
|
|
|
socketActivated = mkOption {
|
|
|
|
type = types.nullOr types.bool;
|
|
|
|
default = null;
|
|
|
|
visible = false;
|
|
|
|
description = ''
|
|
|
|
Removed option, do not use.
|
|
|
|
'';
|
|
|
|
};
|
2009-08-10 20:25:09 +02:00
|
|
|
};
|
2008-11-23 02:28:58 +01:00
|
|
|
};
|
|
|
|
|
2009-08-10 20:25:09 +02:00
|
|
|
###### implementation
|
2008-11-23 02:28:58 +01:00
|
|
|
|
2009-08-10 20:25:09 +02:00
|
|
|
config = mkIf cfg.enable {
|
2020-10-22 20:24:41 +02:00
|
|
|
warnings = optional (cfg.socketActivated != null) (
|
|
|
|
let
|
|
|
|
files = showFiles options.services.dbus.socketActivated.files;
|
|
|
|
in
|
|
|
|
"The option 'services.dbus.socketActivated' in ${files} no longer has"
|
|
|
|
+ " any effect and can be safely removed: the user D-Bus session is"
|
|
|
|
+ " now always socket activated."
|
|
|
|
);
|
2008-11-23 02:28:58 +01:00
|
|
|
|
2016-09-05 13:38:16 +02:00
|
|
|
environment.systemPackages = [ pkgs.dbus.daemon pkgs.dbus ];
|
2009-08-10 20:25:09 +02:00
|
|
|
|
2019-09-14 19:51:29 +02:00
|
|
|
environment.etc."dbus-1".source = configDir;
|
2017-01-30 23:59:20 +01:00
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.users.messagebus = {
|
2013-08-23 11:33:24 +02:00
|
|
|
uid = config.ids.uids.messagebus;
|
|
|
|
description = "D-Bus system message bus daemon user";
|
|
|
|
home = homeDir;
|
|
|
|
group = "messagebus";
|
|
|
|
};
|
2009-08-16 23:46:26 +02:00
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.groups.messagebus.gid = config.ids.gids.messagebus;
|
2009-08-10 20:25:09 +02:00
|
|
|
|
2014-04-22 15:36:39 +02:00
|
|
|
systemd.packages = [ pkgs.dbus.daemon ];
|
2012-06-15 00:44:56 +02:00
|
|
|
|
2017-01-29 08:58:12 +01:00
|
|
|
security.wrappers.dbus-daemon-launch-helper = {
|
|
|
|
source = "${pkgs.dbus.daemon}/libexec/dbus-daemon-launch-helper";
|
|
|
|
owner = "root";
|
|
|
|
group = "messagebus";
|
|
|
|
setuid = true;
|
|
|
|
setgid = false;
|
|
|
|
permissions = "u+rx,g+rx,o-rx";
|
|
|
|
};
|
2009-08-16 23:46:26 +02:00
|
|
|
|
2016-03-07 02:38:53 +01:00
|
|
|
services.dbus.packages = [
|
2016-05-18 21:57:35 +02:00
|
|
|
pkgs.dbus.out
|
2016-03-07 02:38:53 +01:00
|
|
|
config.system.path
|
|
|
|
];
|
2010-07-26 16:10:04 +02:00
|
|
|
|
2016-09-20 09:21:08 +02:00
|
|
|
systemd.services.dbus = {
|
|
|
|
# Don't restart dbus-daemon. Bad things tend to happen if we do.
|
|
|
|
reloadIfChanged = true;
|
|
|
|
restartTriggers = [ configDir ];
|
2018-06-07 16:44:04 +02:00
|
|
|
environment = { LD_LIBRARY_PATH = config.system.nssModules.path; };
|
2016-09-20 09:21:08 +02:00
|
|
|
};
|
2015-04-01 16:28:18 +02:00
|
|
|
|
2016-09-20 09:21:08 +02:00
|
|
|
systemd.user = {
|
|
|
|
services.dbus = {
|
|
|
|
# Don't restart dbus-daemon. Bad things tend to happen if we do.
|
|
|
|
reloadIfChanged = true;
|
|
|
|
restartTriggers = [ configDir ];
|
|
|
|
};
|
2020-09-06 22:57:54 +02:00
|
|
|
sockets.dbus.wantedBy = [ "sockets.target" ];
|
2016-09-20 09:21:08 +02:00
|
|
|
};
|
2015-04-16 19:10:11 +02:00
|
|
|
|
2010-08-09 13:42:32 +02:00
|
|
|
environment.pathsToLink = [ "/etc/dbus-1" "/share/dbus-1" ];
|
2008-11-23 02:28:58 +01:00
|
|
|
};
|
2007-06-08 20:56:55 +02:00
|
|
|
}
|