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 = {
|
i18n = {
|
||||||
|
|
||||||
defaultLocale = mkOption {
|
defaultLocale = mkOption {
|
||||||
@ -2943,5 +2931,8 @@ root ALL=(ALL) SETENV: ALL
|
|||||||
(import ../upstart-jobs/disnix.nix)
|
(import ../upstart-jobs/disnix.nix)
|
||||||
(import ../upstart-jobs/cron.nix)
|
(import ../upstart-jobs/cron.nix)
|
||||||
(import ../upstart-jobs/cron/locate.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
|
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";
|
soundState = "/var/lib/alsa/asound.state";
|
||||||
|
|
||||||
|
# Alsalib seems to require the existence of this group, even if it's
|
||||||
|
# not used (e.g., doesn't own any devices).
|
||||||
|
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
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "alsa";
|
require = [
|
||||||
|
(import ../upstart-jobs/default.nix) # config.services.extraJobs
|
||||||
extraPath = [alsaUtils];
|
# (import ../system/user.nix) # users.*
|
||||||
|
# (import ?) # config.environment.extraPackages
|
||||||
# Alsalib seems to require the existence of this group, even if it's
|
options
|
||||||
# not used (e.g., doesn't own any devices).
|
|
||||||
groups = [
|
|
||||||
{ name = "audio";
|
|
||||||
gid = (import ../system/ids.nix).gids.audio;
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
job = ''
|
environment = {
|
||||||
start on udev
|
extraPackages = ifEnable [alsaUtils];
|
||||||
stop on shutdown
|
};
|
||||||
|
|
||||||
start script
|
users = {
|
||||||
|
extraGroups = ifEnable [group];
|
||||||
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
|
|
||||||
'';
|
|
||||||
|
|
||||||
|
services = {
|
||||||
|
extraJobs = ifEnable [job];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -374,13 +374,6 @@ let
|
|||||||
inherit (config.services.bitlbee) portNumber interface;
|
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.
|
# Postfix mail server.
|
||||||
++ optional config.services.postfix.enable
|
++ optional config.services.postfix.enable
|
||||||
(import ../upstart-jobs/postfix.nix {
|
(import ../upstart-jobs/postfix.nix {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user