2008-11-23 01:28:52 +00:00
|
|
|
# HAL daemon.
|
2009-10-12 18:27:57 +01:00
|
|
|
{ config, pkgs, ... }:
|
2007-06-09 21:05:04 +01:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
with pkgs.lib;
|
2008-11-23 01:28:52 +00:00
|
|
|
|
|
|
|
let
|
2009-08-10 19:25:09 +01:00
|
|
|
|
2008-11-23 01:28:52 +00:00
|
|
|
cfg = config.services.hal;
|
|
|
|
|
|
|
|
inherit (pkgs) hal;
|
|
|
|
|
2009-08-11 22:16:59 +01:00
|
|
|
fdi = pkgs.buildEnv {
|
|
|
|
name = "hal-fdi";
|
|
|
|
pathsToLink = [ "/share/hal/fdi" ];
|
|
|
|
paths = cfg.packages;
|
|
|
|
};
|
2007-06-09 21:05:04 +01:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
in
|
2007-06-09 21:05:04 +01:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
{
|
2008-11-23 01:28:52 +00:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.hal = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = true;
|
2009-08-11 22:16:59 +01:00
|
|
|
description = ''
|
2009-08-10 19:25:09 +01:00
|
|
|
Whether to start the HAL daemon.
|
2009-08-11 22:16:59 +01:00
|
|
|
'';
|
2009-08-10 19:25:09 +01:00
|
|
|
};
|
2008-11-23 01:28:52 +00:00
|
|
|
|
2009-08-11 22:16:59 +01:00
|
|
|
packages = mkOption {
|
2009-08-10 19:25:09 +01:00
|
|
|
default = [];
|
2009-08-11 22:16:59 +01:00
|
|
|
description = ''
|
|
|
|
Packages containing additional HAL configuration data.
|
|
|
|
'';
|
2009-08-10 19:25:09 +01:00
|
|
|
};
|
2008-11-23 01:28:52 +00:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2008-11-23 01:28:52 +00:00
|
|
|
|
2009-05-20 16:43:43 +01:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2008-11-23 01:28:52 +00:00
|
|
|
|
2009-09-26 21:37:48 +01:00
|
|
|
# !!! move pmutils somewhere else
|
|
|
|
environment.systemPackages = [hal pkgs.pmutils];
|
2007-06-09 21:05:04 +01:00
|
|
|
|
2009-08-11 22:16:59 +01:00
|
|
|
services.hal.packages = [hal pkgs.hal_info];
|
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
users.extraUsers = singleton
|
|
|
|
{ name = "haldaemon";
|
|
|
|
uid = config.ids.uids.haldaemon;
|
|
|
|
description = "HAL daemon user";
|
|
|
|
};
|
2007-06-09 21:05:04 +01:00
|
|
|
|
2009-08-10 19:25:09 +01:00
|
|
|
users.extraGroups = singleton
|
|
|
|
{ name = "haldaemon";
|
|
|
|
gid = config.ids.gids.haldaemon;
|
|
|
|
};
|
2007-06-09 21:05:04 +01:00
|
|
|
|
2009-10-12 19:09:34 +01:00
|
|
|
jobs.hal =
|
2009-10-12 18:27:57 +01:00
|
|
|
{ description = "HAL daemon";
|
2009-08-10 19:25:09 +01:00
|
|
|
|
|
|
|
# !!! TODO: make sure that HAL starts after acpid,
|
|
|
|
# otherwise hald-addon-acpi will grab /proc/acpi/event.
|
|
|
|
startOn = if config.powerManagement.enable then "acpid" else "dbus";
|
|
|
|
stopOn = "shutdown";
|
|
|
|
|
|
|
|
environment =
|
2009-09-26 21:37:48 +01:00
|
|
|
{ # !!! HACK? These environment variables manipulated inside
|
|
|
|
# 'src'/hald/mmap_cache.c are used for testing the daemon.
|
|
|
|
HAL_FDI_SOURCE_PREPROBE = "${fdi}/share/hal/fdi/preprobe";
|
2009-08-11 22:16:59 +01:00
|
|
|
HAL_FDI_SOURCE_INFORMATION = "${fdi}/share/hal/fdi/information";
|
|
|
|
HAL_FDI_SOURCE_POLICY = "${fdi}/share/hal/fdi/policy";
|
2009-09-26 21:37:48 +01:00
|
|
|
|
|
|
|
# Stuff needed by the shell scripts run by HAL (in particular pm-utils).
|
|
|
|
HALD_RUNNER_PATH = concatStringsSep ":"
|
|
|
|
[ "${pkgs.coreutils}/bin"
|
|
|
|
"${pkgs.gnugrep}/bin"
|
|
|
|
"${pkgs.dbus.tools}/bin"
|
|
|
|
"${pkgs.procps}/bin"
|
|
|
|
"${pkgs.procps}/sbin"
|
|
|
|
"${config.system.sbin.modprobe}/sbin"
|
|
|
|
"${pkgs.module_init_tools}/bin"
|
|
|
|
"${pkgs.module_init_tools}/sbin"
|
|
|
|
"${pkgs.kbd}/bin"
|
|
|
|
];
|
2009-08-10 19:25:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
preStart =
|
|
|
|
''
|
|
|
|
mkdir -m 0755 -p /var/cache/hald
|
2009-09-09 22:22:00 +01:00
|
|
|
mkdir -m 0755 -p /var/run/hald
|
2009-08-10 19:25:09 +01:00
|
|
|
|
|
|
|
rm -f /var/cache/hald/fdi-cache
|
2009-09-09 22:22:00 +01:00
|
|
|
|
2009-10-21 10:41:32 +01:00
|
|
|
# For some weird reason HAL sometimes fails to start at
|
|
|
|
# boot time, which seems to be timing-dependent. As a
|
|
|
|
# temporary workaround, sleep for a while here.
|
|
|
|
sleep 2
|
|
|
|
|
2009-09-09 22:22:00 +01:00
|
|
|
# !!! Hack: start the daemon here to make sure it's
|
|
|
|
# running when the Upstart job reaches the "running"
|
|
|
|
# state. Should be fixable in Upstart 0.6.
|
2009-09-26 21:37:48 +01:00
|
|
|
${hal}/sbin/hald --use-syslog # --verbose=yes
|
2009-08-10 19:25:09 +01:00
|
|
|
'';
|
|
|
|
|
2009-09-09 22:22:00 +01:00
|
|
|
postStop =
|
|
|
|
''
|
2009-10-21 10:41:32 +01:00
|
|
|
pid=$(cat /var/run/hald/pid || true)
|
2009-09-09 22:22:00 +01:00
|
|
|
test -n "$pid" && kill "$pid"
|
|
|
|
'';
|
2009-08-10 19:25:09 +01:00
|
|
|
};
|
2008-03-22 16:05:01 +00:00
|
|
|
|
2009-08-10 20:05:20 +01:00
|
|
|
services.udev.packages = [hal];
|
2009-08-10 19:25:09 +01:00
|
|
|
|
|
|
|
services.dbus.enable = true;
|
|
|
|
services.dbus.packages = [hal];
|
|
|
|
|
2008-11-23 01:28:52 +00:00
|
|
|
};
|
2009-08-10 19:25:09 +01:00
|
|
|
|
|
|
|
}
|