2008-11-23 01:28:58 +00:00
|
|
|
# D-Bus system-wide daemon.
|
|
|
|
{pkgs, config}:
|
2007-06-08 18:56:55 +00:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
###### interface
|
2007-06-08 18:56:55 +00:00
|
|
|
let
|
2008-11-23 01:28:58 +00: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 01:29:25 +00:00
|
|
|
inherit (pkgs.lib) mkIf;
|
2008-11-23 01:28:58 +00:00
|
|
|
|
|
|
|
inherit (pkgs) stdenv dbus;
|
2007-06-08 18:56:55 +00: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 20:05:04 +00:00
|
|
|
|
|
|
|
ensureDir $out/system.d
|
2008-11-23 01:28:58 +00:00
|
|
|
for i in ${toString services}; do
|
2007-06-09 20:05:04 +00:00
|
|
|
ln -s $i/etc/dbus-1/system.d/* $out/system.d/
|
|
|
|
done
|
2007-06-08 18:56:55 +00:00
|
|
|
";
|
|
|
|
};
|
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
user = {
|
|
|
|
name = "messagebus";
|
|
|
|
uid = (import ../system/ids.nix).uids.messagebus;
|
|
|
|
description = "D-Bus system message bus daemon user";
|
|
|
|
home = homeDir;
|
|
|
|
};
|
2007-06-08 18:56:55 +00:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
job = {
|
|
|
|
name = "dbus";
|
2007-06-08 18:56:55 +00:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
job = ''
|
|
|
|
description "D-Bus system message bus daemon"
|
2007-06-08 18:56:55 +00:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
start on startup
|
|
|
|
stop on shutdown
|
2007-06-08 18:56:55 +00:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
start script
|
2007-06-08 18:56:55 +00:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
mkdir -m 0755 -p ${homeDir}
|
|
|
|
chown messagebus ${homeDir}
|
2007-06-08 18:56:55 +00:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
mkdir -m 0755 -p /var/lib/dbus
|
|
|
|
${dbus.tools}/bin/dbus-uuidgen --ensure
|
2007-06-08 18:56:55 +00:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
end script
|
2007-06-08 18:56:55 +00:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
respawn
|
2007-06-08 18:56:55 +00:00
|
|
|
|
2008-11-23 01:28:58 +00:00
|
|
|
script
|
|
|
|
rm -f ${homeDir}/pid
|
|
|
|
exec ${dbus}/bin/dbus-daemon --config-file=${configFile}/system.conf
|
|
|
|
end script
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
2008-11-23 01:29:25 +00:00
|
|
|
mkIf cfg.enable {
|
2008-11-23 01:28:58 +00:00
|
|
|
require = [
|
|
|
|
(import ../upstart-jobs/default.nix) # config.services.extraJobs
|
|
|
|
# (import ../system/user.nix) # users.*
|
|
|
|
# (import ?) # config.environment.extraPackages
|
|
|
|
options
|
|
|
|
];
|
|
|
|
|
|
|
|
environment = {
|
2008-11-23 01:29:25 +00:00
|
|
|
extraPackages = [dbus.daemon dbus.tools];
|
2008-11-23 01:28:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
users = {
|
2008-11-23 01:29:25 +00:00
|
|
|
extraUsers = [user];
|
2008-11-23 01:28:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
services = {
|
2008-11-23 01:29:25 +00:00
|
|
|
extraJobs = [job];
|
2008-11-23 01:28:58 +00:00
|
|
|
};
|
2007-06-08 18:56:55 +00:00
|
|
|
}
|