From 5abe4e929e0ad92d6cc5c69c4377bdcf64c06277 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 26 Jun 2021 23:35:31 +0200 Subject: [PATCH] modules: hardware: sound: refactor options Do not enable ALSA when using pipewire. Ensure that both pulseaudio and pipewire are not configured at the same time. --- machines/aramis/sound.nix | 2 -- modules/hardware/sound.nix | 22 +++++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/machines/aramis/sound.nix b/machines/aramis/sound.nix index f9dd1b0..41ff7f7 100644 --- a/machines/aramis/sound.nix +++ b/machines/aramis/sound.nix @@ -1,8 +1,6 @@ { ... }: { my.hardware.sound = { - enable = true; - pipewire = { enable = true; }; diff --git a/modules/hardware/sound.nix b/modules/hardware/sound.nix index 3a12843..3a48641 100644 --- a/modules/hardware/sound.nix +++ b/modules/hardware/sound.nix @@ -4,8 +4,6 @@ let in { options.my.hardware.sound = with lib; { - enable = mkEnableOption "sound configuration"; - pipewire = { enable = mkEnableOption "pipewire configuration"; }; @@ -15,10 +13,21 @@ in }; }; - config = lib.mkIf cfg.enable (lib.mkMerge [ - # Basic configuration + config = (lib.mkMerge [ + # Sanity check { - sound.enable = true; + assertions = [ + { + assertion = builtins.all (lib.id) [ + (cfg.pipewire.enable -> !cfg.pulse.enable) + (cfg.pulse.enable -> !cfg.pipewire.enable) + ]; + message = '' + `config.my.hardware.sound.pipewire.enable` and + `config.my.hardware.sound.pulse.enable` are incompatible. + ''; + } + ]; } (lib.mkIf cfg.pipewire.enable { @@ -49,6 +58,9 @@ in # Pulseaudio setup (lib.mkIf cfg.pulse.enable { + # ALSA + sound.enable = true; + hardware.pulseaudio.enable = true; }) ]);