2008-11-23 01:29:05 +00:00
|
|
|
# ALSA sound support.
|
2009-10-12 18:27:57 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
2007-03-01 00:36:00 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2009-07-16 16:01:56 +01:00
|
|
|
inherit (pkgs) alsaUtils;
|
|
|
|
|
|
|
|
soundState = "/var/lib/alsa/asound.state";
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2008-11-23 01:29:05 +00:00
|
|
|
options = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2008-11-23 01:29:05 +00:00
|
|
|
sound = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = true;
|
2009-07-16 16:01:56 +01:00
|
|
|
description = ''
|
2008-11-23 01:29:05 +00:00
|
|
|
Whether to enable ALSA sound.
|
2009-07-16 16:01:56 +01:00
|
|
|
'';
|
2009-10-12 18:27:57 +01:00
|
|
|
merge = mergeEnableOption;
|
2008-11-23 01:29:05 +00:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2010-03-03 14:01:13 +00:00
|
|
|
enableOSSEmulation = mkOption {
|
|
|
|
default = true;
|
2012-08-17 16:00:14 +01:00
|
|
|
description = ''
|
|
|
|
Whether to enable ALSA OSS emulation (with certain cards sound mixing may not work!).
|
|
|
|
'';
|
2010-03-03 14:01:13 +00:00
|
|
|
};
|
2007-03-01 00:36:00 +00:00
|
|
|
|
2008-11-23 01:29:05 +00:00
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2008-11-23 01:29:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-07-16 16:01:56 +01:00
|
|
|
###### implementation
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-07-16 16:01:56 +01:00
|
|
|
config = mkIf config.sound.enable {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2011-11-04 17:40:00 +00:00
|
|
|
environment.systemPackages = [ alsaUtils ];
|
2008-11-23 01:29:05 +00:00
|
|
|
|
2012-10-02 16:09:54 +01:00
|
|
|
# ALSA provides a udev rule for restoring volume settings.
|
|
|
|
services.udev.packages = [ alsaUtils ];
|
2008-11-23 01:29:05 +00:00
|
|
|
|
2012-10-02 16:09:54 +01:00
|
|
|
boot.kernelModules = optional config.sound.enableOSSEmulation "snd_pcm_oss";
|
2007-03-01 00:36:00 +00:00
|
|
|
|
2013-01-16 11:33:18 +00:00
|
|
|
systemd.services."alsa-store" =
|
2012-10-02 16:09:54 +01:00
|
|
|
{ description = "Store Sound Card State";
|
|
|
|
wantedBy = [ "shutdown.target" ];
|
|
|
|
before = [ "shutdown.target" ];
|
|
|
|
unitConfig.DefaultDependencies = "no";
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
serviceConfig.ExecStart = "${alsaUtils}/sbin/alsactl store --ignore";
|
2013-03-13 23:58:35 +00:00
|
|
|
serviceConfig.ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p /var/lib/alsa";
|
2009-07-16 16:01:56 +01:00
|
|
|
};
|
2012-10-09 20:14:32 +01:00
|
|
|
|
2008-11-23 01:29:05 +00:00
|
|
|
};
|
2007-03-01 00:36:00 +00:00
|
|
|
|
|
|
|
}
|