2023-11-17 07:17:12 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
2023-12-17 12:43:24 +00:00
|
|
|
cfg = config.myFlake.hardware.components.audio;
|
2023-11-17 07:17:12 +00:00
|
|
|
in {
|
|
|
|
options = {
|
2023-12-17 12:43:24 +00:00
|
|
|
myFlake.hardware.components.audio.enable = lib.mkEnableOption "Whether to enable audio.";
|
|
|
|
myFlake.hardware.components.audio.soundServer = lib.mkOption {
|
2023-11-17 07:17:12 +00:00
|
|
|
type = lib.types.enum ["pipewire" "pulseaudio"];
|
|
|
|
default = "pipewire";
|
|
|
|
example = "pulseaudio";
|
|
|
|
description = "Select desired sound system.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# https://nixos.wiki/wiki/PipeWire
|
|
|
|
# https://nixos.wiki/wiki/PulseAudio
|
|
|
|
config = lib.mkIf cfg.enable (lib.mkMerge [
|
|
|
|
(lib.mkIf (cfg.soundServer == "pipewire") {
|
|
|
|
security.rtkit.enable = true;
|
|
|
|
hardware.pulseaudio.enable = false;
|
|
|
|
services.pipewire = {
|
|
|
|
enable = true;
|
|
|
|
alsa.enable = true;
|
|
|
|
alsa.support32Bit = true;
|
|
|
|
pulse.enable = true;
|
|
|
|
jack.enable = true;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
(lib.mkIf (cfg.soundServer == "pulseaudio") {
|
|
|
|
hardware.pulseaudio.enable = true;
|
|
|
|
hardware.pulseaudio.support32Bit = true;
|
|
|
|
})
|
|
|
|
]);
|
|
|
|
}
|