nixpkgs-suyu/modules/services/audio/alsa.nix
Eelco Dolstra 83a9bf9a6a * Change all the startOn / stopOn attributes to the Upstart 0.6 syntax
(e.g., startOn = "started foo" instead of startOn = "foo").

svn path=/nixos/branches/upstart-0.6/; revision=18230
2009-11-06 22:19:17 +00:00

73 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;
};
};
};
###### implementation
config = mkIf config.sound.enable {
environment.systemPackages = [alsaUtils];
users.extraGroups = singleton
{ # Alsalib seems to require the existence of this group, even
# if it's not used (e.g., doesn't own any devices).
name = "audio";
gid = config.ids.gids.audio;
};
jobs.alsa =
{ startOn = "started udev";
preStart =
''
mkdir -m 0755 -p $(dirname ${soundState})
# Load some additional modules.
for mod in snd_pcm_oss; do
${config.system.sbin.modprobe}/sbin/modprobe $mod || true
done
# Restore the sound state.
${alsaUtils}/sbin/alsactl -f ${soundState} restore
'';
postStop =
''
# Save the sound state.
${alsaUtils}/sbin/alsactl -f ${soundState} store
'';
};
};
}