summaryrefslogtreecommitdiffstats
path: root/nixos
diff options
context:
space:
mode:
authorNathaniel Glen <njag2202@gmail.com>2020-10-23 13:36:56 -0400
committerNathaniel Glen <njag2202@gmail.com>2020-10-23 13:51:41 -0400
commitf6745d06f5dc6c357e9bc101f524a5ced3562921 (patch)
tree451689347190c92f6b260414d8013458c62cd435 /nixos
parent798b9c072e0cbda4298350310684750f04a11fd8 (diff)
nixos/pipewire: cleanup module
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/desktops/pipewire.nix53
1 files changed, 23 insertions, 30 deletions
diff --git a/nixos/modules/services/desktops/pipewire.nix b/nixos/modules/services/desktops/pipewire.nix
index d527343966d7..ed1b15380ffe 100644
--- a/nixos/modules/services/desktops/pipewire.nix
+++ b/nixos/modules/services/desktops/pipewire.nix
@@ -9,6 +9,10 @@ let
&& 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"
@@ -37,41 +41,16 @@ in {
};
alsa = {
- enable = mkOption {
- default = false;
- type = types.bool;
- description = ''
- Route audio to/from generic ALSA-using applications via the ALSA PIPEWIRE PCM plugin.
- '';
- };
-
- support32Bit = mkOption {
- default = false;
- type = types.bool;
- description = ''
- Whether to support sound for 32-bit ALSA applications on a 64-bit system.
- '';
- };
+ enable = mkEnableOption "ALSA support";
+ support32Bit = mkEnableOption "32-bit ALSA support on 64-bit systems";
};
jack = {
- enable = mkOption {
- default = false;
- type = types.bool;
- description = ''
- Enable transparent JACK audio emulation using LD_LIBRARY_PATH.
- '';
- };
+ enable = mkEnableOption "JACK audio emulation";
};
pulse = {
- enable = mkOption {
- default = false;
- type = types.bool;
- description = ''
- Enable transparent PulseAudio emulation using LD_LIBRARY_PATH.
- '';
- };
+ enable = mkEnableOption "PulseAudio emulation";
};
};
};
@@ -79,12 +58,25 @@ in {
###### implementation
config = mkIf cfg.enable {
+ 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 = [ 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 ];
@@ -107,6 +99,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";
};
- environment.sessionVariables.LD_LIBRARY_PATH = [ "/run/current-system/sw/lib/pipewire" ];
+ environment.sessionVariables.LD_LIBRARY_PATH =
+ lib.optional (cfg.alsa.enable || cfg.jack.enable || cfg.pulse.enable) "/run/current-system/sw/lib/pipewire";
};
}