2008-11-23 02:28:58 +01:00
|
|
|
# D-Bus system-wide daemon.
|
|
|
|
{pkgs, config}:
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2008-11-23 02:28:58 +01:00
|
|
|
###### interface
|
2007-06-08 20:56:55 +02:00
|
|
|
let
|
2008-11-23 02:28:58 +01:00
|
|
|
inherit (pkgs.lib) mkOption;
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services = {
|
|
|
|
dbus = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = true;
|
|
|
|
description = "
|
|
|
|
Whether to start the D-Bus message bus daemon. It is required
|
|
|
|
by the HAL service.
|
|
|
|
";
|
|
|
|
merge = pkgs.lib.mergeEnableOption;
|
|
|
|
};
|
|
|
|
|
|
|
|
services = mkOption {
|
|
|
|
default = [];
|
|
|
|
description = ".. fill me ..";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
let
|
|
|
|
cfg = config.services.dbus;
|
|
|
|
services = cfg.services;
|
2008-11-23 02:29:25 +01:00
|
|
|
inherit (pkgs.lib) mkIf;
|
2008-11-23 02:28:58 +01:00
|
|
|
|
|
|
|
inherit (pkgs) stdenv dbus;
|
2007-06-08 20:56:55 +02:00
|
|
|
|
|
|
|
homeDir = "/var/run/dbus";
|
|
|
|
|
|
|
|
# Take the standard system configuration file, except that we don't
|
|
|
|
# want to fork (Upstart will monitor the daemon).
|
|
|
|
configFile = stdenv.mkDerivation {
|
|
|
|
name = "dbus-conf";
|
|
|
|
buildCommand = "
|
|
|
|
ensureDir $out
|
|
|
|
substitute ${dbus}/etc/dbus-1/system.conf $out/system.conf \\
|
|
|
|
--replace '<fork/>' ''
|
2007-06-09 22:05:04 +02:00
|
|
|
|
|
|
|
ensureDir $out/system.d
|
2008-11-23 02:28:58 +01:00
|
|
|
for i in ${toString services}; do
|
2007-06-09 22:05:04 +02:00
|
|
|
ln -s $i/etc/dbus-1/system.d/* $out/system.d/
|
|
|
|
done
|
2007-06-08 20:56:55 +02:00
|
|
|
";
|
|
|
|
};
|
|
|
|
|
2008-11-23 02:28:58 +01:00
|
|
|
user = {
|
|
|
|
name = "messagebus";
|
|
|
|
uid = (import ../system/ids.nix).uids.messagebus;
|
|
|
|
description = "D-Bus system message bus daemon user";
|
|
|
|
home = homeDir;
|
|
|
|
};
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2008-11-23 02:28:58 +01:00
|
|
|
job = {
|
|
|
|
name = "dbus";
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2008-11-23 02:28:58 +01:00
|
|
|
job = ''
|
|
|
|
description "D-Bus system message bus daemon"
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2008-11-23 02:28:58 +01:00
|
|
|
start on startup
|
|
|
|
stop on shutdown
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2008-11-23 02:28:58 +01:00
|
|
|
start script
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2008-11-23 02:28:58 +01:00
|
|
|
mkdir -m 0755 -p ${homeDir}
|
|
|
|
chown messagebus ${homeDir}
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2008-11-23 02:28:58 +01:00
|
|
|
mkdir -m 0755 -p /var/lib/dbus
|
|
|
|
${dbus.tools}/bin/dbus-uuidgen --ensure
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2008-11-23 02:28:58 +01:00
|
|
|
end script
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2008-11-23 02:28:58 +01:00
|
|
|
respawn
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2008-11-23 02:28:58 +01:00
|
|
|
script
|
|
|
|
rm -f ${homeDir}/pid
|
|
|
|
exec ${dbus}/bin/dbus-daemon --config-file=${configFile}/system.conf
|
|
|
|
end script
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
2008-11-23 02:29:25 +01:00
|
|
|
mkIf cfg.enable {
|
2008-11-23 02:28:58 +01:00
|
|
|
require = [
|
|
|
|
(import ../upstart-jobs/default.nix) # config.services.extraJobs
|
|
|
|
# (import ../system/user.nix) # users.*
|
|
|
|
# (import ?) # config.environment.extraPackages
|
|
|
|
options
|
|
|
|
];
|
|
|
|
|
|
|
|
environment = {
|
2008-11-23 02:29:25 +01:00
|
|
|
extraPackages = [dbus.daemon dbus.tools];
|
2008-11-23 02:28:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
users = {
|
2008-11-23 02:29:25 +01:00
|
|
|
extraUsers = [user];
|
2008-11-23 02:28:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
services = {
|
2008-11-23 02:29:25 +01:00
|
|
|
extraJobs = [job];
|
2008-11-23 02:28:58 +01:00
|
|
|
};
|
2007-06-08 20:56:55 +02:00
|
|
|
}
|