1
0
Fork 0
nix-configuration/modules/nixos/ui/audio/default.nix

51 lines
1.2 KiB
Nix
Raw Normal View History

# Enables audio support.
{
pkgs,
lib,
config,
...
}:
2024-02-29 14:53:34 +00:00
let
cfg = config.aux.system.ui.audio;
2024-02-29 14:53:34 +00:00
in
{
options = {
aux.system.ui.audio = {
2024-09-08 15:58:56 +00: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-02-29 14:53:34 +00:00
config = lib.mkIf cfg.enable {
# Enable sound with pipewire.
security.rtkit.enable = true;
hardware.pulseaudio = {
enable = false;
package = pkgs.pulseaudioFull; # Enable extra audio codecs
};
2024-02-29 14:53:34 +00:00
services.pipewire = {
enable = true;
pulse.enable = true;
jack.enable = true;
2024-09-08 15:58:56 +00:00
alsa = {
enable = true;
support32Bit = true;
};
# Reduce audio latency per https://wiki.nixos.org/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;
};
};
};
};
};
2024-04-23 15:58:20 +00:00
}