Convert "alsa" upstart-job to the fix-style.
svn path=/nixos/branches/fix-style/; revision=13379
This commit is contained in:
parent
9c0eef3bae
commit
157bb2b71a
@ -2781,18 +2781,6 @@ root ALL=(ALL) SETENV: ALL
|
||||
};
|
||||
|
||||
|
||||
sound = {
|
||||
|
||||
enable = mkOption {
|
||||
default = true;
|
||||
description = "
|
||||
Whether to enable ALSA sound.
|
||||
";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
i18n = {
|
||||
|
||||
defaultLocale = mkOption {
|
||||
@ -2943,5 +2931,8 @@ root ALL=(ALL) SETENV: ALL
|
||||
(import ../upstart-jobs/disnix.nix)
|
||||
(import ../upstart-jobs/cron.nix)
|
||||
(import ../upstart-jobs/cron/locate.nix)
|
||||
|
||||
# sound
|
||||
(import ../upstart-jobs/alsa.nix)
|
||||
];
|
||||
}
|
||||
|
@ -1,50 +1,92 @@
|
||||
{modprobe, alsaUtils}:
|
||||
# ALSA sound support.
|
||||
{pkgs, config}:
|
||||
|
||||
###### interface
|
||||
let
|
||||
inherit (pkgs.lib) mkOption;
|
||||
|
||||
options = {
|
||||
sound = {
|
||||
|
||||
enable = mkOption {
|
||||
default = true;
|
||||
description = "
|
||||
Whether to enable ALSA sound.
|
||||
";
|
||||
merge = pkgs.lib.mergeEnableOption;
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
###### implementation
|
||||
let
|
||||
ifEnable = pkgs.lib.ifEnable config.sound.enable;
|
||||
|
||||
# dangerous !
|
||||
modprobe = config.system.sbin.modprobe;
|
||||
inherit (pkgs) alsaUtils;
|
||||
|
||||
soundState = "/var/lib/alsa/asound.state";
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
name = "alsa";
|
||||
|
||||
extraPath = [alsaUtils];
|
||||
|
||||
# Alsalib seems to require the existence of this group, even if it's
|
||||
# not used (e.g., doesn't own any devices).
|
||||
groups = [
|
||||
{ name = "audio";
|
||||
gid = (import ../system/ids.nix).gids.audio;
|
||||
}
|
||||
group = {
|
||||
name = "audio";
|
||||
gid = (import ../system/ids.nix).gids.audio;
|
||||
};
|
||||
|
||||
job = {
|
||||
name = "alsa";
|
||||
|
||||
job = ''
|
||||
start on udev
|
||||
stop on shutdown
|
||||
|
||||
start script
|
||||
|
||||
mkdir -m 0755 -p $(dirname ${soundState})
|
||||
|
||||
# Load some additional modules.
|
||||
for mod in snd_pcm_oss; do
|
||||
${modprobe}/sbin/modprobe $mod || true
|
||||
done
|
||||
|
||||
# Restore the sound state.
|
||||
${alsaUtils}/sbin/alsactl -f ${soundState} restore
|
||||
|
||||
end script
|
||||
|
||||
respawn sleep 1000000 # !!! hack
|
||||
|
||||
stop script
|
||||
|
||||
# Save the sound state.
|
||||
${alsaUtils}/sbin/alsactl -f ${soundState} store
|
||||
|
||||
end script
|
||||
'';
|
||||
};
|
||||
in
|
||||
|
||||
{
|
||||
require = [
|
||||
(import ../upstart-jobs/default.nix) # config.services.extraJobs
|
||||
# (import ../system/user.nix) # users.*
|
||||
# (import ?) # config.environment.extraPackages
|
||||
options
|
||||
];
|
||||
|
||||
job = ''
|
||||
start on udev
|
||||
stop on shutdown
|
||||
environment = {
|
||||
extraPackages = ifEnable [alsaUtils];
|
||||
};
|
||||
|
||||
start script
|
||||
|
||||
mkdir -m 0755 -p $(dirname ${soundState})
|
||||
|
||||
# Load some additional modules.
|
||||
for mod in snd_pcm_oss; do
|
||||
${modprobe}/sbin/modprobe $mod || true
|
||||
done
|
||||
|
||||
# Restore the sound state.
|
||||
${alsaUtils}/sbin/alsactl -f ${soundState} restore
|
||||
|
||||
end script
|
||||
|
||||
respawn sleep 1000000 # !!! hack
|
||||
|
||||
stop script
|
||||
|
||||
# Save the sound state.
|
||||
${alsaUtils}/sbin/alsactl -f ${soundState} store
|
||||
|
||||
end script
|
||||
'';
|
||||
users = {
|
||||
extraGroups = ifEnable [group];
|
||||
};
|
||||
|
||||
services = {
|
||||
extraJobs = ifEnable [job];
|
||||
};
|
||||
}
|
||||
|
@ -374,13 +374,6 @@ let
|
||||
inherit (config.services.bitlbee) portNumber interface;
|
||||
})
|
||||
|
||||
# ALSA sound support.
|
||||
++ optional config.sound.enable
|
||||
(import ../upstart-jobs/alsa.nix {
|
||||
inherit modprobe;
|
||||
inherit (pkgs) alsaUtils;
|
||||
})
|
||||
|
||||
# Postfix mail server.
|
||||
++ optional config.services.postfix.enable
|
||||
(import ../upstart-jobs/postfix.nix {
|
||||
|
Loading…
Reference in New Issue
Block a user