2023-05-24 13:37:59 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitLab
|
2024-05-15 15:35:15 +00:00
|
|
|
, fetchFromGitHub
|
2023-05-24 13:37:59 +00:00
|
|
|
, fetchpatch
|
|
|
|
, rustPlatform
|
|
|
|
, meson
|
|
|
|
, ninja
|
|
|
|
, python3
|
|
|
|
, pkg-config
|
|
|
|
, rustc
|
|
|
|
, cargo
|
|
|
|
, cargo-c
|
2024-07-31 10:19:44 +00:00
|
|
|
, lld
|
2023-05-24 13:37:59 +00:00
|
|
|
, nasm
|
|
|
|
, gstreamer
|
|
|
|
, gst-plugins-base
|
|
|
|
, gst-plugins-bad
|
|
|
|
, gtk4
|
|
|
|
, cairo
|
|
|
|
, csound
|
|
|
|
, dav1d
|
|
|
|
, libsodium
|
|
|
|
, libwebp
|
|
|
|
, openssl
|
|
|
|
, pango
|
|
|
|
, Security
|
2024-05-15 15:35:15 +00:00
|
|
|
, SystemConfiguration
|
2023-05-24 13:37:59 +00:00
|
|
|
, gst-plugins-good
|
|
|
|
, nix-update-script
|
2023-07-15 17:15:38 +00:00
|
|
|
# specifies a limited subset of plugins to build (the default `null` means all plugins supported on the stdenv platform)
|
2023-05-24 13:37:59 +00:00
|
|
|
, plugins ? null
|
2024-06-05 15:53:02 +00:00
|
|
|
, withGtkPlugins ? true
|
2023-07-15 17:15:38 +00:00
|
|
|
# Checks meson.is_cross_build(), so even canExecute isn't enough.
|
|
|
|
, enableDocumentation ? stdenv.hostPlatform == stdenv.buildPlatform && plugins == null
|
|
|
|
, hotdoc
|
2023-05-24 13:37:59 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
# populated from meson_options.txt (manually for now, but that might change in the future)
|
|
|
|
validPlugins = {
|
|
|
|
# audio
|
|
|
|
audiofx = [ ];
|
|
|
|
claxon = [ ];
|
|
|
|
csound = [ csound ];
|
|
|
|
lewton = [ ];
|
|
|
|
spotify = [ ];
|
|
|
|
|
|
|
|
# generic
|
|
|
|
file = [ ];
|
|
|
|
sodium = [ libsodium ];
|
|
|
|
threadshare = [ ];
|
|
|
|
|
|
|
|
# mux
|
|
|
|
flavors = [ ];
|
|
|
|
fmp4 = [ ];
|
|
|
|
mp4 = [ ];
|
|
|
|
|
|
|
|
# net
|
2024-09-26 11:04:55 +00:00
|
|
|
aws = [ openssl ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ Security ];
|
2023-05-24 13:37:59 +00:00
|
|
|
hlssink3 = [ ];
|
|
|
|
ndi = [ ];
|
|
|
|
onvif = [ pango ];
|
|
|
|
raptorq = [ ];
|
2024-09-26 11:04:55 +00:00
|
|
|
reqwest = [ openssl ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ Security ];
|
2023-05-24 13:37:59 +00:00
|
|
|
rtp = [ ];
|
2024-09-26 11:04:55 +00:00
|
|
|
webrtc = [ gst-plugins-bad openssl ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ Security SystemConfiguration ];
|
|
|
|
webrtchttp = [ gst-plugins-bad openssl ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ Security SystemConfiguration ];
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
# text
|
|
|
|
textahead = [ ];
|
|
|
|
json = [ ];
|
|
|
|
regex = [ ];
|
|
|
|
textwrap = [ ];
|
|
|
|
|
|
|
|
# utils
|
|
|
|
fallbackswitch = [ gtk4 ];
|
|
|
|
livesync = [ gtk4 ];
|
|
|
|
togglerecord = [ gtk4 ];
|
|
|
|
tracers = [ ];
|
|
|
|
uriplaylistbin = [ ];
|
|
|
|
|
|
|
|
# video
|
|
|
|
cdg = [ ];
|
|
|
|
closedcaption = [ pango ];
|
2024-05-15 15:35:15 +00:00
|
|
|
dav1d = [
|
|
|
|
# Only dav1d < 1.3 is supported for now.
|
|
|
|
# https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1393
|
|
|
|
(dav1d.overrideAttrs rec {
|
|
|
|
version = "1.2.1";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "videolan";
|
|
|
|
repo = "dav1d";
|
|
|
|
rev = version;
|
|
|
|
hash = "sha256-RrEim3HXXjx2RUU7K3wPH3QbhNTRN9ZX/oAcyE9aV8I=";
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
2023-05-24 13:37:59 +00:00
|
|
|
ffv1 = [ ];
|
|
|
|
gif = [ ];
|
|
|
|
gtk4 = [ gtk4 ];
|
|
|
|
hsv = [ ];
|
|
|
|
png = [ ];
|
|
|
|
rav1e = [ ];
|
|
|
|
videofx = [ cairo ];
|
|
|
|
webp = [ libwebp ];
|
|
|
|
};
|
|
|
|
|
|
|
|
selectedPlugins = if plugins != null then lib.unique (lib.sort lib.lessThan plugins) else lib.subtractLists (
|
|
|
|
[
|
|
|
|
"csound" # tests have weird failure on x86, does not currently work on arm or darwin
|
2023-07-15 17:15:38 +00:00
|
|
|
"livesync" # tests have suspicious intermittent failure, see https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/357
|
2024-09-26 11:04:55 +00:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isAarch64 [
|
2023-07-15 17:15:38 +00:00
|
|
|
"raptorq" # pointer alignment failure in tests on aarch64
|
2024-09-26 11:04:55 +00:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
2023-05-24 13:37:59 +00:00
|
|
|
"reqwest" # tests hang on darwin
|
|
|
|
"threadshare" # tests cannot bind to localhost on darwin
|
|
|
|
"webp" # not supported on darwin (upstream crate issue)
|
2024-06-05 15:53:02 +00:00
|
|
|
] ++ lib.optionals (!gst-plugins-base.glEnabled || !withGtkPlugins) [
|
2023-10-09 19:29:22 +00:00
|
|
|
# these require gstreamer-gl
|
2023-05-24 13:37:59 +00:00
|
|
|
"gtk4"
|
|
|
|
"livesync"
|
|
|
|
"fallbackswitch"
|
|
|
|
"togglerecord"
|
|
|
|
]
|
|
|
|
) (lib.attrNames validPlugins);
|
|
|
|
|
|
|
|
invalidPlugins = lib.subtractLists (lib.attrNames validPlugins) selectedPlugins;
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
# TODO: figure out what must be done about this upstream - related lu-zero/cargo-c#323 lu-zero/cargo-c#138
|
2023-08-04 22:07:22 +00:00
|
|
|
cargo-c' = (cargo-c.__spliced.buildHost or cargo-c).overrideAttrs (oldAttrs: {
|
2023-07-15 17:15:38 +00:00
|
|
|
patches = (oldAttrs.patches or []) ++ [
|
|
|
|
(fetchpatch {
|
|
|
|
name = "cargo-c-test-rlib-fix.patch";
|
|
|
|
url = "https://github.com/lu-zero/cargo-c/commit/8421f2da07cd066d2ae8afbb027760f76dc9ee6c.diff";
|
|
|
|
hash = "sha256-eZSR4DKSbS5HPpb9Kw8mM2ZWg7Y92gZQcaXUEu1WNj0=";
|
|
|
|
revert = true;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
});
|
2023-05-24 13:37:59 +00:00
|
|
|
in
|
|
|
|
assert lib.assertMsg (invalidPlugins == [])
|
|
|
|
"Invalid gst-plugins-rs plugin${lib.optionalString (lib.length invalidPlugins > 1) "s"}: ${lib.concatStringsSep ", " invalidPlugins}";
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2023-05-24 13:37:59 +00:00
|
|
|
pname = "gst-plugins-rs";
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "0.12.8";
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
|
|
|
src = fetchFromGitLab {
|
|
|
|
domain = "gitlab.freedesktop.org";
|
|
|
|
owner = "gstreamer";
|
|
|
|
repo = "gst-plugins-rs";
|
2024-05-15 15:35:15 +00:00
|
|
|
rev = finalAttrs.version;
|
2024-09-19 14:19:46 +00:00
|
|
|
hash = "sha256-AGXKI/0Y2BdaSnpQAt3T/rkYlM8UpQpKm4kMAGd6Dyk=";
|
2023-05-24 13:37:59 +00:00
|
|
|
# TODO: temporary workaround for case-insensitivity problems with color-name crate - https://github.com/annymosse/color-name/pull/2
|
|
|
|
postFetch = ''
|
2023-07-15 17:15:38 +00:00
|
|
|
sedSearch="$(cat <<\EOF | sed -ze 's/\n/\\n/g'
|
|
|
|
\[\[package\]\]
|
|
|
|
name = "color-name"
|
|
|
|
version = "\([^"\n]*\)"
|
|
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
|
checksum = "[^"\n]*"
|
|
|
|
EOF
|
|
|
|
)"
|
|
|
|
sedReplace="$(cat <<\EOF | sed -ze 's/\n/\\n/g'
|
|
|
|
[[package]]
|
|
|
|
name = "color-name"
|
|
|
|
version = "\1"
|
|
|
|
source = "git+https://github.com/lilyinstarlight/color-name#cac0ed5b7d2e0682c08c9bfd13089d5494e81b9a"
|
|
|
|
EOF
|
|
|
|
)"
|
|
|
|
sed -i -ze "s|$sedSearch|$sedReplace|g" $out/Cargo.lock
|
2023-05-24 13:37:59 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
cargoDeps = rustPlatform.importCargoLock {
|
|
|
|
lockFile = ./Cargo.lock;
|
|
|
|
outputHashes = {
|
2024-09-19 14:19:46 +00:00
|
|
|
"cairo-rs-0.19.8" = "sha256-AdIUcxxuZVAWQ+KOBTrtsvTu4KtFiXkQPYWT9Avt7Z0=";
|
2023-05-24 13:37:59 +00:00
|
|
|
"color-name-1.1.0" = "sha256-RfMStbe2wX5qjPARHIFHlSDKjzx8DwJ+RjzyltM5K7A=";
|
|
|
|
"ffv1-0.0.0" = "sha256-af2VD00tMf/hkfvrtGrHTjVJqbl+VVpLaR0Ry+2niJE=";
|
|
|
|
"flavors-0.2.0" = "sha256-zBa0X75lXnASDBam9Kk6w7K7xuH9fP6rmjWZBUB5hxk=";
|
2024-09-19 14:19:46 +00:00
|
|
|
"gdk4-0.8.2" = "sha256-DZjHlhzrELZ8M5YUM5kSeOphjF7863DmywFgGbZL4Jo=";
|
|
|
|
"gstreamer-0.22.7" = "sha256-vTEDqmyqhj9e7r7N0QfG4uTNBizrU0gTUfLOJ8kU1JE=";
|
2023-05-24 13:37:59 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
strictDeps = true;
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
rustPlatform.cargoSetupHook
|
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
python3
|
|
|
|
python3.pkgs.tomli
|
|
|
|
pkg-config
|
|
|
|
rustc
|
|
|
|
cargo
|
2023-07-15 17:15:38 +00:00
|
|
|
cargo-c'
|
2023-05-24 13:37:59 +00:00
|
|
|
nasm
|
2024-09-26 11:04:55 +00:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
2024-07-31 10:19:44 +00:00
|
|
|
lld
|
2023-07-15 17:15:38 +00:00
|
|
|
] ++ lib.optionals enableDocumentation [
|
|
|
|
hotdoc
|
2023-05-24 13:37:59 +00:00
|
|
|
];
|
|
|
|
|
2024-09-26 11:04:55 +00:00
|
|
|
env = lib.optionalAttrs stdenv.hostPlatform.isDarwin { NIX_CFLAGS_LINK = "-fuse-ld=lld"; };
|
2024-07-31 10:19:44 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
buildInputs = [
|
|
|
|
gstreamer
|
|
|
|
gst-plugins-base
|
|
|
|
] ++ lib.concatMap (plugin: lib.getAttr plugin validPlugins) selectedPlugins;
|
|
|
|
|
|
|
|
checkInputs = [
|
|
|
|
gst-plugins-good
|
|
|
|
gst-plugins-bad
|
|
|
|
];
|
|
|
|
|
|
|
|
mesonFlags = (
|
|
|
|
map (plugin: lib.mesonEnable plugin true) selectedPlugins
|
|
|
|
) ++ [
|
|
|
|
(lib.mesonOption "sodium-source" "system")
|
2024-05-15 15:35:15 +00:00
|
|
|
(lib.mesonEnable "tests" finalAttrs.finalPackage.doCheck)
|
2023-07-15 17:15:38 +00:00
|
|
|
(lib.mesonEnable "doc" enableDocumentation)
|
2023-11-16 04:20:00 +00:00
|
|
|
];
|
2023-05-24 13:37:59 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
# turn off all auto plugins since we use a list of plugins we generate
|
2023-05-24 13:37:59 +00:00
|
|
|
mesonAutoFeatures = "disabled";
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
# csound lib dir must be manually specified for it to build
|
|
|
|
preConfigure = ''
|
|
|
|
export CARGO_BUILD_JOBS=$NIX_BUILD_CORES
|
|
|
|
|
|
|
|
patchShebangs dependencies.py
|
|
|
|
'' + lib.optionalString (lib.elem "csound" selectedPlugins) ''
|
|
|
|
export CSOUND_LIB_DIR=${lib.getLib csound}/lib
|
|
|
|
'';
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
# give meson longer before timing out for tests
|
|
|
|
mesonCheckFlags = [ "--verbose" "--timeout-multiplier" "12" ];
|
2023-05-24 13:37:59 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
doInstallCheck = (lib.elem "webp" selectedPlugins) && !stdenv.hostPlatform.isStatic &&
|
2024-01-13 08:15:51 +00:00
|
|
|
stdenv.hostPlatform.isElf;
|
2023-10-09 19:29:22 +00:00
|
|
|
installCheckPhase = ''
|
|
|
|
runHook preInstallCheck
|
|
|
|
readelf -a $out/lib/gstreamer-1.0/libgstrswebp.so | grep -F 'Shared library: [libwebpdemux.so'
|
|
|
|
runHook postInstallCheck
|
|
|
|
'';
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
passthru.updateScript = nix-update-script {
|
|
|
|
# use numbered releases rather than gstreamer-* releases
|
2024-05-15 15:35:15 +00:00
|
|
|
# this matches upstream's recommendation: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/470#note_2202772
|
2023-05-24 13:37:59 +00:00
|
|
|
extraArgs = [ "--version-regex" "([0-9.]+)" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "GStreamer plugins written in Rust";
|
2024-04-21 15:54:59 +00:00
|
|
|
mainProgram = "gst-webrtc-signalling-server";
|
2023-05-24 13:37:59 +00:00
|
|
|
homepage = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs";
|
|
|
|
license = with licenses; [ mpl20 asl20 mit lgpl21Plus ];
|
|
|
|
platforms = platforms.unix;
|
2024-07-31 10:19:44 +00:00
|
|
|
maintainers = [ ];
|
2023-05-24 13:37:59 +00:00
|
|
|
};
|
2024-05-15 15:35:15 +00:00
|
|
|
})
|