nixpkgs/modules/services/audio/alsa.nix
Eelco Dolstra 3ad370ae0a Merge remote-tracking branch 'origin/master' into systemd
Conflicts:
	modules/misc/ids.nix
	modules/services/mail/postfix.nix
	modules/services/system/nscd.nix
	modules/services/x11/desktop-managers/xfce.nix
	modules/system/boot/stage-1.nix
2012-09-28 11:35:27 -04:00

74 lines
1.3 KiB
Nix

# ALSA sound support.
{ config, pkgs, ... }:
with pkgs.lib;
let
inherit (pkgs) alsaUtils;
soundState = "/var/lib/alsa/asound.state";
in
{
###### interface
options = {
sound = {
enable = mkOption {
default = true;
description = ''
Whether to enable ALSA sound.
'';
merge = mergeEnableOption;
};
enableOSSEmulation = mkOption {
default = true;
description = ''
Whether to enable ALSA OSS emulation (with certain cards sound mixing may not work!).
'';
};
};
};
###### implementation
config = mkIf config.sound.enable {
environment.systemPackages = [ alsaUtils ];
boot.kernelModules = optional config.sound.enableOSSEmulation "snd_pcm_oss";
jobs.alsa =
{ description = "ALSA Volume Settings";
startOn = "stopped udevtrigger";
preStart =
''
mkdir -m 0755 -p $(dirname ${soundState})
# Try to restore the sound state.
${alsaUtils}/sbin/alsactl --ignore init || true
${alsaUtils}/sbin/alsactl --ignore -f ${soundState} restore || true
'';
postStop =
''
# Save the sound state.
${alsaUtils}/sbin/alsactl --ignore -f ${soundState} store
'';
};
};
}