templates/system/modules/ui/audio.nix
Andre 54f4de49f4
Some checks are pending
Code Check / Run nixfmt and statix (push) Waiting to run
chore: Change template namespace to 'aux.system'
2024-06-16 12:53:16 -04:00

52 lines
1.2 KiB
Nix

# Enables audio support.
{
pkgs,
lib,
config,
...
}:
let
cfg = config.aux.system.ui.audio;
in
{
options = {
aux.system.ui.audio = {
enable = lib.mkEnableOption (lib.mdDoc "Enables audio.");
enableLowLatency = lib.mkEnableOption (
lib.mdDoc "Enables low-latency audio (may cause crackling) per https://nixos.wiki/wiki/PipeWire#Low-latency_setup."
);
};
};
config = lib.mkIf cfg.enable {
# Enable sound with pipewire.
sound.enable = true;
security.rtkit.enable = true;
hardware.pulseaudio = {
enable = false;
package = pkgs.pulseaudioFull; # Enable extra audio codecs
};
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
# Reduce audio latency per https://nixos.wiki/wiki/PipeWire#Low-latency_setup
extraConfig.pipewire = lib.mkIf cfg.enableLowLatency {
"92-low-latency.conf" = {
"context.properties" = {
"default.clock.rate" = 48000;
"default.clock.quantum" = 32;
"default.clock.min-quantum" = 32;
"default.clock.max-quantum" = 32;
};
};
};
};
};
}