diff --git a/pkgs/by-name/ca/cargo-tauri/gst-plugin.nix b/pkgs/by-name/ca/cargo-tauri/gst-plugin.nix new file mode 100644 index 000000000000..1145c9531c85 --- /dev/null +++ b/pkgs/by-name/ca/cargo-tauri/gst-plugin.nix @@ -0,0 +1,49 @@ +{ + lib, + rustPlatform, + fetchFromGitHub, + pkg-config, + gst_all_1, +}: + +rustPlatform.buildRustPackage (finalAttrs: { + pname = "tauri-asset-gst-plugin"; + version = "0.1.0"; + + # From upstream PR https://github.com/tauri-apps/tauri/pull/14402 + src = fetchFromGitHub { + owner = "aaalloc"; + repo = "tauri"; + rev = "bc502b45a6995aab5687ce3e50b3d218ca5ee105"; + hash = "sha256-H27n2rsqmGbk7ru8K7LhEvvftpz6mxgTow/18SpQn1Q="; + }; + + cargoHash = "sha256-n9CZ92ezRP9i4JpARwLpW4KIo9/6cB481YuG3qN1BKo="; + + cargoBuildFlags = [ "--package tauri-asset-gst-plugin" ]; + cargoTestFlags = finalAttrs.cargoBuildFlags; + + nativeBuildInputs = [ + pkg-config + ]; + + buildInputs = [ + gst_all_1.gstreamer + ]; + + postInstall = '' + mkdir $out/lib/gstreamer-1.0 + mv $out/lib/*.so $out/lib/gstreamer-1.0/ + ''; + + meta = { + description = "GStreamer plugin to handle the tauri asset:// protocol"; + homepage = "https://github.com/tauri-apps/tauri/pull/14402"; + license = [ + lib.licenses.mit + lib.licenses.asl20 + ]; + maintainers = with lib.maintainers; [ snu ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/by-name/ca/cargo-tauri/hook.nix b/pkgs/by-name/ca/cargo-tauri/hook.nix index 4683e5a2ac5c..3b2f72f76be6 100644 --- a/pkgs/by-name/ca/cargo-tauri/hook.nix +++ b/pkgs/by-name/ca/cargo-tauri/hook.nix @@ -18,6 +18,9 @@ makeSetupHook { propagatedBuildInputs = [ cargo cargo-tauri + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ + cargo-tauri.gst-plugin ]; substitutions = { @@ -33,6 +36,14 @@ makeSetupHook { } .${kernelName} or (throw "${kernelName} is not supported by cargo-tauri.hook"); + fixupScript = lib.optionalString stdenv.hostPlatform.isLinux '' + gappsWrapperArgs+=( + --prefix WEBKIT_GST_ALLOWED_URI_PROTOCOLS : "asset" + # Not picked up automatically by the wrappers from the propagatedBuildInputs. + --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "${cargo-tauri.gst-plugin}/lib/gstreamer-1.0/" + ) + ''; + # $targetDir is the path to the build artifacts (i.e., `./target/release`) installScript = { diff --git a/pkgs/by-name/ca/cargo-tauri/hook.sh b/pkgs/by-name/ca/cargo-tauri/hook.sh index adfa24b515b8..51606216cf89 100644 --- a/pkgs/by-name/ca/cargo-tauri/hook.sh +++ b/pkgs/by-name/ca/cargo-tauri/hook.sh @@ -92,10 +92,19 @@ tauriInstallHook() { echo "Finished tauriInstallHook" } +tauriFixupHook() { + # NOTE: This runs as a preFixupPhase and does not replace the original hook. + @fixupScript@ +} + if [ -z "${dontTauriBuild:-}" ] && [ -z "${buildPhase:-}" ]; then buildPhase=tauriBuildHook fi +if [ -z "${dontTauriFixup:-}" ] && [ -z "${fixupPhase:-}" ]; then + preFixupPhases+=(tauriFixupHook) +fi + if [ -z "${dontTauriInstall:-}" ] && [ -z "${installPhase:-}" ]; then installPhase=tauriInstallHook fi diff --git a/pkgs/by-name/ca/cargo-tauri/package.nix b/pkgs/by-name/ca/cargo-tauri/package.nix index 467fdacd64cf..7044a8e76458 100644 --- a/pkgs/by-name/ca/cargo-tauri/package.nix +++ b/pkgs/by-name/ca/cargo-tauri/package.nix @@ -49,6 +49,7 @@ rustPlatform.buildRustPackage (finalAttrs: { passthru = { # See ./doc/hooks/tauri.section.md hook = callPackage ./hook.nix { cargo-tauri = finalAttrs.finalPackage; }; + gst-plugin = callPackage ./gst-plugin.nix { }; tests = { hook = callPackage ./test-app.nix { cargo-tauri = finalAttrs.finalPackage; };