nixpkgs/modules/config/pulseaudio.nix
Eelco Dolstra 77c85b1de7 * Install /etc/pulse/default.pa and /etc/pulse/system.pa.
* If PulseAudio is disabled in the NixOS config, then disable
  autospawning of the PulseAudio server in /etc/pulse/client.conf.

svn path=/nixos/trunk/; revision=27966
2011-07-26 17:35:47 +00:00

79 lines
1.9 KiB
Nix

{ config, pkgs, ... }:
with pkgs.lib;
let cfg = config.hardware.pulseaudio; in
{
options = {
hardware.pulseaudio.enable = mkOption {
default = false;
description = ''
Whether to enable the PulseAudio sound server.
'';
};
};
config = mkIf cfg.enable {
environment.systemPackages =
[ pkgs.pulseaudio ];
environment.etc = mkAlways (
[ # Create pulse/client.conf even if PulseAudio is disabled so
# that we can disable the autospawn feature in programs that
# are built with PulseAudio support (like KDE).
{ target = "pulse/client.conf";
source = pkgs.writeText "client.conf"
''
autospawn=${if cfg.enable then "yes" else "no"}
'';
}
] ++ optionals cfg.enable
[ # Write an /etc/asound.conf that causes all ALSA applications to
# be re-routed to the PulseAudio server through ALSA's Pulse
# plugin.
{ target = "asound.conf";
source = pkgs.writeText "asound.conf"
''
pcm_type.pulse {
lib ${pkgs.alsaPlugins}/lib/alsa-lib/libasound_module_pcm_pulse.so
}
pcm.!default {
type pulse
hint.description "Default Audio Device (via PulseAudio)"
}
ctl_type.pulse {
lib ${pkgs.alsaPlugins}/lib/alsa-lib/libasound_module_ctl_pulse.so
}
ctl.!default {
type pulse
}
'';
}
{ target = "pulse/default.pa";
source = "${pkgs.pulseaudio}/etc/pulse/default.pa";
}
{ target = "pulse/system.pa";
source = "${pkgs.pulseaudio}/etc/pulse/system.pa";
}
]);
# Allow PulseAudio to get realtime priority using rtkit.
security.rtkit.enable = true;
};
}