2008-11-23 02:28:58 +01:00
|
|
|
# D-Bus system-wide daemon.
|
2008-12-04 16:48:27 +01:00
|
|
|
{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
|
2009-04-04 00:04:31 +02:00
|
|
|
ln -s ${dbus}/etc/dbus-1/system.conf $out/system.conf
|
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";
|
2009-05-25 01:13:23 +02:00
|
|
|
uid = (import ../../../system/ids.nix).uids.messagebus;
|
2008-11-23 02:28:58 +01:00
|
|
|
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
|
2009-04-12 00:12:02 +02:00
|
|
|
|
|
|
|
rm -f ${homeDir}/pid
|
|
|
|
${dbus}/bin/dbus-daemon --config-file=${configFile}/system.conf
|
2008-11-23 02:28:58 +01:00
|
|
|
end script
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2009-04-12 00:12:02 +02:00
|
|
|
respawn sleep 1000000
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2009-04-12 00:12:02 +02:00
|
|
|
stop script
|
|
|
|
pid=$(cat ${homeDir}/pid)
|
|
|
|
if test -n "$pid"; then
|
|
|
|
kill -9 $pid
|
|
|
|
fi
|
2008-11-23 02:28:58 +01:00
|
|
|
end script
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
2008-11-23 02:29:25 +01:00
|
|
|
mkIf cfg.enable {
|
2008-11-23 02:28:58 +01:00
|
|
|
require = [
|
2009-05-25 01:13:23 +02:00
|
|
|
# ../upstart-jobs/default.nix # config.services.extraJobs
|
2009-05-20 01:14:45 +02:00
|
|
|
# ../system/user.nix # users.*
|
|
|
|
# ? # config.environment.extraPackages
|
2008-11-23 02:28:58 +01:00
|
|
|
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
|
|
|
}
|