diff --git a/nixos/modules/services/desktops/pipewire/alsa-monitor.conf.json b/nixos/modules/services/desktops/pipewire/media-session/alsa-monitor.conf.json similarity index 100% rename from nixos/modules/services/desktops/pipewire/alsa-monitor.conf.json rename to nixos/modules/services/desktops/pipewire/media-session/alsa-monitor.conf.json diff --git a/nixos/modules/services/desktops/pipewire/bluez-monitor.conf.json b/nixos/modules/services/desktops/pipewire/media-session/bluez-monitor.conf.json similarity index 100% rename from nixos/modules/services/desktops/pipewire/bluez-monitor.conf.json rename to nixos/modules/services/desktops/pipewire/media-session/bluez-monitor.conf.json diff --git a/nixos/modules/services/desktops/pipewire/media-session.conf.json b/nixos/modules/services/desktops/pipewire/media-session/media-session.conf.json similarity index 100% rename from nixos/modules/services/desktops/pipewire/media-session.conf.json rename to nixos/modules/services/desktops/pipewire/media-session/media-session.conf.json diff --git a/nixos/modules/services/desktops/pipewire/v4l2-monitor.conf.json b/nixos/modules/services/desktops/pipewire/media-session/v4l2-monitor.conf.json similarity index 100% rename from nixos/modules/services/desktops/pipewire/v4l2-monitor.conf.json rename to nixos/modules/services/desktops/pipewire/media-session/v4l2-monitor.conf.json diff --git a/nixos/modules/services/desktops/pipewire/pipewire-media-session.nix b/nixos/modules/services/desktops/pipewire/pipewire-media-session.nix index 4ae6aab29cdb..8f6c4fa1d4f6 100644 --- a/nixos/modules/services/desktops/pipewire/pipewire-media-session.nix +++ b/nixos/modules/services/desktops/pipewire/pipewire-media-session.nix @@ -13,10 +13,10 @@ let # 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)); - media-session = (builtins.fromJSON (builtins.readFile ./media-session.conf.json)); - v4l2-monitor = (builtins.fromJSON (builtins.readFile ./v4l2-monitor.conf.json)); + alsa-monitor = (builtins.fromJSON (builtins.readFile ./media-session/alsa-monitor.conf.json)); + bluez-monitor = (builtins.fromJSON (builtins.readFile ./media-session/bluez-monitor.conf.json)); + media-session = (builtins.fromJSON (builtins.readFile ./media-session/media-session.conf.json)); + v4l2-monitor = (builtins.fromJSON (builtins.readFile ./media-session/v4l2-monitor.conf.json)); }; configs = { @@ -43,8 +43,8 @@ in { package = mkOption { type = types.package; - default = pkgs.pipewire.mediaSession; - defaultText = literalExpression "pkgs.pipewire.mediaSession"; + default = pkgs.pipewire-media-session; + defaultText = literalExpression "pkgs.pipewire-media-session"; description = '' The pipewire-media-session derivation to use. ''; @@ -55,7 +55,7 @@ in { type = json.type; 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 + https://gitlab.freedesktop.org/pipewire/media-session/-/blob/${cfg.package.version}/src/daemon/media-session.d/media-session.conf ''; default = {}; }; @@ -64,7 +64,7 @@ in { type = json.type; 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 + https://gitlab.freedesktop.org/pipewire/media-session/-/blob/${cfg.package.version}/src/daemon/media-session.d/alsa-monitor.conf ''; default = {}; }; @@ -73,7 +73,7 @@ in { type = json.type; 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 + https://gitlab.freedesktop.org/pipewire/media-session/-/blob/${cfg.package.version}/src/daemon/media-session.d/bluez-monitor.conf ''; default = {}; }; @@ -82,7 +82,7 @@ in { type = json.type; 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 + https://gitlab.freedesktop.org/pipewire/media-session/-/blob/${cfg.package.version}/src/daemon/media-session.d/v4l2-monitor.conf ''; default = {}; }; diff --git a/pkgs/development/libraries/pipewire/media-session.nix b/pkgs/development/libraries/pipewire/media-session.nix new file mode 100644 index 000000000000..37daffe5c88a --- /dev/null +++ b/pkgs/development/libraries/pipewire/media-session.nix @@ -0,0 +1,93 @@ +{ stdenv +, lib +, fetchFromGitLab +, meson +, ninja +, pkg-config +, doxygen +, graphviz +, systemd +, pipewire +, glib +, dbus +, alsa-lib +, callPackage +}: + +let + mesonEnable = b: if b then "enabled" else "disabled"; + mesonList = l: "[" + lib.concatStringsSep "," l + "]"; + + self = stdenv.mkDerivation rec { + pname = "pipewire-media-session"; + version = "0.4.0"; + + src = fetchFromGitLab { + domain = "gitlab.freedesktop.org"; + owner = "pipewire"; + repo = "media-session"; + rev = version; + sha256 = "sha256-zhOvBlG7DuQkJ+ZZBhBhfKwk+bbLljpt3w4JlK3cJLk="; + }; + + nativeBuildInputs = [ + doxygen + graphviz + meson + ninja + pkg-config + ]; + + buildInputs = [ + alsa-lib + dbus + glib + pipewire + systemd + ]; + + mesonFlags = [ + "-Ddocs=enabled" + # We generate these empty files from the nixos module, don't bother installing them + "-Dwith-module-sets=[]" + ]; + + postUnpack = '' + patchShebangs source/doc/input-filter-h.sh + patchShebangs source/doc/input-filter.sh + ''; + + postInstall = '' + mkdir $out/nix-support + cd $out/share/pipewire/media-session.d + for f in *.conf; do + echo "Generating JSON from $f" + ${pipewire}/bin/spa-json-dump "$f" > "$out/nix-support/$f.json" + done + ''; + + passthru = { + tests = { + test-paths = callPackage ./test-paths.nix { package = self; } { + paths-out = [ + "nix-support/alsa-monitor.conf.json" + "nix-support/bluez-monitor.conf.json" + "nix-support/media-session.conf.json" + "nix-support/v4l2-monitor.conf.json" + ]; + paths-lib = []; + }; + }; + }; + + meta = with lib; { + description = "Example session manager for PipeWire"; + homepage = "https://pipewire.org"; + license = licenses.mit; + platforms = platforms.linux; + maintainers = with maintainers; [ jtojnar kranzes ]; + }; + }; + +in +self diff --git a/pkgs/development/libraries/pipewire/test-paths.nix b/pkgs/development/libraries/pipewire/test-paths.nix index 939b79686e3f..1e3e5fef3a6e 100644 --- a/pkgs/development/libraries/pipewire/test-paths.nix +++ b/pkgs/development/libraries/pipewire/test-paths.nix @@ -1,4 +1,4 @@ -{ lib, runCommand, pipewire, paths-out, paths-lib, paths-out-media-session }: +{ lib, runCommand, package, paths-out, paths-lib }: let check-path = output: path: '' @@ -14,9 +14,8 @@ let in runCommand "pipewire-test-paths" { } '' touch $out - ${check-output pipewire.mediaSession paths-out-media-session} - ${check-output pipewire.lib paths-lib} - ${check-output pipewire paths-out} + ${check-output package.lib paths-lib} + ${check-output package paths-out} if [[ -n "$error" ]]; then exit 1 diff --git a/pkgs/development/libraries/pipewire/update.sh b/pkgs/development/libraries/pipewire/update.sh index 6d0088c206cb..9fc466276672 100755 --- a/pkgs/development/libraries/pipewire/update.sh +++ b/pkgs/development/libraries/pipewire/update.sh @@ -11,14 +11,27 @@ NIXPKGS_ROOT="$(git rev-parse --show-toplevel)" cd "$NIXPKGS_ROOT" nix-update pipewire -outputs=$(nix-build . -A pipewire -A pipewire.mediaSession) +outputs=$(nix-build . -A pipewire) for p in $outputs; do - conf_files=$(find "$p/nix-support/etc/pipewire/" -name '*.conf.json') + conf_files=$(find "$p/nix-support/" -name '*.conf.json') for c in $conf_files; do file_name=$(basename "$c") - if [[ ! -e "nixos/modules/services/desktops/pipewire/$file_name" ]]; then + if [[ ! -e "nixos/modules/services/desktops/pipewire/daemon/$file_name" ]]; then echo "New file $file_name found! Add it to the module config and passthru tests!" fi - install -m 0644 "$c" "nixos/modules/services/desktops/pipewire/" + install -m 0644 "$c" "nixos/modules/services/desktops/pipewire/daemon/" + done +done + +nix-update pipewire-media-session +outputs=$(nix-build . -A pipewire-media-session) +for p in $outputs; do + conf_files=$(find "$p/nix-support/" -name '*.conf.json') + for c in $conf_files; do + file_name=$(basename "$c") + if [[ ! -e "nixos/modules/services/desktops/pipewire/media-session/$file_name" ]]; then + echo "New file $file_name found! Add it to the module config and passthru tests!" + fi + install -m 0644 "$c" "nixos/modules/services/desktops/pipewire/media-session/" done done diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index aaa4638d7d18..0eeb20cd0a30 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -13464,6 +13464,7 @@ with pkgs; pipenv = callPackage ../development/tools/pipenv {}; pipewire = callPackage ../development/libraries/pipewire {}; + pipewire-media-session = callPackage ../development/libraries/pipewire/media-session.nix {}; pipewire_0_2 = callPackage ../development/libraries/pipewire/0.2.nix {}; pyradio = callPackage ../applications/audio/pyradio {};