summary refs log tree commit diff
diff options
context:
space:
mode:
authorGabriel Ebner <gebner@gebner.org>2020-11-29 15:25:40 +0100
committerGabriel Ebner <gebner@gebner.org>2020-11-29 17:43:07 +0100
commit015583027548ef7554d6053f39ec6ef77d9487e2 (patch)
tree3c24f99ed311638f3c2ff7bbeefd594ab875de34
parentce28fd3d22313a2d4daef605c9d4f314bfb6456a (diff)
downloadnixpkgs-015583027548ef7554d6053f39ec6ef77d9487e2.tar
nixpkgs-015583027548ef7554d6053f39ec6ef77d9487e2.tar.gz
nixpkgs-015583027548ef7554d6053f39ec6ef77d9487e2.tar.bz2
nixpkgs-015583027548ef7554d6053f39ec6ef77d9487e2.tar.lz
nixpkgs-015583027548ef7554d6053f39ec6ef77d9487e2.tar.xz
nixpkgs-015583027548ef7554d6053f39ec6ef77d9487e2.tar.zst
nixpkgs-015583027548ef7554d6053f39ec6ef77d9487e2.zip
nixos/pipewire: allow overriding the pipewire derivation
-rw-r--r--nixos/modules/services/desktops/pipewire.nix24
1 files changed, 17 insertions, 7 deletions
diff --git a/nixos/modules/services/desktops/pipewire.nix b/nixos/modules/services/desktops/pipewire.nix
index 7b9ecf03875..57f37b0e525 100644
--- a/nixos/modules/services/desktops/pipewire.nix
+++ b/nixos/modules/services/desktops/pipewire.nix
@@ -15,7 +15,7 @@ let
   # 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"
+    ln -s "${cfg.package.jack}/lib" "$out/lib/pipewire"
   '';
 in {
 
@@ -28,6 +28,16 @@ in {
     services.pipewire = {
       enable = mkEnableOption "pipewire service";
 
+      package = mkOption {
+        type = types.package;
+        default = pkgs.pipewire;
+        defaultText = "pkgs.pipewire";
+        example = literalExample "pkgs.pipewire";
+        description = ''
+          The pipewire derivation to use.
+        '';
+      };
+
       socketActivation = mkOption {
         default = true;
         type = types.bool;
@@ -65,24 +75,24 @@ in {
       }
     ];
 
-    environment.systemPackages = [ pkgs.pipewire ]
+    environment.systemPackages = [ cfg.package ]
                                  ++ lib.optional cfg.jack.enable jack-libs;
 
-    systemd.packages = [ pkgs.pipewire ]
-                       ++ lib.optional cfg.pulse.enable pkgs.pipewire.pulse;
+    systemd.packages = [ cfg.package ]
+                       ++ lib.optional cfg.pulse.enable cfg.package.pulse;
 
     # 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.sockets.pipewire-pulse.wantedBy = lib.mkIf (cfg.socketActivation && cfg.pulse.enable) ["sockets.target"];
     systemd.user.services.pipewire.bindsTo = [ "dbus.service" ];
-    services.udev.packages = [ pkgs.pipewire ];
+    services.udev.packages = [ cfg.package ];
 
     # If any paths are updated here they must also be updated in the package test.
     sound.enable = mkIf cfg.alsa.enable true;
     sound.extraConfig = mkIf cfg.alsa.enable ''
       pcm_type.pipewire {
-        libs.native = ${pkgs.pipewire.lib}/lib/alsa-lib/libasound_module_pcm_pipewire.so ;
+        libs.native = ${cfg.package.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 ;"}
       }
@@ -95,7 +105,7 @@ in {
       }
     '';
     environment.etc."alsa/conf.d/50-pipewire.conf" = mkIf cfg.alsa.enable {
-      source = "${pkgs.pipewire}/share/alsa/alsa.conf.d/50-pipewire.conf";
+      source = "${cfg.package}/share/alsa/alsa.conf.d/50-pipewire.conf";
     };
     environment.sessionVariables.LD_LIBRARY_PATH =
       lib.optional cfg.jack.enable "/run/current-system/sw/lib/pipewire";