Skip to content

Commit

Permalink
corrected mistakes
Browse files Browse the repository at this point in the history
will be squashed before merging
  • Loading branch information
cwyc committed May 25, 2022
1 parent 5ebf782 commit fd073f9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions doc/languages-frameworks/gnome.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ To allow software to use various virtual file systems, `gvfs` package can be als

### GdkPixbuf loaders {#ssec-gnome-gdk-pixbuf-loaders}

GTK applications typically use [GdkPixbuf](https://developer.gnome.org/gdk-pixbuf/stable/) to load images. But `gdk-pixbuf` package only supports basic bitmap formats like JPEG, PNG or TIFF, requiring to use third-party loader modules for other formats. GTK itself includes SVG icons, which cannot be rendered without a loader provided by `librsvg`.
GTK applications typically use [GdkPixbuf](https://developer.gnome.org/gdk-pixbuf/stable/) to load images. But `gdk-pixbuf` package only supports basic bitmap formats like JPEG, PNG or TIFF, requiring third-party loader modules for other formats. GTK itself includes SVG icons, which cannot be rendered without a loader provided by `librsvg`.

Each loader package will contain a `lib/gdk-pixbuf-2.0/2.10.0/loaders.cache` file containing information about the available loaders. GdkPixbuf looks for these files in the `GDK_PIXBUF_MODULE_FILE` environment variable. Although upstream GdkPixbuf only supports a single file, in nixpkgs it is patched to accept multiple files, separated by `:`.

[`wrapGAppsHook`]{#ssec-gnome-hooks-wrapgappshook} handles setting `GDK_PIXBUF_MODULE_FILE` for GTK apps. If you're manually constructing a wrapper, consider `--prefix`ing the variable rather than overwriting it, so that users can extend your program's capabilities through `services.xserver.gdk-pixbuf.modulePackages`.
[`wrapGAppsHook`](#ssec-gnome-hooks-wrapgappshook) handles setting `GDK_PIXBUF_MODULE_FILE` for GTK apps. If you're manually constructing a wrapper, consider `--prefix`ing the variable rather than overwriting it, so that users can extend your program's capabilities through `services.xserver.gdk-pixbuf.modulePackages`.

### Icons {#ssec-gnome-icons}

Expand Down
24 changes: 14 additions & 10 deletions pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ makeSetupHook {
makeWrapper
];
substitutions = {
STANDARD_GDK_PIXBUF_MODULES = lib.makeSearchPathOutput "lib" gdk-pixbuf.cacheFile [ gdk-pixbuf librsvg ];
GDK_PIXBUF_CACHE_FILE = gdk-pixbuf.cacheFile;
standardGdkPixbufModules = lib.makeSearchPathOutput "lib" gdk-pixbuf.cacheFile [ gdk-pixbuf librsvg ];
gdkPixbufCacheFile = gdk-pixbuf.cacheFile;

passthru.tests = let
sample-project = ./tests/sample-project;
Expand Down Expand Up @@ -71,24 +71,28 @@ makeSetupHook {
# Stopgap as no modules have been packaged yet
mock-pixbuf-module = stdenv.mkDerivation {
name = "mock-gdk-pixbuf-module";
outputs = ["lib"];
builder = ''
outputs = ["out" "lib"];
dontUnpack = true;
buildPhase = ''
mkdir -p $out
mkdir -p $lib/$(dirname ${gdk-pixbuf.cacheFile})
touch $lib/${gdk-pixbuf.cacheFile}
'';
dontInstall = true;
dontFixup = true;
};

pixbuf-modules = basic.overrideAttrs (old: {extraGdkPixbufModules = [mock-pixbuf-module];});

pixbuf-modules-check = let
tested = pixbuf-modules;
in testLib.runTest "pixbuf-modules-check" ''
${expectSomeLineContainingYInFileXToMentionZ "${tested}/bin/foo" "GDK_PIXBUF_MODULE_FILE=" "${gdk-pixbuf}/${gdk-pixbuf.cacheFile}"}
${expectSomeLineContainingYInFileXToMentionZ "${tested}/bin/foo" "GDK_PIXBUF_MODULE_FILE=" "${librsvg}/${gdk-pixbuf.cacheFile}"}
${expectSomeLineContainingYInFileXToMentionZ "${tested}/bin/foo" "GDK_PIXBUF_MODULE_FILE=" "${mock-pixbuf-module}/${gdk-pixbuf.cacheFile}"}
${expectSomeLineContainingYInFileXToMentionZ "${tested}/libexec/bar" "GDK_PIXBUF_MODULE_FILE=" "${gdk-pixbuf}/${gdk-pixbuf.cacheFile}"}
${expectSomeLineContainingYInFileXToMentionZ "${tested}/libexec/bar" "GDK_PIXBUF_MODULE_FILE=" "${librsvg}/${gdk-pixbuf.cacheFile}"}
${expectSomeLineContainingYInFileXToMentionZ "${tested}/libexec/bar" "GDK_PIXBUF_MODULE_FILE=" "${mock-pixbuf-module}/${gdk-pixbuf.cacheFile}"}
${expectSomeLineContainingYInFileXToMentionZ "${tested}/bin/foo" "GDK_PIXBUF_MODULE_FILE" "${gdk-pixbuf}/${gdk-pixbuf.cacheFile}"}
${expectSomeLineContainingYInFileXToMentionZ "${tested}/bin/foo" "GDK_PIXBUF_MODULE_FILE" "${librsvg}/${gdk-pixbuf.cacheFile}"}
${expectSomeLineContainingYInFileXToMentionZ "${tested}/bin/foo" "GDK_PIXBUF_MODULE_FILE" "${mock-pixbuf-module}/${gdk-pixbuf.cacheFile}"}
${expectSomeLineContainingYInFileXToMentionZ "${tested}/libexec/bar" "GDK_PIXBUF_MODULE_FILE" "${gdk-pixbuf}/${gdk-pixbuf.cacheFile}"}
${expectSomeLineContainingYInFileXToMentionZ "${tested}/libexec/bar" "GDK_PIXBUF_MODULE_FILE" "${librsvg}/${gdk-pixbuf.cacheFile}"}
${expectSomeLineContainingYInFileXToMentionZ "${tested}/libexec/bar" "GDK_PIXBUF_MODULE_FILE" "${mock-pixbuf-module}/${gdk-pixbuf.cacheFile}"}
'';

# Simple derivation containing a gobject-introspection typelib.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ addEnvHooks "${targetOffset:?}" find_gio_modules

gappsWrapperArgsHook() {

gappsWrapperArgs+=(--prefix GDK_PIXBUF_MODULE_FILE : "@STANDARD_GDK_PIXBUF_MODULES@")
gappsWrapperArgs+=(--prefix GDK_PIXBUF_MODULE_FILE : "@standardGdkPixbufModules@")

if [ -n "$extraGdkPixbufModules" ]; then
for pkg in $extraGdkPixbufModules; do
gappsWrapperArgs+=(--prefix GDK_PIXBUF_MODULE_FILE : "$pkg/@GDK_PIXBUF_CACHE_FILE@")
gappsWrapperArgs+=(--prefix GDK_PIXBUF_MODULE_FILE : "$pkg/@gdkPixbufCacheFile@")
done
fi

Expand Down

0 comments on commit fd073f9

Please sign in to comment.