diff --git a/doc/hooks/index.md b/doc/hooks/index.md index cd769cec0373c..e7b5972c84d76 100644 --- a/doc/hooks/index.md +++ b/doc/hooks/index.md @@ -22,6 +22,7 @@ haredo.section.md installShellFiles.section.md julec.section.md just.section.md +libglycin.section.md libiconv.section.md libxml2.section.md meson.section.md diff --git a/doc/hooks/libglycin.section.md b/doc/hooks/libglycin.section.md new file mode 100644 index 0000000000000..48c52e1b40363 --- /dev/null +++ b/doc/hooks/libglycin.section.md @@ -0,0 +1,47 @@ +# libglycin {#libglycin-hooks} + +[Glycin](https://gitlab.gnome.org/GNOME/glycin) is a library for sandboxed and extendable image loading. + +[]{#libglycin-setup-hook} For most applications using it, individual image formats are loaded through binaries provided by `glycin-loaders`. The paths of these loaders must be injected into the environment, e.g. using [`wrapGAppsHook`](#ssec-gnome-hooks). `libglycin.setupHook` will do that. + +[]{#libglycin-patch-vendor-hook} Additionally, for Rust projects `glycin` Rust crate itself requires a patch to become self-contained. `libglycin.patchVendorHook` will do that. This is not needed for projects using the ELF library from `libglycin` package. + +## Example code snippet {#libglycin-hooks-example-code-snippet} + +```nix +{ + lib, + rustPlatform, + libglycin, + glycin-loaders, + wrapGAppsHook4, +}: + +rustPlatform.buildRustPackage { + # ... + + cargoHash = "..."; + + nativeBuildInputs = [ + wrapGAppsHook4 + libglycin.patchVendorHook + ]; + + buildInputs = [ + libglycin.setupHook + glycin-loaders + ]; + + # ... +} +``` + +## Variables controlling glycin-loaders {#libglycin-hook-variables-controlling} + +### `glycinCargoDepsPath` {#glycin-cargo-deps-path} + +Path to a directory containing the `glycin` crate to patch. Defaults to the crate directory created by `cargoSetupHook`, or `./vendor/`. + +### `dontWrapGlycinLoaders` {#glycin-dont-wrap} + +Disable adding the Glycin loaders path `XDG_DATA_DIRS` with `wrapGAppsHook`. diff --git a/doc/languages-frameworks/gnome.section.md b/doc/languages-frameworks/gnome.section.md index 252f7ea3dea79..ecfda62b57007 100644 --- a/doc/languages-frameworks/gnome.section.md +++ b/doc/languages-frameworks/gnome.section.md @@ -129,6 +129,8 @@ The hooks do the following: - []{#ssec-gnome-hooks-gst-grl-plugins} Setup hooks of `gst_all_1.gstreamer` and `grilo` will populate the `GST_PLUGIN_SYSTEM_PATH_1_0` and `GRL_PLUGIN_PATH` variables, respectively, which will then be added to the wrapper by `wrapGApps*` hook. +- []{#ssec-gnome-hooks-libglycin} `libglycin`'s [setup hook](#libglycin-setup-hook) will populate `XDG_DATA_DIRS` with the path to the loaders. + You can also pass additional arguments to `makeWrapper` using `gappsWrapperArgs` in `preFixup` hook: ```nix diff --git a/doc/redirects.json b/doc/redirects.json index cbff4ea2f2261..4bb4441171893 100644 --- a/doc/redirects.json +++ b/doc/redirects.json @@ -2468,6 +2468,27 @@ "setup-hook-gdk-pixbuf": [ "index.html#setup-hook-gdk-pixbuf" ], + "libglycin-hooks": [ + "index.html#libglycin-hooks" + ], + "libglycin-setup-hook": [ + "index.html#libglycin-setup-hook" + ], + "libglycin-patch-vendor-hook": [ + "index.html#libglycin-patch-vendor-hook" + ], + "libglycin-hooks-example-code-snippet": [ + "index.html#libglycin-hooks-example-code-snippet" + ], + "libglycin-hook-variables-controlling": [ + "index.html#libglycin-hook-variables-controlling" + ], + "glycin-cargo-deps-path": [ + "index.html#glycin-cargo-deps-path" + ], + "glycin-dont-wrap": [ + "index.html#glycin-dont-wrap" + ], "ghc": [ "index.html#ghc" ], @@ -3158,6 +3179,9 @@ "ssec-gnome-hooks-gst-grl-plugins": [ "index.html#ssec-gnome-hooks-gst-grl-plugins" ], + "ssec-gnome-hooks-libglycin": [ + "index.html#ssec-gnome-hooks-libglycin" + ], "ssec-gnome-updating": [ "index.html#ssec-gnome-updating" ], diff --git a/pkgs/by-name/au/authenticator/package.nix b/pkgs/by-name/au/authenticator/package.nix index 082bada63e836..d17ae0756f478 100644 --- a/pkgs/by-name/au/authenticator/package.nix +++ b/pkgs/by-name/au/authenticator/package.nix @@ -21,7 +21,6 @@ sqlite, wayland, zbar, - glycin-loaders, nix-update-script, }: @@ -78,8 +77,6 @@ stdenv.mkDerivation (finalAttrs: { gappsWrapperArgs+=( # vp8enc preset --prefix GST_PRESET_PATH : "${gst_all_1.gst-plugins-good}/share/gstreamer-1.0/presets" - # See https://gitlab.gnome.org/sophie-h/glycin/-/blob/0.1.beta.2/glycin/src/config.rs#L44 - --prefix XDG_DATA_DIRS : "${glycin-loaders}/share" ) ''; diff --git a/pkgs/by-name/ba/bazaar/package.nix b/pkgs/by-name/ba/bazaar/package.nix index ac2d8b37cb26d..a274e9968ac42 100644 --- a/pkgs/by-name/ba/bazaar/package.nix +++ b/pkgs/by-name/ba/bazaar/package.nix @@ -9,7 +9,6 @@ pkg-config, wrapGAppsHook4, appstream, - bubblewrap, flatpak, glib-networking, glycin-loaders, @@ -18,6 +17,7 @@ libadwaita, libdex, libglycin, + libglycin-gtk4, libsoup_3, libxmlb, libyaml, @@ -56,6 +56,8 @@ stdenv.mkDerivation (finalAttrs: { libadwaita libdex libglycin + libglycin-gtk4 + glycin-loaders libsoup_3 libxmlb libyaml @@ -64,15 +66,7 @@ stdenv.mkDerivation (finalAttrs: { libsecret ]; - preFixup = '' - gappsWrapperArgs+=( - --prefix PATH : "$out/bin:${lib.makeBinPath [ bubblewrap ]}" - --prefix XDG_DATA_DIRS : "${glycin-loaders}/share" - ) - ''; - passthru = { - inherit (libglycin) glycinPathsPatch; updateScript = nix-update-script { }; }; diff --git a/pkgs/by-name/co/constrict/package.nix b/pkgs/by-name/co/constrict/package.nix index 8df59d9f2d9c5..caf6b88dbe7b4 100644 --- a/pkgs/by-name/co/constrict/package.nix +++ b/pkgs/by-name/co/constrict/package.nix @@ -11,6 +11,7 @@ desktop-file-utils, libadwaita, libglycin, + libglycin-gtk4, libva-utils, ffmpeg, gst-thumbnailers, @@ -42,6 +43,8 @@ python3Packages.buildPythonApplication (finalAttrs: { buildInputs = [ libadwaita libglycin + libglycin-gtk4 + glycin-loaders ]; dependencies = [ @@ -60,7 +63,6 @@ python3Packages.buildPythonApplication (finalAttrs: { preFixup = '' makeWrapperArgs+=( ''${gappsWrapperArgs[@]} - --prefix XDG_DATA_DIRS : "${glycin-loaders}/share" --prefix PATH : ${lib.makeBinPath finalAttrs.runtimeDeps} ) ''; diff --git a/pkgs/by-name/fr/fractal/package.nix b/pkgs/by-name/fr/fractal/package.nix index 57e2d580238e1..2aae752c96e69 100644 --- a/pkgs/by-name/fr/fractal/package.nix +++ b/pkgs/by-name/fr/fractal/package.nix @@ -23,10 +23,10 @@ libshumate, wrapGAppsHook4, blueprint-compiler, - bubblewrap, sqlite, xdg-desktop-portal, libseccomp, + libglycin, glycin-loaders, libwebp, }: @@ -64,6 +64,7 @@ stdenv.mkDerivation (finalAttrs: { glib grass-sass gtk4 + libglycin.patchVendorHook meson ninja pkg-config @@ -79,6 +80,8 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ glib + libglycin.setupHook + glycin-loaders gtk4 gtksourceview5 lcms2 @@ -99,13 +102,6 @@ stdenv.mkDerivation (finalAttrs: { gst-plugins-rs ]); - preFixup = '' - gappsWrapperArgs+=( - --prefix XDG_DATA_DIRS : "${glycin-loaders}/share" - --prefix PATH : "${lib.makeBinPath [ bubblewrap ]}" - ) - ''; - env.CARGO_BUILD_TARGET = stdenv.hostPlatform.rust.rustcTargetSpec; passthru = { diff --git a/pkgs/by-name/gl/glycin-loaders/package.nix b/pkgs/by-name/gl/glycin-loaders/package.nix index ea0eb152f4d4c..f9b97462d9156 100644 --- a/pkgs/by-name/gl/glycin-loaders/package.nix +++ b/pkgs/by-name/gl/glycin-loaders/package.nix @@ -1,13 +1,12 @@ { stdenv, lib, - fetchurl, cairo, cargo, gettext, - git, - gnome, + glib, gtk4, + libglycin, lcms2, libheif, libjxl, @@ -17,43 +16,34 @@ meson, ninja, pkg-config, + python3, + shared-mime-info, rustc, rustPlatform, - common-updater-scripts, - _experimental-update-script-combinators, }: stdenv.mkDerivation (finalAttrs: { pname = "glycin-loaders"; - version = "2.0.7"; - src = fetchurl { - url = "mirror://gnome/sources/glycin/${lib.versions.majorMinor finalAttrs.version}/glycin-${finalAttrs.version}.tar.xz"; - hash = "sha256-xBasKbbT7NxnuQwVU3uhKTzrevlvoQHK5nt9HTflCrA="; - }; - - cargoDeps = rustPlatform.fetchCargoVendor { - inherit (finalAttrs) src; - name = "glycin-loaders-deps-${finalAttrs.version}"; - hash = "sha256-UVVVjMt4vWkLob0H/MxIaW6rkBSFImu+5dezaCnc3Q8="; - dontConfigure = true; - }; + inherit (libglycin) version src cargoDeps; nativeBuildInputs = [ cargo gettext # for msgfmt - git meson ninja pkg-config rustc rustPlatform.cargoSetupHook + ] + ++ lib.optionals finalAttrs.finalPackage.doCheck [ + python3 + # Tests use Rust glycin library. + libglycin.patchVendorHook ]; buildInputs = [ - gtk4 # for GdkTexture cairo - lcms2 libheif libxml2 # for librsvg crate librsvg @@ -61,12 +51,20 @@ stdenv.mkDerivation (finalAttrs: { libjxl ]; + # Tests in passthru.tests to avoid dependency cycles. + checkInputs = [ + glib + gtk4 + lcms2 + ]; + mesonFlags = [ "-Dglycin-loaders=true" "-Dglycin-thumbnailer=false" "-Dlibglycin=false" "-Dlibglycin-gtk4=false" "-Dvapi=false" + (lib.mesonBool "tests" finalAttrs.finalPackage.doCheck) ]; strictDeps = true; @@ -74,38 +72,30 @@ stdenv.mkDerivation (finalAttrs: { postPatch = '' substituteInPlace glycin-loaders/meson.build \ --replace-fail "cargo_target_dir / rust_target / loader," "cargo_target_dir / '${stdenv.hostPlatform.rust.cargoShortTarget}' / rust_target / loader," + '' + + lib.optionalString finalAttrs.finalPackage.doCheck '' + chmod +x build-aux/setup-integration-test.py + + patchShebangs \ + build-aux/setup-integration-test.py + ''; + + preCheck = lib.optionalString finalAttrs.finalPackage.doCheck '' + # Fix test files being considered application/octet-stream + export XDG_DATA_DIRS=${shared-mime-info}/share:$XDG_DATA_DIRS + + # fonts test will not be able to create cache without this + export XDG_CACHE_HOME=$(mktemp -d) ''; env.CARGO_BUILD_TARGET = stdenv.hostPlatform.rust.rustcTargetSpec; passthru = { - updateScript = - let - updateSource = gnome.updateScript { - attrPath = "glycin-loaders"; - packageName = "glycin"; - }; - updateLockfile = { - command = [ - "sh" - "-c" - '' - PATH=${ - lib.makeBinPath [ - common-updater-scripts - ] - } - update-source-version glycin-loaders --ignore-same-version --source-key=cargoDeps.vendorStaging > /dev/null - '' - ]; - # Experimental feature: do not copy! - supportedFeatures = [ "silent" ]; - }; - in - _experimental-update-script-combinators.sequence [ - updateSource - updateLockfile - ]; + tests = { + withTests = finalAttrs.finalPackage.overrideAttrs { + doCheck = true; + }; + }; }; meta = { diff --git a/pkgs/by-name/gs/gst-thumbnailers/package.nix b/pkgs/by-name/gs/gst-thumbnailers/package.nix index 3b84499f8a7c2..2ae9a3cd9b187 100644 --- a/pkgs/by-name/gs/gst-thumbnailers/package.nix +++ b/pkgs/by-name/gs/gst-thumbnailers/package.nix @@ -49,14 +49,9 @@ stdenv.mkDerivation (finalAttrs: { gst_all_1.gst-plugins-ugly fontconfig libglycin + glycin-loaders ]; - preFixup = '' - gappsWrapperArgs+=( - --prefix XDG_DATA_DIRS : "${glycin-loaders}/share" - ) - ''; - meta = { description = "Generate thumbnailer for video and audio files"; homepage = "https://gitlab.gnome.org/GNOME/gst-thumbnailers"; diff --git a/pkgs/by-name/hi/highscore-unwrapped/package.nix b/pkgs/by-name/hi/highscore-unwrapped/package.nix index 1a309c758d21d..e4d44e8ed8da9 100644 --- a/pkgs/by-name/hi/highscore-unwrapped/package.nix +++ b/pkgs/by-name/hi/highscore-unwrapped/package.nix @@ -17,6 +17,7 @@ libadwaita, libarchive, libglycin, + libglycin-gtk4, libhighscore, libmanette, sqlite, @@ -92,6 +93,7 @@ stdenv.mkDerivation (finalAttrs: { libadwaita libarchive libglycin + libglycin-gtk4 libhighscore libmanette-1-alpha sqlite diff --git a/pkgs/by-name/li/libglycin-gtk4/package.nix b/pkgs/by-name/li/libglycin-gtk4/package.nix new file mode 100644 index 0000000000000..bc1b85315bd22 --- /dev/null +++ b/pkgs/by-name/li/libglycin-gtk4/package.nix @@ -0,0 +1,102 @@ +{ + lib, + stdenv, + cargo, + fontconfig, + gi-docgen, + glib, + gobject-introspection, + gtk4, + lcms2, + libglycin, + libseccomp, + meson, + ninja, + pkg-config, + python3, + rustPlatform, + rustc, + vala, + buildPackages, + withIntrospection ? + lib.meta.availableOn stdenv.hostPlatform gobject-introspection + && stdenv.hostPlatform.emulatorAvailable buildPackages, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "libglycin-gtk4"; + + outputs = [ + "out" + "dev" + "devdoc" + ]; + + inherit (libglycin) version src cargoDeps; + + nativeBuildInputs = [ + meson + ninja + pkg-config + rustc + cargo + python3 + rustPlatform.cargoSetupHook + ] + ++ lib.optionals withIntrospection [ + vala + gi-docgen + gobject-introspection + ]; + + buildInputs = [ + fontconfig + glib + libseccomp + lcms2 + gtk4 + ]; + + propagatedBuildInputs = [ + libglycin + gtk4 + # TODO: these should not be required by .pc file + fontconfig + libseccomp + lcms2 + ]; + + mesonFlags = [ + (lib.mesonBool "glycin-loaders" false) + (lib.mesonBool "glycin-thumbnailer" false) + (lib.mesonBool "libglycin" false) + (lib.mesonBool "libglycin-gtk4" true) + (lib.mesonBool "introspection" withIntrospection) + (lib.mesonBool "vapi" withIntrospection) + (lib.mesonBool "capi_docs" withIntrospection) + ]; + + postPatch = '' + patchShebangs \ + build-aux/crates-version.py + ''; + + postFixup = '' + # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back. + moveToOutput "share/doc" "$devdoc" + ''; + + meta = { + description = "C-Bindings to convert glycin frames to GDK Textures"; + homepage = "https://gitlab.gnome.org/GNOME/glycin"; + license = with lib.licenses; [ + mpl20 # or + lgpl21Plus + ]; + teams = [ lib.teams.gnome ]; + platforms = lib.platforms.linux; + pkgConfigModules = [ + "glycin-gtk4-1" + ]; + }; +}) diff --git a/pkgs/by-name/li/libglycin/fix-glycin-3-paths.patch b/pkgs/by-name/li/libglycin/fix-glycin-3-paths.patch deleted file mode 100644 index 35b22f06fa367..0000000000000 --- a/pkgs/by-name/li/libglycin/fix-glycin-3-paths.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/vendor/glycin/src/sandbox.rs b/vendor/glycin/src/sandbox.rs -index 90cd5f6..17a6469 100644 ---- a/vendor/glycin/src/sandbox.rs -+++ b/vendor/glycin/src/sandbox.rs -@@ -251,7 +251,7 @@ impl Sandbox { - } - - async fn bwrap_command(&self, seccomp_memfd: &Memfd) -> Result { -- let mut command = Command::new("bwrap"); -+ let mut command = Command::new("@bwrap@"); - - command.args([ - "--unshare-all", diff --git a/pkgs/by-name/li/libglycin/package.nix b/pkgs/by-name/li/libglycin/package.nix index ff497becdea53..15ea7bb02d7b6 100644 --- a/pkgs/by-name/li/libglycin/package.nix +++ b/pkgs/by-name/li/libglycin/package.nix @@ -1,7 +1,8 @@ { lib, stdenv, - fetchFromGitLab, + fetchurl, + makeSetupHook, meson, ninja, pkg-config, @@ -11,13 +12,18 @@ rustPlatform, vala, gi-docgen, + glib, gobject-introspection, + glycin-loaders, + libglycin-gtk4, + fontconfig, libseccomp, lcms2, - gtk4, gnome, replaceVars, bubblewrap, + jq, + moreutils, common-updater-scripts, _experimental-update-script-combinators, buildPackages, @@ -29,12 +35,22 @@ stdenv.mkDerivation (finalAttrs: { pname = "libglycin"; version = "2.0.7"; - src = fetchFromGitLab { - domain = "gitlab.gnome.org"; - owner = "GNOME"; - repo = "glycin"; - tag = finalAttrs.version; - hash = "sha256-17ebdiLMuDJuuw8TBYWamyyDM4aZgtWRWEQhWGb/2mw="; + outputs = [ + "out" + "dev" + "devdoc" + ]; + + setupHook = ./path-hook.sh; + + src = fetchurl { + url = "mirror://gnome/sources/glycin/${lib.versions.majorMinor finalAttrs.version}/glycin-${finalAttrs.version}.tar.xz"; + hash = "sha256-xBasKbbT7NxnuQwVU3uhKTzrevlvoQHK5nt9HTflCrA="; + }; + + cargoDeps = rustPlatform.fetchCargoVendor { + inherit (finalAttrs) pname version src; + hash = "sha256-UVVVjMt4vWkLob0H/MxIaW6rkBSFImu+5dezaCnc3Q8="; }; nativeBuildInputs = [ @@ -45,6 +61,7 @@ stdenv.mkDerivation (finalAttrs: { cargo python3 rustPlatform.cargoSetupHook + finalAttrs.passthru.patchVendorHook ] ++ lib.optionals withIntrospection [ vala @@ -52,18 +69,16 @@ stdenv.mkDerivation (finalAttrs: { gobject-introspection ]; - cargoDeps = rustPlatform.fetchCargoVendor { - inherit (finalAttrs) pname version src; - hash = "sha256-7x4Ts0wRFoxZ2u3AHVEey8g6+XWDpxM/hFZeomkojKU="; - }; - buildInputs = [ + fontconfig libseccomp lcms2 - gtk4 ]; propagatedBuildInputs = [ + glib + # TODO: these should not be required by .pc file + fontconfig libseccomp lcms2 ]; @@ -72,18 +87,22 @@ stdenv.mkDerivation (finalAttrs: { (lib.mesonBool "glycin-loaders" false) (lib.mesonBool "glycin-thumbnailer" false) (lib.mesonBool "libglycin" true) + (lib.mesonBool "libglycin-gtk4" false) (lib.mesonBool "introspection" withIntrospection) (lib.mesonBool "vapi" withIntrospection) (lib.mesonBool "capi_docs" withIntrospection) ]; postPatch = '' - patch -p2 < ${finalAttrs.passthru.glycin3PathsPatch} - patchShebangs \ build-aux/crates-version.py ''; + postFixup = '' + # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back. + moveToOutput "share/doc" "$devdoc" + ''; + passthru = { updateScript = let @@ -113,12 +132,24 @@ stdenv.mkDerivation (finalAttrs: { updateLockfile ]; - glycinPathsPatch = replaceVars ./fix-glycin-paths.patch { - bwrap = "${bubblewrap}/bin/bwrap"; - }; + patchVendorHook = + makeSetupHook + { + name = "glycinPatchVendorHook"; + } + ( + replaceVars ./patch-vendor-hook.sh { + bwrap = "${bubblewrap}/bin/bwrap"; + jq = "${jq}/bin/jq"; + sponge = "${moreutils}/bin/sponge"; + } + ); - glycin3PathsPatch = replaceVars ./fix-glycin-3-paths.patch { - bwrap = "${bubblewrap}/bin/bwrap"; + tests = { + inherit + glycin-loaders + libglycin-gtk4 + ; }; }; @@ -135,7 +166,6 @@ stdenv.mkDerivation (finalAttrs: { platforms = lib.platforms.linux; pkgConfigModules = [ "glycin-1" - "glycin-gtk4-1" ]; }; }) diff --git a/pkgs/by-name/li/libglycin/patch-vendor-hook.sh b/pkgs/by-name/li/libglycin/patch-vendor-hook.sh new file mode 100644 index 0000000000000..9cc9f2b172e54 --- /dev/null +++ b/pkgs/by-name/li/libglycin/patch-vendor-hook.sh @@ -0,0 +1,43 @@ +libglycinPatchVendorHook() { + echo "executing libglycinPatchVendorHook" + + local glycinPath + + if [[ -z ${glycinCargoDepsPath:-} ]]; then + # When cargoSetupHook is used, `cargoDepsCopy` would be set and preferred. + # Otherwise, fallback to vendor/ + local cargoDepsPath=${cargoDepsCopy:-vendor} + fi + + while read -r path; do + # Ensure the paths we're patching exist (and that this crate probably isn't something like glycin-utils) + if [[ -f $path/src/sandbox.rs ]]; then + glycinPath="$path" + break + fi + done < <(find "$cargoDepsPath" -type d -name 'glycin*') + + if [[ -z ${glycinPath:-} ]]; then + echo >&2 "error: glycin was not found within the cargo dependencies at '$cargoDepsPath'." + echo >&2 "are you sure libglycin.patchVendorHook is still required?" + exit 1 + fi + echo "patching glycin crate at '$glycinPath'" + + # Allow use in non-FHS environments like tests in Nix build sandbox. + substituteInPlace "$glycinPath/src/sandbox.rs" \ + --replace-fail '"--ro-bind", + "/usr",' '"--ro-bind-try", "/usr",' + + substituteInPlace "$glycinPath/src/sandbox.rs" \ + --replace-fail '"bwrap"' '"@bwrap@"' + + # Replace hash of file we patch in vendored glycin. + @jq@ \ + --arg hash "$(sha256sum "$glycinPath/src/sandbox.rs" | cut -d' ' -f 1)" \ + '.files."src/sandbox.rs" = $hash' \ + "$glycinPath/.cargo-checksum.json" | + @sponge@ "$glycinPath/.cargo-checksum.json" +} + +prePatchHooks+=(libglycinPatchVendorHook) diff --git a/pkgs/by-name/li/libglycin/path-hook.sh b/pkgs/by-name/li/libglycin/path-hook.sh new file mode 100644 index 0000000000000..19de8ecfbec2a --- /dev/null +++ b/pkgs/by-name/li/libglycin/path-hook.sh @@ -0,0 +1,18 @@ +find_glycin_loader_paths() { + if [ -d "$1/share/glycin-loaders" ]; then + addToSearchPath NIX_GLYCIN_LOADER_PATHS $1/share + fi +} + +addEnvHooks "$hostOffset" find_glycin_loader_paths + +glycinLoadersWrapperArgsHook() { + echo "executing glycinLoadersWrapperArgsHook" + if [[ -n "$NIX_GLYCIN_LOADER_PATHS" ]]; then + gappsWrapperArgs+=(--prefix XDG_DATA_DIRS : "$NIX_GLYCIN_LOADER_PATHS") + fi +} + +if [[ -z ${dontWrapGlycinLoaders:-} ]]; then + preFixupPhases+=(glycinLoadersWrapperArgsHook) +fi diff --git a/pkgs/by-name/lo/loupe/package.nix b/pkgs/by-name/lo/loupe/package.nix index 8b08bc09e80f7..d441f1708c7f7 100644 --- a/pkgs/by-name/lo/loupe/package.nix +++ b/pkgs/by-name/lo/loupe/package.nix @@ -48,6 +48,7 @@ stdenv.mkDerivation (finalAttrs: { cargo desktop-file-utils itstool + libglycin.patchVendorHook meson ninja pkg-config @@ -57,6 +58,8 @@ stdenv.mkDerivation (finalAttrs: { ]; buildInputs = [ + libglycin.setupHook + glycin-loaders gtk4 lcms2 libadwaita @@ -64,22 +67,6 @@ stdenv.mkDerivation (finalAttrs: { libseccomp ]; - preConfigure = '' - # Dirty approach to add patches after cargoSetupPostUnpackHook - # We should eventually use a cargo vendor patch hook instead - pushd ../$(stripHash $cargoDeps)/glycin-3.* - patch -p3 < ${libglycin.passthru.glycin3PathsPatch} - popd - ''; - - preFixup = '' - # Needed for the glycin crate to find loaders. - # https://gitlab.gnome.org/sophie-h/glycin/-/blob/0.1.beta.2/glycin/src/config.rs#L44 - gappsWrapperArgs+=( - --prefix XDG_DATA_DIRS : "${glycin-loaders}/share" - ) - ''; - # For https://gitlab.gnome.org/GNOME/loupe/-/blob/0e6ddb0227ac4f1c55907f8b43eaef4bb1d3ce70/src/meson.build#L34-35 env.CARGO_BUILD_TARGET = stdenv.hostPlatform.rust.rustcTargetSpec; diff --git a/pkgs/by-name/li/libglycin/fix-glycin-paths.patch b/pkgs/by-name/re/recordbox/fix-glycin-paths.patch similarity index 100% rename from pkgs/by-name/li/libglycin/fix-glycin-paths.patch rename to pkgs/by-name/re/recordbox/fix-glycin-paths.patch diff --git a/pkgs/by-name/re/recordbox/package.nix b/pkgs/by-name/re/recordbox/package.nix index 0678773dacd5a..7f6a77a9b37f2 100644 --- a/pkgs/by-name/re/recordbox/package.nix +++ b/pkgs/by-name/re/recordbox/package.nix @@ -3,12 +3,12 @@ stdenv, appstream-glib, blueprint-compiler, + bubblewrap, cargo, dbus, desktop-file-utils, fetchFromGitea, glib, - libglycin, glycin-loaders, gst_all_1, gtk4, @@ -21,12 +21,19 @@ ninja, nix-update-script, pkg-config, + replaceVars, rustPlatform, rustc, sqlite, wrapGAppsHook4, }: +let + glycinPathsPatch = replaceVars ./fix-glycin-paths.patch { + bwrap = "${bubblewrap}/bin/bwrap"; + }; +in + stdenv.mkDerivation (finalAttrs: { pname = "recordbox"; version = "0.10.4"; @@ -91,7 +98,7 @@ stdenv.mkDerivation (finalAttrs: { # Dirty approach to add patches after cargoSetupPostUnpackHook # We should eventually use a cargo vendor patch hook instead pushd ../$(stripHash $cargoDeps)/glycin-2.* - patch -p3 < ${libglycin.passthru.glycinPathsPatch} + patch -p3 < ${glycinPathsPatch} popd ''; preFixup = '' diff --git a/pkgs/by-name/sn/snapshot/package.nix b/pkgs/by-name/sn/snapshot/package.nix index 27f72987a6795..449fe3e4e350c 100644 --- a/pkgs/by-name/sn/snapshot/package.nix +++ b/pkgs/by-name/sn/snapshot/package.nix @@ -6,9 +6,7 @@ glycin-loaders, cargo, desktop-file-utils, - jq, meson, - moreutils, ninja, pkg-config, rustc, @@ -34,19 +32,13 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-NVj2+ODTiylQtrrZue7COCSb7f7c5w+1iijK1pRebOk="; }; - patches = [ - # Fix paths in glycin library - libglycin.passthru.glycin3PathsPatch - ]; - cargoVendorDir = "vendor"; nativeBuildInputs = [ cargo desktop-file-utils - jq + libglycin.patchVendorHook meson - moreutils # sponge is used in postPatch ninja pkg-config rustc @@ -56,6 +48,8 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ glib + libglycin.setupHook + glycin-loaders gst_all_1.gst-plugins-bad gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good @@ -70,13 +64,6 @@ stdenv.mkDerivation (finalAttrs: { ]; postPatch = '' - # Replace hash of file we patch in vendored glycin. - jq \ - --arg hash "$(sha256sum vendor/glycin/src/sandbox.rs | cut -d' ' -f 1)" \ - '.files."src/sandbox.rs" = $hash' \ - vendor/glycin/.cargo-checksum.json \ - | sponge vendor/glycin/.cargo-checksum.json - substituteInPlace src/meson.build --replace-fail \ "'src' / rust_target / meson.project_name()" \ "'src' / '${stdenv.hostPlatform.rust.cargoShortTarget}' / rust_target / meson.project_name()" @@ -86,8 +73,6 @@ stdenv.mkDerivation (finalAttrs: { gappsWrapperArgs+=( # vp8enc preset --prefix GST_PRESET_PATH : "${gst_all_1.gst-plugins-good}/share/gstreamer-1.0/presets" - # See https://gitlab.gnome.org/sophie-h/glycin/-/blob/0.1.beta.2/glycin/src/config.rs#L44 - --prefix XDG_DATA_DIRS : "${glycin-loaders}/share" ) ''; diff --git a/pkgs/by-name/tu/turntable/package.nix b/pkgs/by-name/tu/turntable/package.nix index 078190806a3cb..7cb19fec3855c 100644 --- a/pkgs/by-name/tu/turntable/package.nix +++ b/pkgs/by-name/tu/turntable/package.nix @@ -13,6 +13,7 @@ json-glib, libsecret, libglycin, + libglycin-gtk4, glib-networking, glycin-loaders, @@ -48,6 +49,8 @@ stdenv.mkDerivation (finalAttrs: { json-glib libsecret libglycin + libglycin-gtk4 + glycin-loaders glib-networking ]; @@ -58,12 +61,6 @@ stdenv.mkDerivation (finalAttrs: { strictDeps = true; - preFixup = '' - gappsWrapperArgs+=( - --prefix XDG_DATA_DIRS : "${glycin-loaders}/share" - ) - ''; - meta = { description = "Scrobbles your music to multiple services with playback controls for MPRIS players"; longDescription = '' diff --git a/pkgs/by-name/va/valent/package.nix b/pkgs/by-name/va/valent/package.nix index a59479fe7267f..4e8fee88a9cf2 100644 --- a/pkgs/by-name/va/valent/package.nix +++ b/pkgs/by-name/va/valent/package.nix @@ -61,6 +61,7 @@ stdenv.mkDerivation (finalAttrs: { json-glib libadwaita libglycin + glycin-loaders libpeas2 libphonenumber libportal-gtk4 @@ -69,12 +70,6 @@ stdenv.mkDerivation (finalAttrs: { tinysparql ]; - preFixup = '' - gappsWrapperArgs+=( - --prefix XDG_DATA_DIRS : "${glycin-loaders}/share" - ) - ''; - passthru.updateScript = nix-update-script { }; meta = {