2008-11-23 01:28:52 +00:00
|
|
|
# HAL daemon.
|
2008-12-04 15:48:27 +00:00
|
|
|
{pkgs, config, ...}:
|
2007-06-09 20:05:04 +00:00
|
|
|
|
2008-11-23 01:28:52 +00:00
|
|
|
###### interface
|
|
|
|
let
|
|
|
|
inherit (pkgs.lib) mkOption;
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services = {
|
|
|
|
hal = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = true;
|
|
|
|
description = "
|
|
|
|
Whether to start the HAL daemon.
|
|
|
|
";
|
|
|
|
};
|
2009-05-20 15:43:43 +00:00
|
|
|
|
|
|
|
extraFdi = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = [ "/nix/store/.../fdi" ];
|
|
|
|
description = "
|
|
|
|
Extend HAL daemon configuration with additionnal paths.
|
|
|
|
";
|
|
|
|
};
|
2008-11-23 01:28:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
let
|
|
|
|
cfg = config.services.hal;
|
2008-11-23 01:29:25 +00:00
|
|
|
inherit (pkgs.lib) mkIf;
|
2008-11-23 01:28:52 +00:00
|
|
|
|
|
|
|
inherit (pkgs) hal;
|
|
|
|
|
|
|
|
user = {
|
|
|
|
name = "haldaemon";
|
|
|
|
uid = (import ../system/ids.nix).uids.haldaemon;
|
|
|
|
description = "HAL daemon user";
|
|
|
|
};
|
|
|
|
|
|
|
|
group = {
|
|
|
|
name = "haldaemon";
|
|
|
|
gid = (import ../system/ids.nix).gids.haldaemon;
|
|
|
|
};
|
2007-06-10 20:13:12 +00:00
|
|
|
|
2009-05-20 15:43:43 +00:00
|
|
|
fdi =
|
|
|
|
if cfg.extraFdi == [] then
|
|
|
|
hal + "/share/hal/fdi"
|
|
|
|
else
|
|
|
|
pkgs.buildEnv {
|
|
|
|
name = "hal-fdi";
|
|
|
|
pathsToLink = [ "/preprobe" "/information" "/policy" ];
|
|
|
|
paths = [ (hal + "/share/hal/fdi") ] ++ cfg.extraFdi;
|
|
|
|
};
|
2007-06-09 20:05:04 +00:00
|
|
|
|
2008-11-23 01:28:52 +00:00
|
|
|
job = {
|
|
|
|
name = "hal";
|
|
|
|
|
|
|
|
job = ''
|
|
|
|
description "HAL daemon"
|
2007-06-09 20:05:04 +00:00
|
|
|
|
2009-04-08 13:41:33 +00:00
|
|
|
# !!! TODO: make sure that HAL starts after acpid,
|
|
|
|
# otherwise hald-addon-acpi will grab /proc/acpi/event.
|
|
|
|
start on ${if config.powerManagement.enable then "acpid" else "dbus"}
|
2008-11-23 01:28:52 +00:00
|
|
|
stop on shutdown
|
|
|
|
|
|
|
|
start script
|
|
|
|
|
|
|
|
mkdir -m 0755 -p /var/cache/hald
|
2009-04-28 13:44:43 +00:00
|
|
|
|
|
|
|
rm -f /var/cache/hald/fdi-cache
|
2008-11-23 01:28:52 +00:00
|
|
|
|
|
|
|
end script
|
|
|
|
|
2009-05-20 15:43:43 +00:00
|
|
|
# HACK ? These environment variables manipulated inside
|
|
|
|
# 'src'/hald/mmap_cache.c are used for testing the daemon
|
|
|
|
env HAL_FDI_SOURCE_PREPROBE=${fdi}/preprobe
|
|
|
|
env HAL_FDI_SOURCE_INFORMATION=${fdi}/information
|
|
|
|
env HAL_FDI_SOURCE_POLICY=${fdi}/policy
|
|
|
|
|
2008-11-23 01:28:52 +00:00
|
|
|
respawn ${hal}/sbin/hald --daemon=no
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
2008-11-23 01:29:25 +00:00
|
|
|
mkIf cfg.enable {
|
2008-11-23 01:28:52 +00:00
|
|
|
require = [
|
2009-05-19 23:14:45 +00:00
|
|
|
../upstart-jobs/default.nix # config.services.extraJobs
|
|
|
|
# ../system/user.nix # users.*
|
|
|
|
# ../upstart-jobs/udev.nix # services.udev.*
|
|
|
|
../upstart-jobs/dbus.nix # services.dbus.*
|
|
|
|
# ? # config.environment.extraPackages
|
2008-11-23 01:28:52 +00:00
|
|
|
options
|
|
|
|
];
|
2007-06-09 20:05:04 +00:00
|
|
|
|
2008-11-23 01:28:52 +00:00
|
|
|
environment = {
|
2008-11-23 01:29:25 +00:00
|
|
|
extraPackages = [hal];
|
2008-11-23 01:28:52 +00:00
|
|
|
};
|
2007-06-09 20:05:04 +00:00
|
|
|
|
2008-11-23 01:28:52 +00:00
|
|
|
users = {
|
2008-11-23 01:29:25 +00:00
|
|
|
extraUsers = [user];
|
|
|
|
extraGroups = [group];
|
2008-11-23 01:28:52 +00:00
|
|
|
};
|
2007-06-09 20:05:04 +00:00
|
|
|
|
2008-11-23 01:28:52 +00:00
|
|
|
services = {
|
2008-11-23 01:29:25 +00:00
|
|
|
extraJobs = [job];
|
2007-06-09 20:05:04 +00:00
|
|
|
|
2008-11-23 01:28:52 +00:00
|
|
|
udev = {
|
2008-11-23 01:29:25 +00:00
|
|
|
addUdevPkgs = [hal];
|
2008-11-23 01:28:52 +00:00
|
|
|
};
|
2008-03-22 16:05:01 +00:00
|
|
|
|
2008-11-23 01:28:52 +00:00
|
|
|
dbus = {
|
2008-11-23 01:29:25 +00:00
|
|
|
enable = true;
|
|
|
|
services = [hal];
|
2008-11-23 01:28:52 +00:00
|
|
|
};
|
|
|
|
};
|
2007-06-09 20:05:04 +00:00
|
|
|
}
|