{ config, pkgs, lib, ... }: let cfg = config.local.sound; in { options.local.sound = { enable = lib.mkEnableOption "sound"; systemWide = lib.mkEnableOption "systemWide"; }; config = lib.mkIf cfg.enable { services.pipewire.enable = false; environment.systemPackages = [ pkgs.alsa-utils ]; hardware.pulseaudio = lib.mkMerge [ { enable = true; package = pkgs.pulseaudioFull; support32Bit = true; } (lib.mkIf cfg.systemWide { systemWide = true; tcp = { enable = true; anonymousClients.allowedIpRanges = [ "127.0.0.1" ]; }; }) ]; networking.firewall.allowedTCPPorts = lib.mkIf cfg.systemWide [ 4713 ]; }; }