2008-11-23 01:28:52 +00:00
|
|
|
# HAL daemon.
|
2009-10-12 17:27:57 +00:00
|
|
|
{ config, pkgs, ... }:
|
2007-06-09 20:05:04 +00:00
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
with pkgs.lib;
|
2008-11-23 01:28:52 +00:00
|
|
|
|
|
|
|
let
|
2009-08-10 18:25:09 +00:00
|
|
|
|
2008-11-23 01:28:52 +00:00
|
|
|
cfg = config.services.hal;
|
|
|
|
|
|
|
|
inherit (pkgs) hal;
|
|
|
|
|
2009-08-11 21:16:59 +00:00
|
|
|
fdi = pkgs.buildEnv {
|
|
|
|
name = "hal-fdi";
|
|
|
|
pathsToLink = [ "/share/hal/fdi" ];
|
|
|
|
paths = cfg.packages;
|
|
|
|
};
|
2007-06-09 20:05:04 +00:00
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
in
|
2007-06-09 20:05:04 +00:00
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
{
|
2008-11-23 01:28:52 +00:00
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.hal = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = true;
|
2009-08-11 21:16:59 +00:00
|
|
|
description = ''
|
2009-08-10 18:25:09 +00:00
|
|
|
Whether to start the HAL daemon.
|
2009-08-11 21:16:59 +00:00
|
|
|
'';
|
2009-08-10 18:25:09 +00:00
|
|
|
};
|
2008-11-23 01:28:52 +00:00
|
|
|
|
2009-08-11 21:16:59 +00:00
|
|
|
packages = mkOption {
|
2009-08-10 18:25:09 +00:00
|
|
|
default = [];
|
2009-08-11 21:16:59 +00:00
|
|
|
description = ''
|
|
|
|
Packages containing additional HAL configuration data.
|
|
|
|
'';
|
2009-08-10 18:25:09 +00:00
|
|
|
};
|
2008-11-23 01:28:52 +00:00
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2008-11-23 01:28:52 +00:00
|
|
|
|
2009-05-20 15:43:43 +00:00
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2008-11-23 01:28:52 +00:00
|
|
|
|
2009-09-26 20:37:48 +00:00
|
|
|
# !!! move pmutils somewhere else
|
|
|
|
environment.systemPackages = [hal pkgs.pmutils];
|
2007-06-09 20:05:04 +00:00
|
|
|
|
2009-08-11 21:16:59 +00:00
|
|
|
services.hal.packages = [hal pkgs.hal_info];
|
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
users.extraUsers = singleton
|
|
|
|
{ name = "haldaemon";
|
|
|
|
uid = config.ids.uids.haldaemon;
|
|
|
|
description = "HAL daemon user";
|
|
|
|
};
|
2007-06-09 20:05:04 +00:00
|
|
|
|
2009-08-10 18:25:09 +00:00
|
|
|
users.extraGroups = singleton
|
|
|
|
{ name = "haldaemon";
|
|
|
|
gid = config.ids.gids.haldaemon;
|
|
|
|
};
|
2007-06-09 20:05:04 +00:00
|
|
|
|
2009-10-12 18:09:34 +00:00
|
|
|
jobs.hal =
|
2009-10-12 17:27:57 +00:00
|
|
|
{ description = "HAL daemon";
|
2009-08-10 18:25:09 +00: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 20:37:48 +00: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 21:16:59 +00:00
|
|
|
HAL_FDI_SOURCE_INFORMATION = "${fdi}/share/hal/fdi/information";
|
|
|
|
HAL_FDI_SOURCE_POLICY = "${fdi}/share/hal/fdi/policy";
|
2009-09-26 20:37:48 +00: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 18:25:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
preStart =
|
|
|
|
''
|
|
|
|
mkdir -m 0755 -p /var/cache/hald
|
2009-09-09 21:22:00 +00:00
|
|
|
mkdir -m 0755 -p /var/run/hald
|
2009-08-10 18:25:09 +00:00
|
|
|
|
|
|
|
rm -f /var/cache/hald/fdi-cache
|
2009-09-09 21:22:00 +00: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 20:37:48 +00:00
|
|
|
${hal}/sbin/hald --use-syslog # --verbose=yes
|
2009-08-10 18:25:09 +00:00
|
|
|
'';
|
|
|
|
|
2009-09-09 21:22:00 +00:00
|
|
|
postStop =
|
|
|
|
''
|
|
|
|
pid=$(cat /var/run/hald/pid)
|
|
|
|
test -n "$pid" && kill "$pid"
|
|
|
|
'';
|
2009-08-10 18:25:09 +00:00
|
|
|
};
|
2008-03-22 16:05:01 +00:00
|
|
|
|
2009-08-10 19:05:20 +00:00
|
|
|
services.udev.packages = [hal];
|
2009-08-10 18:25:09 +00:00
|
|
|
|
|
|
|
services.dbus.enable = true;
|
|
|
|
services.dbus.packages = [hal];
|
|
|
|
|
2008-11-23 01:28:52 +00:00
|
|
|
};
|
2009-08-10 18:25:09 +00:00
|
|
|
|
|
|
|
}
|