2024-06-24 11:38:28 -04:00
|
|
|
# Enables audio support.
|
2024-05-07 18:02:59 -04:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}:
|
2024-02-29 09:53:34 -05:00
|
|
|
|
|
|
|
let
|
2024-06-24 11:38:28 -04:00
|
|
|
cfg = config.aux.system.ui.audio;
|
2024-02-29 09:53:34 -05:00
|
|
|
in
|
|
|
|
{
|
2024-05-07 18:02:59 -04:00
|
|
|
options = {
|
2024-06-24 11:38:28 -04:00
|
|
|
aux.system.ui.audio = {
|
2024-09-08 11:58:56 -04:00
|
|
|
enable = lib.mkEnableOption "Enables audio.";
|
|
|
|
enableLowLatency = lib.mkEnableOption "Enables low-latency audio (may cause crackling) per https://wiki.nixos.org/wiki/PipeWire#Low-latency_setup.";
|
2024-05-07 18:02:59 -04:00
|
|
|
};
|
|
|
|
};
|
2024-02-29 09:53:34 -05:00
|
|
|
|
2024-06-24 11:38:28 -04:00
|
|
|
config = lib.mkIf cfg.enable {
|
2024-05-07 18:02:59 -04:00
|
|
|
# Enable sound with pipewire.
|
|
|
|
security.rtkit.enable = true;
|
|
|
|
hardware.pulseaudio = {
|
|
|
|
enable = false;
|
|
|
|
package = pkgs.pulseaudioFull; # Enable extra audio codecs
|
|
|
|
};
|
2024-02-29 09:53:34 -05:00
|
|
|
|
2024-05-07 18:02:59 -04:00
|
|
|
services.pipewire = {
|
|
|
|
enable = true;
|
|
|
|
pulse.enable = true;
|
|
|
|
jack.enable = true;
|
2024-09-08 11:58:56 -04:00
|
|
|
alsa = {
|
|
|
|
enable = true;
|
|
|
|
support32Bit = true;
|
|
|
|
};
|
2024-05-05 19:51:37 -04:00
|
|
|
|
2024-07-13 13:34:59 -04:00
|
|
|
# Reduce audio latency per https://wiki.nixos.org/wiki/PipeWire#Low-latency_setup
|
2024-06-24 11:38:28 -04:00
|
|
|
extraConfig.pipewire = lib.mkIf cfg.enableLowLatency {
|
2024-05-07 18:02:59 -04:00
|
|
|
"92-low-latency.conf" = {
|
|
|
|
"context.properties" = {
|
|
|
|
"default.clock.rate" = 48000;
|
|
|
|
"default.clock.quantum" = 32;
|
|
|
|
"default.clock.min-quantum" = 32;
|
|
|
|
"default.clock.max-quantum" = 32;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-04-23 11:58:20 -04:00
|
|
|
}
|