nixpkgs/nixos/modules/services/desktops/pipewire/pipewire-media-session.nix

136 lines
4.8 KiB
Nix
Raw Normal View History

# pipewire example session manager.
{ config, lib, pkgs, ... }:
with lib;
let
json = pkgs.formats.json {};
2021-02-12 13:27:44 +00:00
cfg = config.services.pipewire.media-session;
enable32BitAlsaPlugins = cfg.alsa.support32Bit
&& pkgs.stdenv.isx86_64
&& pkgs.pkgsi686Linux.pipewire != null;
2021-02-25 14:22:40 +00:00
# Use upstream config files passed through spa-json-dump as the base
# Patched here as necessary for them to work with this module
defaults = {
alsa-monitor = (builtins.fromJSON (builtins.readFile ./alsa-monitor.conf.json));
bluez-monitor = (builtins.fromJSON (builtins.readFile ./bluez-monitor.conf.json));
bluez-hardware = (builtins.fromJSON (builtins.readFile ./bluez-hardware.conf.json));
2021-03-14 23:38:20 +00:00
media-session = (builtins.fromJSON (builtins.readFile ./media-session.conf.json));
2021-02-25 14:22:40 +00:00
v4l2-monitor = (builtins.fromJSON (builtins.readFile ./v4l2-monitor.conf.json));
};
configs = {
alsa-monitor = recursiveUpdate defaults.alsa-monitor cfg.config.alsa-monitor;
bluez-monitor = recursiveUpdate defaults.bluez-monitor cfg.config.bluez-monitor;
bluez-hardware = defaults.bluez-hardware;
media-session = recursiveUpdate defaults.media-session cfg.config.media-session;
v4l2-monitor = recursiveUpdate defaults.v4l2-monitor cfg.config.v4l2-monitor;
};
in {
meta = {
maintainers = teams.freedesktop.members;
};
###### interface
options = {
2021-02-12 13:27:44 +00:00
services.pipewire.media-session = {
enable = mkOption {
type = types.bool;
default = config.services.pipewire.enable;
defaultText = literalExpression "config.services.pipewire.enable";
2021-02-12 13:27:44 +00:00
description = "Example pipewire session manager";
};
package = mkOption {
type = types.package;
default = pkgs.pipewire.mediaSession;
defaultText = literalExpression "pkgs.pipewire.mediaSession";
description = ''
The pipewire-media-session derivation to use.
'';
};
2021-02-25 14:22:40 +00:00
config = {
media-session = mkOption {
type = json.type;
2021-02-25 14:22:40 +00:00
description = ''
Configuration for the media session core. For details see
https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/${cfg.package.version}/src/daemon/media-session.d/media-session.conf
'';
default = {};
};
2021-02-25 14:22:40 +00:00
alsa-monitor = mkOption {
type = json.type;
2021-02-25 14:22:40 +00:00
description = ''
Configuration for the alsa monitor. For details see
https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/${cfg.package.version}/src/daemon/media-session.d/alsa-monitor.conf
'';
default = {};
};
2021-02-25 14:22:40 +00:00
bluez-monitor = mkOption {
type = json.type;
2021-02-25 14:22:40 +00:00
description = ''
Configuration for the bluez5 monitor. For details see
https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/${cfg.package.version}/src/daemon/media-session.d/bluez-monitor.conf
'';
default = {};
};
2021-02-25 14:22:40 +00:00
v4l2-monitor = mkOption {
type = json.type;
2021-02-25 14:22:40 +00:00
description = ''
Configuration for the V4L2 monitor. For details see
https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/${cfg.package.version}/src/daemon/media-session.d/v4l2-monitor.conf
'';
default = {};
};
};
};
};
###### implementation
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
2021-03-04 22:41:02 +00:00
systemd.packages = [ cfg.package ];
systemd.user.services.pipewire-media-session.wantedBy = [ "pipewire.service" ];
environment.etc."pipewire/media-session.d/media-session.conf" = {
source = json.generate "media-session.conf" configs.media-session;
};
environment.etc."pipewire/media-session.d/v4l2-monitor.conf" = {
source = json.generate "v4l2-monitor.conf" configs.v4l2-monitor;
};
environment.etc."pipewire/media-session.d/with-alsa" =
mkIf config.services.pipewire.alsa.enable {
text = "";
};
environment.etc."pipewire/media-session.d/alsa-monitor.conf" =
mkIf config.services.pipewire.alsa.enable {
source = json.generate "alsa-monitor.conf" configs.alsa-monitor;
};
environment.etc."pipewire/media-session.d/with-pulseaudio" =
mkIf config.services.pipewire.pulse.enable {
text = "";
};
environment.etc."pipewire/media-session.d/bluez-monitor.conf" =
mkIf config.services.pipewire.pulse.enable {
source = json.generate "bluez-monitor.conf" configs.bluez-monitor;
};
environment.etc."pipewire/media-session.d/bluez-hardware.conf" =
mkIf config.services.pipewire.pulse.enable {
source = json.generate "bluez-hardware.conf" configs.bluez-hardware;
};
environment.etc."pipewire/media-session.d/with-jack" =
mkIf config.services.pipewire.jack.enable {
text = "";
};
};
}