NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.49k stars 12.99k forks source link

swaybg fails to render webp: Couldn’t recognize the image file format #321983

Open KiaraGrouwstra opened 2 weeks ago

KiaraGrouwstra commented 2 weeks ago

Describe the bug

as per https://github.com/swaywm/swaybg/issues/76, webp images seem rejected by swaybg under NixOS.

Steps To Reproduce

Steps to reproduce the behavior:

  1. install swaybg and webp-pixbuf-loader
  2. swaybg -i img.webp
  3. find error: [background-image.c:30] Failed to load background image (Couldn’t recognize the image file format for file “img.webp”).

Expected behavior

any image formats supported by swaybg work

Additional context

this may be about gdk-pixbuf detecting webp-pixbuf-loader, tho its package does do stuff about this (and confirmed on my end, libpixbufloader-webp.so is present in /run/current-system/sw/lib/gdk-pixbuf-2.0/2.10.0/loaders/ and /etc/profiles/per-user/kiara/lib/gdk-pixbuf-2.0/2.10.0/loaders/).

c.f. #221017 similarly mentions webp issues in gdk-pixbuf, tho using librsvg

Notify maintainers

@primeos @bobby285271 @hedning @jtojnar @dasj19 @cwyc

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.9.2-zen1, NixOS, 24.11 (Vicuña), 24.11.20240525.47e03a6`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Lix, like Nix) 2.90.0-beta.1-lixpre20240506-b6799ab`
 - nixpkgs: `/run/current-system/nixpkgs`
jtojnar commented 2 weeks ago

Programs generally do not load stuff from /run/current-system/sw/lib – otherwise, we could return to just using /usr/lib. In this case, you need to add webp-pixbuf-loader to swaybg package using a wrapper that sets GDK_PIXBUF_MODULE_FILE environment variable. See eog for an example:

https://github.com/NixOS/nixpkgs/blob/2b14afdba35b51a1a9f841d695d2254f5f1eadca/pkgs/desktops/gnome/core/eog/default.nix#L84-L95

Also please always open an issue downstream (in Nixpkgs) before going upstream, unless you are sure it is an upstream issue.

KiaraGrouwstra commented 2 weeks ago

i tested creating a local overlay adding a similar attribute:

prev.swaybg.overrideAttrs (oa: {
  postInstall = ''
    # Pull in WebP and JXL support
    export GDK_PIXBUF_MODULE_FILE="${pkgs.gnome._gdkPixbufCacheBuilder_DO_NOT_USE {
      extraLoaders = [
        pkgs.libjxl
        pkgs.librsvg
        pkgs.webp-pixbuf-loader
        pkgs.libheif.out
      ];
    }}"
  '';
})

it looks like this did not resolve the issue yet however.

jtojnar commented 2 weeks ago

That's just one part. You also need the wrapper.