5ebdee3577
those that run daemons) to modules/services. This probably broke some things since there are a few relative paths in modules (e.g. imports of system/ids.nix). * Moved some PAM modules out of etc/pam.d to the directories of NixOS modules that use them. svn path=/nixos/branches/modular-nixos/; revision=15717
116 lines
2.3 KiB
Nix
116 lines
2.3 KiB
Nix
# D-Bus system-wide daemon.
|
|
{pkgs, config, ...}:
|
|
|
|
###### interface
|
|
let
|
|
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;
|
|
inherit (pkgs.lib) mkIf;
|
|
|
|
inherit (pkgs) stdenv dbus;
|
|
|
|
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
|
|
ln -s ${dbus}/etc/dbus-1/system.conf $out/system.conf
|
|
|
|
ensureDir $out/system.d
|
|
for i in ${toString services}; do
|
|
ln -s $i/etc/dbus-1/system.d/* $out/system.d/
|
|
done
|
|
";
|
|
};
|
|
|
|
user = {
|
|
name = "messagebus";
|
|
uid = (import ../../../system/ids.nix).uids.messagebus;
|
|
description = "D-Bus system message bus daemon user";
|
|
home = homeDir;
|
|
};
|
|
|
|
job = {
|
|
name = "dbus";
|
|
|
|
job = ''
|
|
description "D-Bus system message bus daemon"
|
|
|
|
start on startup
|
|
stop on shutdown
|
|
|
|
start script
|
|
|
|
mkdir -m 0755 -p ${homeDir}
|
|
chown messagebus ${homeDir}
|
|
|
|
mkdir -m 0755 -p /var/lib/dbus
|
|
${dbus.tools}/bin/dbus-uuidgen --ensure
|
|
|
|
rm -f ${homeDir}/pid
|
|
${dbus}/bin/dbus-daemon --config-file=${configFile}/system.conf
|
|
end script
|
|
|
|
respawn sleep 1000000
|
|
|
|
stop script
|
|
pid=$(cat ${homeDir}/pid)
|
|
if test -n "$pid"; then
|
|
kill -9 $pid
|
|
fi
|
|
end script
|
|
'';
|
|
};
|
|
|
|
in
|
|
|
|
mkIf cfg.enable {
|
|
require = [
|
|
# ../upstart-jobs/default.nix # config.services.extraJobs
|
|
# ../system/user.nix # users.*
|
|
# ? # config.environment.extraPackages
|
|
options
|
|
];
|
|
|
|
environment = {
|
|
extraPackages = [dbus.daemon dbus.tools];
|
|
};
|
|
|
|
users = {
|
|
extraUsers = [user];
|
|
};
|
|
|
|
services = {
|
|
extraJobs = [job];
|
|
};
|
|
}
|