diff options
author | Hans Christian Schmitz <git@hcsch.eu> | 2024-01-19 13:50:11 +0100 |
---|---|---|
committer | Hans Christian Schmitz <git@hcsch.eu> | 2024-02-23 08:58:15 +0100 |
commit | 5bf2637b489091b787944d9d60b4e04878ac1b89 (patch) | |
tree | 37fc4eafba4be5241cda9fa9a00a24b1bd7cf445 /nixos/modules/services/desktops | |
parent | 054bba560af06ef9ba53c00e154be2ad3238f811 (diff) |
nixos/wireplumber: add config packages option
Diffstat (limited to 'nixos/modules/services/desktops')
-rw-r--r-- | nixos/modules/services/desktops/pipewire/pipewire.nix | 4 | ||||
-rw-r--r-- | nixos/modules/services/desktops/pipewire/wireplumber.nix | 71 |
2 files changed, 47 insertions, 28 deletions
diff --git a/nixos/modules/services/desktops/pipewire/pipewire.nix b/nixos/modules/services/desktops/pipewire/pipewire.nix index 7effd8df9a17..238259c212bb 100644 --- a/nixos/modules/services/desktops/pipewire/pipewire.nix +++ b/nixos/modules/services/desktops/pipewire/pipewire.nix @@ -38,7 +38,9 @@ let configs = pkgs.buildEnv { name = "pipewire-configs"; - paths = configPackages ++ [ extraConfigPkg ]; + paths = configPackages + ++ [ extraConfigPkg ] + ++ lib.optionals cfg.wireplumber.enable cfg.wireplumber.configPackages; pathsToLink = [ "/share/pipewire" ]; }; in { diff --git a/nixos/modules/services/desktops/pipewire/wireplumber.nix b/nixos/modules/services/desktops/pipewire/wireplumber.nix index eee06f09ba20..584cbf1486ef 100644 --- a/nixos/modules/services/desktops/pipewire/wireplumber.nix +++ b/nixos/modules/services/desktops/pipewire/wireplumber.nix @@ -23,51 +23,68 @@ in defaultText = lib.literalExpression "pkgs.wireplumber"; description = lib.mdDoc "The WirePlumber derivation to use."; }; + + configPackages = lib.mkOption { + type = lib.types.listOf lib.types.package; + default = [ ]; + description = lib.mdDoc '' + List of packages that provide WirePlumber configuration, in the form of + `share/wireplumber/*/*.lua` files. + ''; + }; }; }; - config = lib.mkIf cfg.enable { - assertions = [ - { - assertion = !config.hardware.bluetooth.hsphfpd.enable; - message = "Using WirePlumber conflicts with hsphfpd, as it provides the same functionality. `hardware.bluetooth.hsphfpd.enable` needs be set to false"; - } - ]; - - environment.systemPackages = [ cfg.package ]; + config = + let + configPackages = cfg.configPackages; - environment.etc."wireplumber/main.lua.d/80-nixos.lua" = lib.mkIf (!pwUsedForAudio) { - text = '' + pwNotForAudioConfigPkg = pkgs.writeTextDir "share/wireplumber/main.lua.d/80-pw-not-for-audio.lua" '' -- PipeWire is not used for audio, so prevent it from grabbing audio devices alsa_monitor.enable = function() end ''; - }; - environment.etc."wireplumber/main.lua.d/80-systemwide.lua" = lib.mkIf config.services.pipewire.systemWide { - text = '' + systemwideConfigPkg = pkgs.writeTextDir "wireplumber/main.lua.d/80-systemwide.lua" '' -- When running system-wide, these settings need to be disabled (they -- use functions that aren't available on the system dbus). alsa_monitor.properties["alsa.reserve"] = false default_access.properties["enable-flatpak-portal"] = false ''; - }; - environment.etc."wireplumber/bluetooth.lua.d/80-systemwide.lua" = lib.mkIf config.services.pipewire.systemWide { - text = '' + systemwideBluetoothConfigPkg = pkgs.writeTextDir "wireplumber/bluetooth.lua.d/80-systemwide.lua" '' -- When running system-wide, logind-integration needs to be disabled. bluez_monitor.properties["with-logind"] = false ''; - }; - systemd.packages = [ cfg.package ]; + configs = pkgs.buildEnv { + name = "wireplumber-configs"; + paths = configPackages + ++ lib.optional (!pwUsedForAudio) pwNotForAudioConfigPkg + ++ lib.optionals config.services.pipewire.systemWide [ systemwideConfigPkg systemwideBluetoothConfigPkg ]; + pathsToLink = [ "/share/wireplumber" ]; + }; + in + lib.mkIf cfg.enable { + assertions = [ + { + assertion = !config.hardware.bluetooth.hsphfpd.enable; + message = "Using WirePlumber conflicts with hsphfpd, as it provides the same functionality. `hardware.bluetooth.hsphfpd.enable` needs be set to false"; + } + ]; + + environment.systemPackages = [ cfg.package ]; + + environment.etc.wireplumber.source = "${configs}/share/wireplumber"; - systemd.services.wireplumber.enable = config.services.pipewire.systemWide; - systemd.user.services.wireplumber.enable = !config.services.pipewire.systemWide; + systemd.packages = [ cfg.package ]; - systemd.services.wireplumber.wantedBy = [ "pipewire.service" ]; - systemd.user.services.wireplumber.wantedBy = [ "pipewire.service" ]; + systemd.services.wireplumber.enable = config.services.pipewire.systemWide; + systemd.user.services.wireplumber.enable = !config.services.pipewire.systemWide; - systemd.services.wireplumber.environment = lib.mkIf config.services.pipewire.systemWide { - # Force WirePlumber to use system dbus. - DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/dbus/system_bus_socket"; + systemd.services.wireplumber.wantedBy = [ "pipewire.service" ]; + systemd.user.services.wireplumber.wantedBy = [ "pipewire.service" ]; + + systemd.services.wireplumber.environment = lib.mkIf config.services.pipewire.systemWide { + # Force WirePlumber to use system dbus. + DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/dbus/system_bus_socket"; + }; }; - }; } |