2007-06-09 22:05:04 +02:00
|
|
|
{stdenv, dbus, dbusServices ? []}:
|
2007-06-08 20:56:55 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
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
|
|
|
|
for i in ${toString dbusServices}; do
|
|
|
|
ln -s $i/etc/dbus-1/system.d/* $out/system.d/
|
|
|
|
done
|
2007-06-08 20:56:55 +02:00
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
name = "dbus";
|
|
|
|
|
|
|
|
users = [
|
|
|
|
{ name = "messagebus";
|
|
|
|
uid = (import ../system/ids.nix).uids.messagebus;
|
|
|
|
description = "D-Bus system message bus daemon user";
|
|
|
|
home = homeDir;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2008-03-04 15:58:48 +01:00
|
|
|
extraPath = [dbus.daemon dbus.tools];
|
2007-06-09 22:05:04 +02:00
|
|
|
|
2008-03-22 17:05:01 +01:00
|
|
|
job = ''
|
|
|
|
description "D-Bus system message bus daemon"
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2008-03-22 17:05:01 +01:00
|
|
|
start on startup
|
|
|
|
stop on shutdown
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2008-03-22 17:05:01 +01:00
|
|
|
start script
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2008-03-22 17:05:01 +01:00
|
|
|
mkdir -m 0755 -p ${homeDir}
|
|
|
|
chown messagebus ${homeDir}
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2008-03-22 17:05:01 +01:00
|
|
|
mkdir -m 0755 -p /var/lib/dbus
|
|
|
|
${dbus.tools}/bin/dbus-uuidgen --ensure
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2009-04-04 00:04:31 +02:00
|
|
|
rm -f ${homeDir}/pid
|
|
|
|
${dbus}/bin/dbus-daemon --config-file=${configFile}/system.conf
|
2008-03-22 17:05:01 +01:00
|
|
|
end script
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2009-04-04 00:04:31 +02:00
|
|
|
respawn sleep 1000000
|
2007-06-08 20:56:55 +02:00
|
|
|
|
2009-04-04 00:04:31 +02:00
|
|
|
stop script
|
|
|
|
pid=$(cat ${homeDir}/pid)
|
|
|
|
if test -n "$pid"; then
|
|
|
|
kill -9 $pid
|
|
|
|
fi
|
2008-03-22 17:05:01 +01:00
|
|
|
end script
|
|
|
|
'';
|
2007-06-08 20:56:55 +02:00
|
|
|
|
|
|
|
}
|