2008-11-23 02:28:52 +01:00
|
|
|
# HAL daemon.
|
2008-12-04 16:48:27 +01:00
|
|
|
{pkgs, config, ...}:
|
2007-06-09 22:05:04 +02:00
|
|
|
|
2008-11-23 02:28:52 +01:00
|
|
|
###### interface
|
|
|
|
let
|
|
|
|
inherit (pkgs.lib) mkOption;
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services = {
|
|
|
|
hal = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = true;
|
|
|
|
description = "
|
|
|
|
Whether to start the HAL daemon.
|
|
|
|
";
|
|
|
|
};
|
2009-05-20 17:43:43 +02:00
|
|
|
|
|
|
|
extraFdi = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = [ "/nix/store/.../fdi" ];
|
|
|
|
description = "
|
|
|
|
Extend HAL daemon configuration with additionnal paths.
|
|
|
|
";
|
|
|
|
};
|
2008-11-23 02:28:52 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
let
|
|
|
|
cfg = config.services.hal;
|
2008-11-23 02:29:25 +01:00
|
|
|
inherit (pkgs.lib) mkIf;
|
2008-11-23 02:28:52 +01:00
|
|
|
|
|
|
|
inherit (pkgs) hal;
|
|
|
|
|
|
|
|
user = {
|
|
|
|
name = "haldaemon";
|
2009-05-25 01:13:23 +02:00
|
|
|
uid = (import ../../../system/ids.nix).uids.haldaemon;
|
2008-11-23 02:28:52 +01:00
|
|
|
description = "HAL daemon user";
|
|
|
|
};
|
|
|
|
|
|
|
|
group = {
|
|
|
|
name = "haldaemon";
|
2009-05-25 01:13:23 +02:00
|
|
|
gid = (import ../../../system/ids.nix).gids.haldaemon;
|
2008-11-23 02:28:52 +01:00
|
|
|
};
|
2007-06-10 22:13:12 +02:00
|
|
|
|
2009-05-20 17:43:43 +02: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 22:05:04 +02:00
|
|
|
|
2008-11-23 02:28:52 +01:00
|
|
|
job = {
|
|
|
|
name = "hal";
|
|
|
|
|
|
|
|
job = ''
|
|
|
|
description "HAL daemon"
|
2007-06-09 22:05:04 +02:00
|
|
|
|
2009-04-08 15:41:33 +02: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 02:28:52 +01:00
|
|
|
stop on shutdown
|
|
|
|
|
|
|
|
start script
|
|
|
|
|
|
|
|
mkdir -m 0755 -p /var/cache/hald
|
2009-04-28 15:44:43 +02:00
|
|
|
|
|
|
|
rm -f /var/cache/hald/fdi-cache
|
2008-11-23 02:28:52 +01:00
|
|
|
|
|
|
|
end script
|
|
|
|
|
2009-05-20 17:43:43 +02: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 02:28:52 +01:00
|
|
|
respawn ${hal}/sbin/hald --daemon=no
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
2008-11-23 02:29:25 +01:00
|
|
|
mkIf cfg.enable {
|
2008-11-23 02:28:52 +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.*
|
|
|
|
# ../upstart-jobs/udev.nix # services.udev.*
|
2009-05-25 01:13:23 +02:00
|
|
|
# ../upstart-jobs/dbus.nix # services.dbus.*
|
2009-05-20 01:14:45 +02:00
|
|
|
# ? # config.environment.extraPackages
|
2008-11-23 02:28:52 +01:00
|
|
|
options
|
|
|
|
];
|
2007-06-09 22:05:04 +02:00
|
|
|
|
2008-11-23 02:28:52 +01:00
|
|
|
environment = {
|
2008-11-23 02:29:25 +01:00
|
|
|
extraPackages = [hal];
|
2008-11-23 02:28:52 +01:00
|
|
|
};
|
2007-06-09 22:05:04 +02:00
|
|
|
|
2008-11-23 02:28:52 +01:00
|
|
|
users = {
|
2008-11-23 02:29:25 +01:00
|
|
|
extraUsers = [user];
|
|
|
|
extraGroups = [group];
|
2008-11-23 02:28:52 +01:00
|
|
|
};
|
2007-06-09 22:05:04 +02:00
|
|
|
|
2008-11-23 02:28:52 +01:00
|
|
|
services = {
|
2008-11-23 02:29:25 +01:00
|
|
|
extraJobs = [job];
|
2007-06-09 22:05:04 +02:00
|
|
|
|
2008-11-23 02:28:52 +01:00
|
|
|
udev = {
|
2008-11-23 02:29:25 +01:00
|
|
|
addUdevPkgs = [hal];
|
2008-11-23 02:28:52 +01:00
|
|
|
};
|
2008-03-22 17:05:01 +01:00
|
|
|
|
2008-11-23 02:28:52 +01:00
|
|
|
dbus = {
|
2008-11-23 02:29:25 +01:00
|
|
|
enable = true;
|
|
|
|
services = [hal];
|
2008-11-23 02:28:52 +01:00
|
|
|
};
|
|
|
|
};
|
2007-06-09 22:05:04 +02:00
|
|
|
}
|