summaryrefslogtreecommitdiffstats
path: root/nixos
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2020-10-24 00:05:33 +0200
committerGitHub <noreply@github.com>2020-10-24 00:05:33 +0200
commit3a735434012d7f0b10ff299070e7958912691bcb (patch)
tree504daf3b8ce92803ffd8d90e1e3cb0c692612a93 /nixos
parent582f622f6c82e8db2efc4d490e5945db177ed597 (diff)
parent4bca42a6ec4e442f1a3a4b781b1adb529bf049e0 (diff)
Merge pull request #93725 from nglen/pipewire
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/desktops/pipewire.nix72
-rw-r--r--nixos/tests/installed-tests/default.nix1
-rw-r--r--nixos/tests/installed-tests/pipewire.nix5
3 files changed, 74 insertions, 4 deletions
diff --git a/nixos/modules/services/desktops/pipewire.nix b/nixos/modules/services/desktops/pipewire.nix
index 5aee59cfdcce..5179cbaf6bc2 100644
--- a/nixos/modules/services/desktops/pipewire.nix
+++ b/nixos/modules/services/desktops/pipewire.nix
@@ -5,8 +5,22 @@ with lib;
let
cfg = config.services.pipewire;
- packages = with pkgs; [ pipewire ];
+ enable32BitAlsaPlugins = cfg.alsa.support32Bit
+ && pkgs.stdenv.isx86_64
+ && pkgs.pkgsi686Linux.pipewire != null;
+ # The package doesn't output to $out/lib/pipewire directly so that the
+ # overlays can use the outputs to replace the originals in FHS environments.
+ #
+ # This doesn't work in general because of missing development information.
+ jack-libs = pkgs.runCommand "jack-libs" {} ''
+ mkdir -p "$out/lib"
+ ln -s "${pkgs.pipewire.jack}/lib" "$out/lib/pipewire"
+ '';
+ pulse-libs = pkgs.runCommand "pulse-libs" {} ''
+ mkdir -p "$out/lib"
+ ln -s "${pkgs.pipewire.pulse}/lib" "$out/lib/pipewire"
+ '';
in {
meta = {
@@ -25,17 +39,67 @@ in {
Automatically run pipewire when connections are made to the pipewire socket.
'';
};
+
+ alsa = {
+ enable = mkEnableOption "ALSA support";
+ support32Bit = mkEnableOption "32-bit ALSA support on 64-bit systems";
+ };
+
+ jack = {
+ enable = mkEnableOption "JACK audio emulation";
+ };
+
+ pulse = {
+ enable = mkEnableOption "PulseAudio emulation";
+ };
};
};
###### implementation
config = mkIf cfg.enable {
- environment.systemPackages = packages;
+ assertions = [
+ {
+ assertion = cfg.pulse.enable -> !config.hardware.pulseaudio.enable;
+ message = "PipeWire based PulseAudio emulation doesn't use the PulseAudio service";
+ }
+ {
+ assertion = cfg.jack.enable -> !config.services.jack.jackd.enable;
+ message = "PIpeWire based JACK emulation doesn't use the JACK service";
+ }
+ ];
+
+ environment.systemPackages = [ pkgs.pipewire ]
+ ++ lib.optional cfg.jack.enable jack-libs
+ ++ lib.optional cfg.pulse.enable pulse-libs;
- systemd.packages = packages;
+ systemd.packages = [ pkgs.pipewire ];
+ # PipeWire depends on DBUS but doesn't list it. Without this booting
+ # into a terminal results in the service crashing with an error.
systemd.user.sockets.pipewire.wantedBy = lib.mkIf cfg.socketActivation [ "sockets.target" ];
- };
+ systemd.user.services.pipewire.bindsTo = [ "dbus.service" ];
+ services.udev.packages = [ pkgs.pipewire ];
+ # If any paths are updated here they must also be updated in the package test.
+ sound.extraConfig = mkIf cfg.alsa.enable ''
+ pcm_type.pipewire {
+ libs.native = ${pkgs.pipewire.lib}/lib/alsa-lib/libasound_module_pcm_pipewire.so ;
+ ${optionalString enable32BitAlsaPlugins
+ "libs.32Bit = ${pkgs.pkgsi686Linux.pipewire.lib}/lib/alsa-lib/libasound_module_pcm_pipewire.so ;"}
+ }
+ pcm.!default {
+ @func getenv
+ vars [ PCM ]
+ default "plug:pipewire"
+ playback_mode "-1"
+ capture_mode "-1"
+ }
+ '';
+ environment.etc."alsa/conf.d/50-pipewire.conf" = mkIf cfg.alsa.enable {
+ source = "${pkgs.pipewire}/share/alsa/alsa.conf.d/50-pipewire.conf";
+ };
+ environment.sessionVariables.LD_LIBRARY_PATH =
+ lib.optional (cfg.jack.enable || cfg.pulse.enable) "/run/current-system/sw/lib/pipewire";
+ };
}
diff --git a/nixos/tests/installed-tests/default.nix b/nixos/tests/installed-tests/default.nix
index 889a00d4b568..50ca8ad2b50f 100644
--- a/nixos/tests/installed-tests/default.nix
+++ b/nixos/tests/installed-tests/default.nix
@@ -101,5 +101,6 @@ in
libxmlb = callInstalledTest ./libxmlb.nix {};
malcontent = callInstalledTest ./malcontent.nix {};
ostree = callInstalledTest ./ostree.nix {};
+ pipewire = callInstalledTest ./pipewire.nix {};
xdg-desktop-portal = callInstalledTest ./xdg-desktop-portal.nix {};
}
diff --git a/nixos/tests/installed-tests/pipewire.nix b/nixos/tests/installed-tests/pipewire.nix
new file mode 100644
index 000000000000..f4154b5d2fd7
--- /dev/null
+++ b/nixos/tests/installed-tests/pipewire.nix
@@ -0,0 +1,5 @@
+{ pkgs, lib, makeInstalledTest, ... }:
+
+makeInstalledTest {
+ tested = pkgs.pipewire;
+}