flake/nixos/modules/myFlake/hardware/components/audio.nix

38 lines
1 KiB
Nix
Raw Normal View History

{
lib,
config,
...
}: let
2023-12-17 12:43:24 +00:00
cfg = config.myFlake.hardware.components.audio;
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 {
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;
})
]);
}