home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

commit 69d12c91d18360bdafbbe86a6ef851c194c69d01
parent 26d4b0fe14b6c8c2e4a925a4797979683bfa4a53
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Fri, 19 Aug 2022 17:53:37 +0200

systems/modules: hardware.audio to support pipewire

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Msystems/modules/desktop/sway.nix | 12++++++------
Msystems/modules/hardware/audio.nix | 51+++++++++++++++++++++++++++++++++++----------------
Msystems/modules/hardware/bluetooth.nix | 2+-
3 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/systems/modules/desktop/sway.nix b/systems/modules/desktop/sway.nix @@ -13,6 +13,12 @@ in # Enable wayland desktop modules if not already modules.desktop.wayland.enable = true; + # Enable pipewire + modules.hardware.audio = { + enable = true; + pipewire.enable = true; + }; + xdg = { portal = { enable = true; @@ -23,12 +29,6 @@ in }; }; - services.pipewire = { - enable = true; - alsa.enable = true; - pulse.enable = true; - }; - # Allow swaylock to unlock the computer for us security.pam.services.swaylock = { text = "auth include login"; diff --git a/systems/modules/hardware/audio.nix b/systems/modules/hardware/audio.nix @@ -6,27 +6,22 @@ in { options.modules.hardware.audio = { enable = mkEnableOption "enable audio"; - tcp = mkOption { - default = false; - description = "enable pulseaudio tcp"; - type = types.bool; + pulseaudio = { + enable = mkEnableOption "enable pulseaudio"; + tcp = mkOption { + default = false; + description = "enable pulseaudio tcp"; + type = types.bool; + }; + }; + pipewire = { + enable = mkEnableOption "enable pipewire"; }; }; config = mkIf cfg.enable (mkMerge [ { - # Add extra packages - environment.systemPackages = with pkgs; [ - apulse # allow alsa application to use pulse - pavucontrol # pulseaudio volume control - pasystray # systray application - ]; # Enable sound (alsa) sound.enable = true; - # Enable and configure pulseaudio - hardware.pulseaudio = { - enable = true; - support32Bit = true; - }; # FIXME is it needed security.pam.loginLimits = [ { domain = "@audio"; item = "memlock"; type = "-"; value = "unlimited"; } @@ -34,7 +29,31 @@ in { domain = "@audio"; item = "nofile"; type = "-"; value = "99999"; } ]; } - (mkIf cfg.tcp { + (mkIf cfg.pipewire.enable { + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + }) + (mkIf cfg.pulseaudio.enable { + # Enable and configure pulseaudio + hardware.pulseaudio = { + enable = true; + support32Bit = true; + }; + }) + (mkIf (cfg.pulseaudio.enable || cfg.pipewire.enable) { + # Add extra packages + environment.systemPackages = with pkgs; [ + apulse # allow alsa application to use pulse + pavucontrol # pulseaudio volume control + pasystray # systray application + ]; + }) + (mkIf (cfg.pulseaudio.enable && cfg.pulseaudio.tcp) { hardware.pulseaudio = { zeroconf = { discovery.enable = cfg.tcp; diff --git a/systems/modules/hardware/bluetooth.nix b/systems/modules/hardware/bluetooth.nix @@ -14,7 +14,7 @@ in hardware.bluetooth.enable = true; # warnings = if stable then [ ] else [ "NixOS release: ${config.system.nixos.release}" ]; } - (mkIf config.modules.hardware.audio.enable { + (mkIf config.modules.hardware.audio.pulseaudio.enable { hardware.pulseaudio = { # NixOS allows either a lightweight build (default) or full build of # PulseAudio to be installed. Only the full build has Bluetooth