mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-18 03:34:58 +00:00
903e92bde6
is "ready". This prevents ugly race conditions, e.g. HAL failing to start because dbus hasn't finished starting yet. * Support post-start scripts. These are executed after the job's main process has started but before the job's "started" event is emitted. For instance, the udev job uses this to perform "udevadm trigger / settle" to create all devices. Previously this had to be done in the pre-start script, so the daemon had to started in the pre-start script as well. svn path=/nixos/branches/upstart-0.6/; revision=18211
119 lines
2.8 KiB
Nix
119 lines
2.8 KiB
Nix
# HAL daemon.
|
|
{ config, pkgs, ... }:
|
|
|
|
with pkgs.lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.hal;
|
|
|
|
inherit (pkgs) hal;
|
|
|
|
fdi = pkgs.buildEnv {
|
|
name = "hal-fdi";
|
|
pathsToLink = [ "/share/hal/fdi" ];
|
|
paths = cfg.packages;
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.hal = {
|
|
|
|
enable = mkOption {
|
|
default = true;
|
|
description = ''
|
|
Whether to start the HAL daemon.
|
|
'';
|
|
};
|
|
|
|
packages = mkOption {
|
|
default = [];
|
|
description = ''
|
|
Packages containing additional HAL configuration data.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
# !!! move pmutils somewhere else
|
|
environment.systemPackages = [hal pkgs.pmutils];
|
|
|
|
services.hal.packages = [hal pkgs.hal_info];
|
|
|
|
users.extraUsers = singleton
|
|
{ name = "haldaemon";
|
|
uid = config.ids.uids.haldaemon;
|
|
description = "HAL daemon user";
|
|
};
|
|
|
|
users.extraGroups = singleton
|
|
{ name = "haldaemon";
|
|
gid = config.ids.gids.haldaemon;
|
|
};
|
|
|
|
jobs.hal =
|
|
{ description = "HAL daemon";
|
|
|
|
# !!! TODO: make sure that HAL starts after acpid,
|
|
# otherwise hald-addon-acpi will grab /proc/acpi/event.
|
|
startOn = if config.powerManagement.enable then "started acpid" else "started dbus";
|
|
stopOn = "shutdown";
|
|
|
|
environment =
|
|
{ # !!! 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";
|
|
HAL_FDI_SOURCE_INFORMATION = "${fdi}/share/hal/fdi/information";
|
|
HAL_FDI_SOURCE_POLICY = "${fdi}/share/hal/fdi/policy";
|
|
|
|
# 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"
|
|
];
|
|
};
|
|
|
|
preStart =
|
|
''
|
|
mkdir -m 0755 -p /var/cache/hald
|
|
mkdir -m 0755 -p /var/run/hald
|
|
|
|
rm -f /var/cache/hald/fdi-cache
|
|
'';
|
|
|
|
daemonType = "fork";
|
|
|
|
# The `PATH=' works around a bug in HAL: it concatenates
|
|
# its libexec directory to $PATH, but using a 512-byte
|
|
# buffer. So if $PATH is too long it fails.
|
|
script = "PATH= exec ${hal}/sbin/hald --use-syslog";
|
|
};
|
|
|
|
services.udev.packages = [hal];
|
|
|
|
services.dbus.enable = true;
|
|
services.dbus.packages = [hal];
|
|
|
|
};
|
|
|
|
} |