diff --git a/pkgs/by-name/gl/glycin-loaders/package.nix b/pkgs/by-name/gl/glycin-loaders/package.nix index f9b97462d915..bb6e645bb5f1 100644 --- a/pkgs/by-name/gl/glycin-loaders/package.nix +++ b/pkgs/by-name/gl/glycin-loaders/package.nix @@ -20,8 +20,20 @@ shared-mime-info, rustc, rustPlatform, + + # List of loaders to build. + # https://gitlab.gnome.org/GNOME/glycin/-/blob/2.1.1/meson_options.txt?ref_type=tags#L26-43 + enabledLoaders ? [ + "heif" + "image-rs" + "jxl" + "svg" + ], }: +# Doesn't produce any output if no loaders are enabled +assert enabledLoaders != [ ]; + stdenv.mkDerivation (finalAttrs: { pname = "glycin-loaders"; @@ -59,12 +71,15 @@ stdenv.mkDerivation (finalAttrs: { ]; mesonFlags = [ - "-Dglycin-loaders=true" - "-Dglycin-thumbnailer=false" - "-Dlibglycin=false" - "-Dlibglycin-gtk4=false" - "-Dvapi=false" + (lib.mesonBool "glycin-loaders" true) + (lib.mesonBool "glycin-thumbnailer" false) + (lib.mesonBool "libglycin" false) + (lib.mesonBool "libglycin-gtk4" false) + (lib.mesonBool "vapi" false) (lib.mesonBool "tests" finalAttrs.finalPackage.doCheck) + (lib.mesonOption "loaders" ( + lib.concatMapStringsSep "," (loader: "glycin-${loader}") enabledLoaders + )) ]; strictDeps = true; @@ -88,9 +103,16 @@ stdenv.mkDerivation (finalAttrs: { export XDG_CACHE_HOME=$(mktemp -d) ''; + # Thumbnailer files are provided by glycin-thumbnailer + postInstall = '' + rm -r $out/share/thumbnailers + ''; + env.CARGO_BUILD_TARGET = stdenv.hostPlatform.rust.rustcTargetSpec; passthru = { + inherit enabledLoaders; + tests = { withTests = finalAttrs.finalPackage.overrideAttrs { doCheck = true; @@ -102,10 +124,12 @@ stdenv.mkDerivation (finalAttrs: { description = "Glycin loaders for several formats"; homepage = "https://gitlab.gnome.org/GNOME/glycin"; teams = [ lib.teams.gnome ]; - license = with lib.licenses; [ - mpl20 # or - lgpl21Plus - ]; + license = + with lib.licenses; + OR [ + mpl20 + lgpl21Plus + ]; platforms = lib.platforms.linux; }; }) diff --git a/pkgs/by-name/gl/glycin-thumbnailer/package.nix b/pkgs/by-name/gl/glycin-thumbnailer/package.nix new file mode 100644 index 000000000000..f90b4dd1e43e --- /dev/null +++ b/pkgs/by-name/gl/glycin-thumbnailer/package.nix @@ -0,0 +1,100 @@ +{ + lib, + stdenv, + callPackage, + cargo, + fontconfig, + glib, + glycin-loaders, + glycin-thumbnailer, + libglycin, + libseccomp, + meson, + ninja, + pkg-config, + rustc, + rustPlatform, + wrapGAppsNoGuiHook, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "glycin-thumbnailer"; + + inherit (libglycin) version src cargoDeps; + + nativeBuildInputs = [ + cargo + libglycin.patchVendorHook + meson + ninja + pkg-config + rustc + rustPlatform.cargoSetupHook + wrapGAppsNoGuiHook + ]; + + buildInputs = [ + fontconfig + glib + glycin-loaders + libglycin + libglycin.setupHook + libseccomp + ]; + + mesonFlags = [ + (lib.mesonBool "glycin-loaders" false) + (lib.mesonBool "glycin-thumbnailer" true) + (lib.mesonBool "libglycin" false) + (lib.mesonBool "libglycin-gtk4" false) + ]; + + strictDeps = true; + __structuredAttrs = true; + + # Thumbnailer files are in `glycin-loaders`, but we provide them in this package + postInstall = '' + mkdir -p $out/share/thumbnailers + ( + shopt -s failglob + + for loader in ${lib.concatStringsSep " " glycin-loaders.passthru.enabledLoaders}; do + substitute \ + "../glycin-loaders/glycin-$loader/glycin-$loader.thumbnailer.in" \ + "$out/share/thumbnailers/glycin-$loader.thumbnailer" \ + --subst-var-by "BINDIR" "$out/bin" + done + ) + ''; + + passthru.tests = { + all-loaders = glycin-thumbnailer.override { + glycin-loaders = glycin-loaders.override { + enabledLoaders = [ + "heif" + "image-rs" + "jxl" + "raw" + "svg" + ]; + }; + }; + thumbnailer = callPackage ./tests.nix { }; + }; + + meta = { + description = "Glycin thumbnailers for several formats"; + homepage = "https://gitlab.gnome.org/GNOME/glycin"; + changelog = "https://gitlab.gnome.org/GNOME/glycin/-/tags/${finalAttrs.version}"; + license = + with lib.licenses; + OR [ + mpl20 + lgpl21Plus + ]; + maintainers = with lib.maintainers; [ thunze ]; + teams = [ lib.teams.gnome ]; + platforms = lib.platforms.linux; + mainProgram = "glycin-thumbnailer"; + }; +}) diff --git a/pkgs/by-name/gl/glycin-thumbnailer/tests.nix b/pkgs/by-name/gl/glycin-thumbnailer/tests.nix new file mode 100644 index 000000000000..da7f2a845de1 --- /dev/null +++ b/pkgs/by-name/gl/glycin-thumbnailer/tests.nix @@ -0,0 +1,44 @@ +{ + lib, + stdenv, + fetchFromGitLab, + glycin-thumbnailer, + shared-mime-info, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "glycin-thumbnailer-test"; + inherit (glycin-thumbnailer) version; + + src = fetchFromGitLab { + domain = "gitlab.gnome.org"; + owner = "sophie-h"; + repo = "test-images"; + rev = "f7a06d9131a5686c1b58c56f42f9fda9ea5e620d"; + hash = "sha256-qoteYmliUha3lY21PRM0FaeYu9aD5MsygBTsTYog9SE="; + }; + + # Fix incorrectly detected MIME types + preBuild = '' + export XDG_DATA_DIRS=${shared-mime-info}/share:$XDG_DATA_DIRS + ''; + + buildPhase = '' + runHook preBuild + + cd images/ + mkdir -p $out + + for image in color/* icon/*; do + for size in 128 256 512 1024; do + input="file://$(realpath "$image")" + output="$out/$(basename "$image")-$size.png" + + ${lib.getExe glycin-thumbnailer} -i "$input" -o "$output" -s $size + file -E "$output" + done + done + + runHook postBuild + ''; +}) diff --git a/pkgs/by-name/li/libglycin-gtk4/package.nix b/pkgs/by-name/li/libglycin-gtk4/package.nix index f5b46f1d68b3..b5181f595b22 100644 --- a/pkgs/by-name/li/libglycin-gtk4/package.nix +++ b/pkgs/by-name/li/libglycin-gtk4/package.nix @@ -96,10 +96,12 @@ stdenv.mkDerivation (finalAttrs: { 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 - ]; + license = + with lib.licenses; + OR [ + mpl20 + lgpl21Plus + ]; teams = [ lib.teams.gnome ]; platforms = lib.platforms.linux; pkgConfigModules = [ diff --git a/pkgs/by-name/li/libglycin/package.nix b/pkgs/by-name/li/libglycin/package.nix index 9ee9bb5df921..3a42bc136d27 100644 --- a/pkgs/by-name/li/libglycin/package.nix +++ b/pkgs/by-name/li/libglycin/package.nix @@ -15,6 +15,7 @@ glib, gobject-introspection, glycin-loaders, + glycin-thumbnailer, libglycin-gtk4, fontconfig, libseccomp, @@ -153,6 +154,7 @@ stdenv.mkDerivation (finalAttrs: { tests = { inherit glycin-loaders + glycin-thumbnailer libglycin-gtk4 ; }; @@ -162,10 +164,12 @@ stdenv.mkDerivation (finalAttrs: { description = "Sandboxed and extendable image loading library"; homepage = "https://gitlab.gnome.org/GNOME/glycin"; changelog = "https://gitlab.gnome.org/GNOME/glycin/-/tags/${finalAttrs.version}"; - license = with lib.licenses; [ - mpl20 # or - lgpl21Plus - ]; + license = + with lib.licenses; + OR [ + mpl20 + lgpl21Plus + ]; maintainers = [ ]; teams = [ lib.teams.gnome ]; platforms = lib.platforms.linux;