2011-07-26 02:51:56 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
2011-07-26 18:35:47 +01:00
|
|
|
let cfg = config.hardware.pulseaudio; in
|
|
|
|
|
2011-07-26 02:51:56 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
hardware.pulseaudio.enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable the PulseAudio sound server.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-07-26 18:35:47 +01:00
|
|
|
config = mkIf cfg.enable {
|
2011-07-26 02:51:56 +01:00
|
|
|
|
|
|
|
environment.systemPackages =
|
2011-07-26 14:00:43 +01:00
|
|
|
[ pkgs.pulseaudio ];
|
2011-07-26 02:51:56 +01:00
|
|
|
|
2011-07-26 18:35:47 +01:00
|
|
|
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
|
2011-07-26 02:51:56 +01:00
|
|
|
[ # 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"
|
|
|
|
''
|
2011-07-26 14:00:43 +01:00
|
|
|
pcm_type.pulse {
|
|
|
|
lib ${pkgs.alsaPlugins}/lib/alsa-lib/libasound_module_pcm_pulse.so
|
|
|
|
}
|
|
|
|
|
2011-07-26 02:51:56 +01:00
|
|
|
pcm.!default {
|
|
|
|
type pulse
|
|
|
|
hint.description "Default Audio Device (via PulseAudio)"
|
|
|
|
}
|
2011-07-26 14:00:43 +01:00
|
|
|
|
|
|
|
ctl_type.pulse {
|
|
|
|
lib ${pkgs.alsaPlugins}/lib/alsa-lib/libasound_module_ctl_pulse.so
|
|
|
|
}
|
|
|
|
|
2011-07-26 02:51:56 +01:00
|
|
|
ctl.!default {
|
|
|
|
type pulse
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
}
|
2011-07-26 18:35:47 +01:00
|
|
|
|
|
|
|
{ target = "pulse/default.pa";
|
|
|
|
source = "${pkgs.pulseaudio}/etc/pulse/default.pa";
|
|
|
|
}
|
|
|
|
|
|
|
|
{ target = "pulse/system.pa";
|
|
|
|
source = "${pkgs.pulseaudio}/etc/pulse/system.pa";
|
|
|
|
}
|
|
|
|
|
|
|
|
]);
|
2011-07-26 02:51:56 +01:00
|
|
|
|
2011-07-26 15:14:10 +01:00
|
|
|
# Allow PulseAudio to get realtime priority using rtkit.
|
|
|
|
security.rtkit.enable = true;
|
|
|
|
|
2011-07-26 02:51:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|