2024-05-07 22:02:59 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}:
|
2024-02-29 14:53:34 +00:00
|
|
|
|
|
|
|
let
|
2024-05-07 22:02:59 +00:00
|
|
|
cfg = config.host.ui.audio;
|
2024-02-29 14:53:34 +00:00
|
|
|
in
|
|
|
|
with lib;
|
|
|
|
{
|
2024-05-07 22:02:59 +00:00
|
|
|
options = {
|
|
|
|
host.ui.audio = {
|
|
|
|
enable = mkEnableOption (mdDoc "Enables audio");
|
|
|
|
enableLowLatency = mkEnableOption (
|
|
|
|
mdDoc "Enables low-latency audio (may cause crackling) per https://nixos.wiki/wiki/PipeWire#Low-latency_setup "
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
2024-02-29 14:53:34 +00:00
|
|
|
|
2024-05-07 22:02:59 +00:00
|
|
|
config = 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
|
|
|
|
};
|
2024-02-29 14:53:34 +00:00
|
|
|
|
2024-05-07 22:02:59 +00:00
|
|
|
services.pipewire = {
|
|
|
|
enable = true;
|
|
|
|
alsa.enable = true;
|
|
|
|
alsa.support32Bit = true;
|
|
|
|
pulse.enable = true;
|
|
|
|
jack.enable = true;
|
2024-05-05 23:51:37 +00:00
|
|
|
|
2024-05-07 22:02:59 +00:00
|
|
|
# Reduce audio latency per https://nixos.wiki/wiki/PipeWire#Low-latency_setup
|
|
|
|
extraConfig.pipewire = 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-03-26 19:50:32 +00:00
|
|
|
|
2024-05-07 22:02:59 +00:00
|
|
|
services.flatpak.packages = mkIf config.host.ui.flatpak.enable [ "com.github.wwmm.easyeffects" ];
|
|
|
|
};
|
2024-04-23 15:58:20 +00:00
|
|
|
}
|