From b079a65c0c0b13d8d396a84f8abe2e2403dd0300 Mon Sep 17 00:00:00 2001
From: cwyc <16950437+cwyc@users.noreply.github.com>
Date: Sat, 1 Jan 2022 12:21:24 -0500
Subject: [PATCH 01/10] gdk-pixbuf: multiple module files patches gdk-pixbuf to
accept multiple module files in $GDK_PIXBUF_MODULE_FILE, separated by ":"
---
.../wrap-gapps-hook/wrap-gapps-hook.sh | 2 +-
.../libraries/gdk-pixbuf/default.nix | 2 ++
.../gdk-pixbuf/multiple-module-files.patch | 28 +++++++++++++++++++
.../libraries/gdk-pixbuf/setup-hook.sh | 5 +---
4 files changed, 32 insertions(+), 5 deletions(-)
create mode 100644 pkgs/development/libraries/gdk-pixbuf/multiple-module-files.patch
diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh b/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh
index 0acf4a8e6f8d4..045407c4637d9 100644
--- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh
+++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh
@@ -11,7 +11,7 @@ addEnvHooks "${targetOffset:?}" find_gio_modules
gappsWrapperArgsHook() {
if [ -n "$GDK_PIXBUF_MODULE_FILE" ]; then
- gappsWrapperArgs+=(--set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE")
+ gappsWrapperArgs+=(--suffix GDK_PIXBUF_MODULE_FILE : "$GDK_PIXBUF_MODULE_FILE")
fi
if [ -n "$GSETTINGS_SCHEMAS_PATH" ]; then
diff --git a/pkgs/development/libraries/gdk-pixbuf/default.nix b/pkgs/development/libraries/gdk-pixbuf/default.nix
index cbed6a62a3c58..65746c2199c36 100644
--- a/pkgs/development/libraries/gdk-pixbuf/default.nix
+++ b/pkgs/development/libraries/gdk-pixbuf/default.nix
@@ -42,6 +42,8 @@ stdenv.mkDerivation rec {
patches = [
# Move installed tests to a separate output
./installed-tests-path.patch
+ # Allow for multiple loader.cache files specified in $GDK_PIXBUF_MODULE_FILE, delimited by ":"
+ ./multiple-module-files.patch
];
# gdk-pixbuf-thumbnailer is not wrapped therefore strictDeps will work
diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files.patch b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files.patch
new file mode 100644
index 0000000000000..f74e2bfd7045b
--- /dev/null
+++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files.patch
@@ -0,0 +1,28 @@
+diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
+index 182781178..67b844ea1 100644
+--- a/gdk-pixbuf/gdk-pixbuf-io.c
++++ b/gdk-pixbuf/gdk-pixbuf-io.c
+@@ -668,13 +668,21 @@ static gboolean
+ gdk_pixbuf_io_init (void)
+ {
+ char *module_file;
+- gboolean ret;
++ gboolean ret = FALSE;
+
+ gdk_pixbuf_io_init_builtin ();
+ #ifdef USE_GMODULE
+ module_file = gdk_pixbuf_get_module_file ();
++ gchar **files = g_strsplit(module_file, ":", -1);
++
++ for(gchar **file = files; *file != NULL; file++){
++ if(**file != NULL){
++ ret |= gdk_pixbuf_io_init_modules (*file, NULL);
++ }
++ }
++
++ g_strfreev(files);
+ #endif
+- ret = gdk_pixbuf_io_init_modules (module_file, NULL);
+ g_free (module_file);
+ return ret;
+ }
diff --git a/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh b/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh
index ecf9793b91f6c..60ffa147d8187 100644
--- a/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh
+++ b/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh
@@ -1,12 +1,9 @@
findGdkPixbufLoaders() {
- # choose the longest loaders.cache
local loadersCache="$1/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"
if [[ -f "$loadersCache" ]]; then
if [[ -f "${GDK_PIXBUF_MODULE_FILE-}" ]]; then
- if (( "$(cat "$loadersCache" | wc -l)" > "$(cat "$GDK_PIXBUF_MODULE_FILE" | wc -l)" )); then
- export GDK_PIXBUF_MODULE_FILE="$loadersCache"
- fi
+ export GDK_PIXBUF_MODULE_FILE="$loadersCache":$GDK_PIXBUF_MODULE_FILE
else
export GDK_PIXBUF_MODULE_FILE="$loadersCache"
fi
From 5c5b68c3af5d78c7a96402ac4a440d79fb0dc77b Mon Sep 17 00:00:00 2001
From: cwyc <16950437+cwyc@users.noreply.github.com>
Date: Wed, 16 Mar 2022 20:11:01 -0400
Subject: [PATCH 02/10] reverse module loading order (will squash before
committing)
---
.../setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh | 2 +-
.../gdk-pixbuf/multiple-module-files.patch | 14 +++++++++-----
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh b/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh
index 045407c4637d9..49cb63229f534 100644
--- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh
+++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh
@@ -11,7 +11,7 @@ addEnvHooks "${targetOffset:?}" find_gio_modules
gappsWrapperArgsHook() {
if [ -n "$GDK_PIXBUF_MODULE_FILE" ]; then
- gappsWrapperArgs+=(--suffix GDK_PIXBUF_MODULE_FILE : "$GDK_PIXBUF_MODULE_FILE")
+ gappsWrapperArgs+=(--prefix GDK_PIXBUF_MODULE_FILE : "$GDK_PIXBUF_MODULE_FILE")
fi
if [ -n "$GSETTINGS_SCHEMAS_PATH" ]; then
diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files.patch b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files.patch
index f74e2bfd7045b..f1674959b2045 100644
--- a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files.patch
+++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files.patch
@@ -1,8 +1,8 @@
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
-index 182781178..67b844ea1 100644
+index 1827811..eda0c29 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.c
+++ b/gdk-pixbuf/gdk-pixbuf-io.c
-@@ -668,13 +668,21 @@ static gboolean
+@@ -668,13 +668,24 @@ static gboolean
gdk_pixbuf_io_init (void)
{
char *module_file;
@@ -14,9 +14,12 @@ index 182781178..67b844ea1 100644
module_file = gdk_pixbuf_get_module_file ();
+ gchar **files = g_strsplit(module_file, ":", -1);
+
-+ for(gchar **file = files; *file != NULL; file++){
-+ if(**file != NULL){
-+ ret |= gdk_pixbuf_io_init_modules (*file, NULL);
++ int num_files = 0;
++ while(files[num_files] != NULL) num_files++;
++
++ for(int i = num_files - 1; i >= 0; i--){ /* reverse iteration so earlier files have precedence */
++ if(files[i][0] != '\0'){ /* :: yields an empty split string, we should ignore */
++ ret |= gdk_pixbuf_io_init_modules (files[i], NULL);
+ }
+ }
+
@@ -26,3 +29,4 @@ index 182781178..67b844ea1 100644
g_free (module_file);
return ret;
}
+
\ No newline at end of file
From 3beecc85069d158aa10a8bca1df28d8d80fc4200 Mon Sep 17 00:00:00 2001
From: cwyc <16950437+cwyc@users.noreply.github.com>
Date: Wed, 16 Mar 2022 22:28:20 -0400
Subject: [PATCH 03/10] modified build support code (will squash before
committing)
---
doc/languages-frameworks/gnome.section.md | 8 ++++----
doc/stdenv/stdenv.chapter.md | 4 ----
nixos/doc/manual/release-notes/rl-2205.section.md | 11 +++++++++++
.../setup-hooks/wrap-gapps-hook/default.nix | 8 +++++++-
.../setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh | 9 +++++++--
pkgs/development/libraries/gdk-pixbuf/default.nix | 2 --
.../development/libraries/gdk-pixbuf/setup-hook.sh | 14 --------------
7 files changed, 29 insertions(+), 27 deletions(-)
delete mode 100644 pkgs/development/libraries/gdk-pixbuf/setup-hook.sh
diff --git a/doc/languages-frameworks/gnome.section.md b/doc/languages-frameworks/gnome.section.md
index d5996cce13cfd..62766b2c153ce 100644
--- a/doc/languages-frameworks/gnome.section.md
+++ b/doc/languages-frameworks/gnome.section.md
@@ -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. This is especially painful since 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 to use third-party loader modules for other formats. GTK itself includes SVG icons, which cannot be rendered without a loader provided by `librsvg`.
-Unlike other libraries mentioned in this section, GdkPixbuf only supports a single value in its controlling environment variable `GDK_PIXBUF_MODULE_FILE`. It is supposed to point to a cache file containing information about the available loaders. Each loader package will contain a `lib/gdk-pixbuf-2.0/2.10.0/loaders.cache` file describing the default loaders in `gdk-pixbuf` package plus the loader contained in the package itself. If you want to use multiple third-party loaders, you will need to create your own cache file manually. Fortunately, this is pretty rare as [not many loaders exist](https://gitlab.gnome.org/federico/gdk-pixbuf-survey/blob/master/src/modules.md).
+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 `:`.
-`gdk-pixbuf` contains [a setup hook](#ssec-gnome-hooks-gdk-pixbuf) that sets `GDK_PIXBUF_MODULE_FILE` from dependencies but as mentioned in further section, it is pretty limited. Loaders should propagate this setup hook.
+[`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}
@@ -106,7 +106,7 @@ For convenience, it also adds `dconf.lib` for a GIO module implementing a GSetti
- []{#ssec-gnome-hooks-glib} `glib` setup hook will populate `GSETTINGS_SCHEMAS_PATH` and then `wrapGAppsHook` will prepend it to `XDG_DATA_DIRS`.
-- []{#ssec-gnome-hooks-gdk-pixbuf} `gdk-pixbuf` setup hook will populate `GDK_PIXBUF_MODULE_FILE` with the path to biggest `loaders.cache` file from the dependencies containing [GdkPixbuf loaders](#ssec-gnome-gdk-pixbuf-loaders). This works fine when there are only two packages containing loaders (`gdk-pixbuf` and e.g. `librsvg`) – it will choose the second one, reasonably expecting that it will be bigger since it describes extra loader in addition to the default ones. But when there are more than two loader packages, this logic will break. One possible solution would be constructing a custom cache file for each package containing a program like `services/x11/gdk-pixbuf.nix` NixOS module does. `wrapGAppsHook` copies the `GDK_PIXBUF_MODULE_FILE` environment variable into the produced wrapper.
+- []{#ssec-gnome-hooks-gdk-pixbuf} `wrapGAppsHook` will automatically prepend `GDK_PIXBUF_MODULE_FILE` with modules from `gdk-pixbuf` and `librsvg`. To include additional gdk-pixbuf modules, set `extraGdkPixbufModules` with an array of packages.
- []{#ssec-gnome-hooks-gtk-drop-icon-theme-cache} One of `gtk3`’s setup hooks will remove `icon-theme.cache` files from package’s icon theme directories to avoid conflicts. Icon theme packages should prevent this with `dontDropIconThemeCache = true;`.
diff --git a/doc/stdenv/stdenv.chapter.md b/doc/stdenv/stdenv.chapter.md
index b57698cb90b34..903e42de7d747 100644
--- a/doc/stdenv/stdenv.chapter.md
+++ b/doc/stdenv/stdenv.chapter.md
@@ -1077,10 +1077,6 @@ Adds the `share/texmf-nix` subdirectory of each build input to the `TEXINPUTS` e
Sets the `QTDIR` environment variable to Qt’s path.
-### gdk-pixbuf {#setup-hook-gdk-pixbuf}
-
-Exports `GDK_PIXBUF_MODULE_FILE` environment variable to the builder. Add librsvg package to `buildInputs` to get svg support. See also the [setup hook description in GNOME platform docs](#ssec-gnome-hooks-gdk-pixbuf).
-
### GHC {#ghc}
Creates a temporary package database and registers every Haskell build input in it (TODO: how?).
diff --git a/nixos/doc/manual/release-notes/rl-2205.section.md b/nixos/doc/manual/release-notes/rl-2205.section.md
index edb3758dd2f12..54195172fd455 100644
--- a/nixos/doc/manual/release-notes/rl-2205.section.md
+++ b/nixos/doc/manual/release-notes/rl-2205.section.md
@@ -621,6 +621,17 @@ In addition to numerous new and upgraded packages, this release has the followin
To import that data after to the upgrade, run
`sudo -u epgstation epgstation run v1migrate /tmp/epgstation.bak`
+- How `gdk-pixbuf` modules are set has changed.
+ - `gdk-pixbuf` has been patched to accept multiple `loaders.cache` files in `$GDK_PIXBUF_MODULE_FILE`, separated by `:`
+ - Setting modules through `wrapGAppsHook`:
+ `wrapGAppsHook` now automatically includes modules from `gdk-pixbuf` and `librsvg`. This is backwards-compatible for most packages.
+ It no longer looks for a module file in `$GDK_PIXBUF_MODULE_FILE` in the build environment, `gdk-pixbuf` no longer sets it when added to `buildInputs`, and you no longer need to add `gdk-pixbuf` or `librsvg` to `buildInputs` unless the program directly depends on it.
+ To include additional gdk-pixbuf modules, set `extraGdkPixbufModules` with an array of packages.
+ - Manually wrapping `$GDK_PIXBUF_MODULE_FILE`:
+ The `librsvg` loaders.cache still contains all of the loaders from `gdk-pixbuf`. This might change in the future, so it is recommended that you explicitly include both.
+ As this change allows users to extend programs with their own loaders, it is recommended that you `--prefix` rather than `--set` `$GDK_PIXBUF_MODULE_FILE` with your values.
+ For example: `makeWrapper ... --prefix GDK_PIXBUF_MODULE_FILE : "${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache:${gdk-pixbuf}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"`
+
- `switch-to-configuration` (the script that is run when running `nixos-rebuild switch` for example) has been reworked
* The interface that allows activation scripts to restart units has been streamlined. Restarting and reloading is now done by a single file `/run/nixos/activation-restart-list` that honors `restartIfChanged` and `reloadIfChanged` of the units.
* Preferring to reload instead of restarting can still be achieved using `/run/nixos/activation-reload-list`.
diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix b/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
index d7699b2557fc4..d275207e520fe 100644
--- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
+++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
@@ -10,6 +10,7 @@
, callPackage
, wrapGAppsHook
, writeTextFile
+, gdk-pixbuf
}:
makeSetupHook {
@@ -36,7 +37,12 @@ makeSetupHook {
# We use the wrapProgram function.
makeWrapper
];
- substitutions = {
+ substitutions = let
+ loadersPath = (lib.strings.removeSuffix "/" gdk-pixbuf.moduleDir) + ".cache";
+ in {
+ STANDARD_GDK_PIXBUF_MODULES = "${gdk-pixbuf}/${loadersPath}:${librsvg}/${loadersPath}";
+ LOADERS_PATH = loadersPath;
+
passthru.tests = let
sample-project = ./tests/sample-project;
diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh b/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh
index 49cb63229f534..523f2cf71f0ae 100644
--- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh
+++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh
@@ -10,8 +10,13 @@ find_gio_modules() {
addEnvHooks "${targetOffset:?}" find_gio_modules
gappsWrapperArgsHook() {
- if [ -n "$GDK_PIXBUF_MODULE_FILE" ]; then
- gappsWrapperArgs+=(--prefix GDK_PIXBUF_MODULE_FILE : "$GDK_PIXBUF_MODULE_FILE")
+
+ gappsWrapperArgs+=(--prefix GDK_PIXBUF_MODULE_FILE : "@STANDARD_GDK_PIXBUF_MODULES@")
+
+ if [ -n "$extraGdkPixbufModules" ]; then
+ for pkg in $extraGdkPixbufModules; do
+ gappsWrapperArgs+=(--prefix GDK_PIXBUF_MODULE_FILE : "$pkg/@LOADERS_PATH@")
+ done
fi
if [ -n "$GSETTINGS_SCHEMAS_PATH" ]; then
diff --git a/pkgs/development/libraries/gdk-pixbuf/default.nix b/pkgs/development/libraries/gdk-pixbuf/default.nix
index 65746c2199c36..826f8be93feb8 100644
--- a/pkgs/development/libraries/gdk-pixbuf/default.nix
+++ b/pkgs/development/libraries/gdk-pixbuf/default.nix
@@ -130,8 +130,6 @@ stdenv.mkDerivation rec {
# The tests take an excessive amount of time (> 1.5 hours) and memory (> 6 GB).
inherit doCheck;
- setupHook = ./setup-hook.sh;
-
separateDebugInfo = stdenv.isLinux;
passthru = {
diff --git a/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh b/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh
deleted file mode 100644
index 60ffa147d8187..0000000000000
--- a/pkgs/development/libraries/gdk-pixbuf/setup-hook.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-findGdkPixbufLoaders() {
-
- local loadersCache="$1/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"
- if [[ -f "$loadersCache" ]]; then
- if [[ -f "${GDK_PIXBUF_MODULE_FILE-}" ]]; then
- export GDK_PIXBUF_MODULE_FILE="$loadersCache":$GDK_PIXBUF_MODULE_FILE
- else
- export GDK_PIXBUF_MODULE_FILE="$loadersCache"
- fi
- fi
-
-}
-
-addEnvHooks "$targetOffset" findGdkPixbufLoaders
From b79df1a7f04cf77d44fce15685122e3d63c8692d Mon Sep 17 00:00:00 2001
From: cwyc <16950437+cwyc@users.noreply.github.com>
Date: Sat, 9 Apr 2022 16:32:17 -0400
Subject: [PATCH 04/10] more changes will be squashed before merge
---
.../build-support/setup-hooks/wrap-gapps-hook/default.nix | 8 +++-----
.../setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh | 2 +-
pkgs/development/libraries/gdk-pixbuf/default.nix | 3 ++-
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix b/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
index d275207e520fe..c1e5e2fbd2a94 100644
--- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
+++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
@@ -37,11 +37,9 @@ makeSetupHook {
# We use the wrapProgram function.
makeWrapper
];
- substitutions = let
- loadersPath = (lib.strings.removeSuffix "/" gdk-pixbuf.moduleDir) + ".cache";
- in {
- STANDARD_GDK_PIXBUF_MODULES = "${gdk-pixbuf}/${loadersPath}:${librsvg}/${loadersPath}";
- LOADERS_PATH = loadersPath;
+ substitutions = {
+ STANDARD_GDK_PIXBUF_MODULES = lib.makeSearchPathOutput "lib" gdk-pixbuf.cacheFile [ gdk-pixbuf librsvg ];
+ GDK_PIXBUF_CACHE_FILE = gdk-pixbuf.cacheFile;
passthru.tests = let
sample-project = ./tests/sample-project;
diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh b/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh
index 523f2cf71f0ae..4d7a1988919f2 100644
--- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh
+++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh
@@ -15,7 +15,7 @@ gappsWrapperArgsHook() {
if [ -n "$extraGdkPixbufModules" ]; then
for pkg in $extraGdkPixbufModules; do
- gappsWrapperArgs+=(--prefix GDK_PIXBUF_MODULE_FILE : "$pkg/@LOADERS_PATH@")
+ gappsWrapperArgs+=(--prefix GDK_PIXBUF_MODULE_FILE : "$pkg/@GDK_PIXBUF_CACHE_FILE@")
done
fi
diff --git a/pkgs/development/libraries/gdk-pixbuf/default.nix b/pkgs/development/libraries/gdk-pixbuf/default.nix
index 826f8be93feb8..24c8558c186e9 100644
--- a/pkgs/development/libraries/gdk-pixbuf/default.nix
+++ b/pkgs/development/libraries/gdk-pixbuf/default.nix
@@ -42,7 +42,7 @@ stdenv.mkDerivation rec {
patches = [
# Move installed tests to a separate output
./installed-tests-path.patch
- # Allow for multiple loader.cache files specified in $GDK_PIXBUF_MODULE_FILE, delimited by ":"
+ # Allow for multiple loaders.cache files specified in $GDK_PIXBUF_MODULE_FILE, delimited by ":"
./multiple-module-files.patch
];
@@ -144,6 +144,7 @@ stdenv.mkDerivation rec {
# gdk_pixbuf_moduledir variable from gdk-pixbuf-2.0.pc
moduleDir = "lib/gdk-pixbuf-2.0/2.10.0/loaders";
+ cacheFile = "lib/gdk-pixbuf-2.0/2.10.0/loaders.cache";
};
meta = with lib; {
From 5ebf782cfa8deaacbf42f7a9af6998d6dc6b1804 Mon Sep 17 00:00:00 2001
From: cwyc <16950437+cwyc@users.noreply.github.com>
Date: Sat, 9 Apr 2022 17:52:04 -0400
Subject: [PATCH 05/10] tests for wrapper code to do: tests for patched code
will be squashed before merge
---
.../setup-hooks/wrap-gapps-hook/default.nix | 23 +++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix b/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
index c1e5e2fbd2a94..535db9a04dbc6 100644
--- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
+++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
@@ -68,6 +68,29 @@ makeSetupHook {
''
);
+ # Stopgap as no modules have been packaged yet
+ mock-pixbuf-module = stdenv.mkDerivation {
+ name = "mock-gdk-pixbuf-module";
+ outputs = ["lib"];
+ builder = ''
+ mkdir -p $lib/$(dirname ${gdk-pixbuf.cacheFile})
+ touch $lib/${gdk-pixbuf.cacheFile}
+ '';
+ };
+
+ 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}"}
+ '';
+
# Simple derivation containing a gobject-introspection typelib.
typelib-Mahjong = stdenv.mkDerivation {
name = "typelib-Mahjong";
From fd073f94cf979895fc0be1a94acee08ad61c85d7 Mon Sep 17 00:00:00 2001
From: cwyc <16950437+cwyc@users.noreply.github.com>
Date: Wed, 25 May 2022 13:36:36 +0000
Subject: [PATCH 06/10] corrected mistakes will be squashed before merging
---
doc/languages-frameworks/gnome.section.md | 4 ++--
.../setup-hooks/wrap-gapps-hook/default.nix | 24 +++++++++++--------
.../wrap-gapps-hook/wrap-gapps-hook.sh | 4 ++--
3 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/doc/languages-frameworks/gnome.section.md b/doc/languages-frameworks/gnome.section.md
index 62766b2c153ce..73f296737a40b 100644
--- a/doc/languages-frameworks/gnome.section.md
+++ b/doc/languages-frameworks/gnome.section.md
@@ -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}
diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix b/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
index 535db9a04dbc6..274e8f0806731 100644
--- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
+++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
@@ -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;
@@ -71,11 +71,15 @@ 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];});
@@ -83,12 +87,12 @@ makeSetupHook {
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.
diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh b/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh
index 4d7a1988919f2..a3b75ffa2761d 100644
--- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh
+++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/wrap-gapps-hook.sh
@@ -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
From a4e5e1edd1325c30992f3478696af86eb62c419d Mon Sep 17 00:00:00 2001
From: cwyc <16950437+cwyc@users.noreply.github.com>
Date: Wed, 25 May 2022 13:37:46 +0000
Subject: [PATCH 07/10] added package test for gdk-pixbuf multiple file
functionality will be squashed before merging
---
.../libraries/gdk-pixbuf/default.nix | 2 +
.../multiple-module-files-test/default.nix | 34 ++++++++
.../multiple-module-files-test/sample.svg | 79 +++++++++++++++++++
3 files changed, 115 insertions(+)
create mode 100644 pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/default.nix
create mode 100644 pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/sample.svg
diff --git a/pkgs/development/libraries/gdk-pixbuf/default.nix b/pkgs/development/libraries/gdk-pixbuf/default.nix
index 24c8558c186e9..6f058718ab942 100644
--- a/pkgs/development/libraries/gdk-pixbuf/default.nix
+++ b/pkgs/development/libraries/gdk-pixbuf/default.nix
@@ -19,6 +19,7 @@
, doCheck ? false
, makeWrapper
, lib
+, callPackage
, withIntrospection ? (stdenv.buildPlatform == stdenv.hostPlatform)
, gobject-introspection
}:
@@ -140,6 +141,7 @@ stdenv.mkDerivation rec {
tests = {
installedTests = nixosTests.installed-tests.gdk-pixbuf;
+ multiple-module-files = callPackage ./multiple-module-files-test {};
};
# gdk_pixbuf_moduledir variable from gdk-pixbuf-2.0.pc
diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/default.nix b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/default.nix
new file mode 100644
index 0000000000000..f56c0e509f228
--- /dev/null
+++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/default.nix
@@ -0,0 +1,34 @@
+# Simple tests for multiple module files functionality.
+# In the future, would like to test precedence, more than two files, unexpected inputs/fuzzing.
+{ runCommand, gdk-pixbuf, librsvg}:
+runCommand "pixbuf-mmf-test" {} ''
+ mkdir -p $out
+ set +e
+
+ function test {
+ modulepath=$1
+ testfile=$2
+ GDK_PIXBUF_MODULE_FILE=$modulepath ${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer $testfile $out/$(basename $testfile) > /dev/null
+ }
+
+ test ${gdk-pixbuf}/${gdk-pixbuf.cacheFile} ${./sample.svg}
+ if ! (($?)); then
+ >&2 echo "This shouldn't happen? SVG parsing succeeded even though librsvg wasn't supplied."
+ exit 1
+ fi
+
+ test ${gdk-pixbuf}/${gdk-pixbuf.cacheFile}:${librsvg}/${gdk-pixbuf.cacheFile} ${./sample.svg}
+ if (($?)); then
+ >&2 echo "Test failed."
+ exit 1
+ fi
+
+ test ${librsvg}/${gdk-pixbuf.cacheFile}:${gdk-pixbuf}/${gdk-pixbuf.cacheFile} ${./sample.svg}
+ if (($?)); then
+ >&2 echo "Test failed."
+ exit 1
+ fi
+
+ set -e
+ exit 0
+''
diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/sample.svg b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/sample.svg
new file mode 100644
index 0000000000000..22bd85d520bc4
--- /dev/null
+++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/sample.svg
@@ -0,0 +1,79 @@
+
+
+
+
From 0b5b13b36df4f580f2c34c965c37f55db1bf3f4c Mon Sep 17 00:00:00 2001
From: cwyc <16950437+cwyc@users.noreply.github.com>
Date: Tue, 31 May 2022 13:10:37 -0400
Subject: [PATCH 08/10] updated documentation will squash before merge
---
doc/languages-frameworks/gnome.section.md | 2 +-
.../from_md/release-notes/rl-2211.section.xml | 50 +++++++++++++++++++
.../manual/release-notes/rl-2205.section.md | 11 ----
.../manual/release-notes/rl-2211.section.md | 11 ++++
4 files changed, 62 insertions(+), 12 deletions(-)
diff --git a/doc/languages-frameworks/gnome.section.md b/doc/languages-frameworks/gnome.section.md
index 73f296737a40b..f05ca6dc1a449 100644
--- a/doc/languages-frameworks/gnome.section.md
+++ b/doc/languages-frameworks/gnome.section.md
@@ -38,7 +38,7 @@ GTK applications typically use [GdkPixbuf](https://developer.gnome.org/gdk-pixbu
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 (`wrapGAppsHook` is preferred), 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}
diff --git a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
index 79268b398e60f..5cb82edf1ae15 100644
--- a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
+++ b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
@@ -31,6 +31,56 @@
stdenv.buildPlatform.canExecute stdenv.hostPlatform.
+
+
+ How gdk-pixbuf modules are set has changed.
+
+
+
+
+ gdk-pixbuf has been patched to accept
+ multiple loaders.cache files in
+ $GDK_PIXBUF_MODULE_FILE, separated by
+ :
+
+
+
+
+ Setting modules through wrapGAppsHook
+ (preferred method): wrapGAppsHook now
+ automatically includes modules from
+ gdk-pixbuf and
+ librsvg. This is backwards-compatible
+ for most packages. It no longer looks for a module file in
+ $GDK_PIXBUF_MODULE_FILE in the build
+ environment, gdk-pixbuf no longer sets
+ it when added to buildInputs, and you
+ no longer need to add gdk-pixbuf or
+ librsvg to
+ buildInputs unless the program directly
+ depends on it. To include additional gdk-pixbuf modules,
+ set extraGdkPixbufModules with an array
+ of packages.
+
+
+
+
+ Manually wrapping
+ $GDK_PIXBUF_MODULE_FILE: The
+ librsvg loaders.cache still contains
+ all of the loaders from gdk-pixbuf.
+ This might change in the future, so it is recommended that
+ you explicitly include both. As this change allows users
+ to extend programs with their own loaders, it is
+ recommended that you --prefix rather
+ than --set
+ $GDK_PIXBUF_MODULE_FILE with your
+ values. For example:
+ makeWrapper ... --prefix GDK_PIXBUF_MODULE_FILE : "${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache:${gdk-pixbuf}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"
+
+
+
+
PHP now defaults to PHP 8.1, updated from 8.0.
diff --git a/nixos/doc/manual/release-notes/rl-2205.section.md b/nixos/doc/manual/release-notes/rl-2205.section.md
index 54195172fd455..edb3758dd2f12 100644
--- a/nixos/doc/manual/release-notes/rl-2205.section.md
+++ b/nixos/doc/manual/release-notes/rl-2205.section.md
@@ -621,17 +621,6 @@ In addition to numerous new and upgraded packages, this release has the followin
To import that data after to the upgrade, run
`sudo -u epgstation epgstation run v1migrate /tmp/epgstation.bak`
-- How `gdk-pixbuf` modules are set has changed.
- - `gdk-pixbuf` has been patched to accept multiple `loaders.cache` files in `$GDK_PIXBUF_MODULE_FILE`, separated by `:`
- - Setting modules through `wrapGAppsHook`:
- `wrapGAppsHook` now automatically includes modules from `gdk-pixbuf` and `librsvg`. This is backwards-compatible for most packages.
- It no longer looks for a module file in `$GDK_PIXBUF_MODULE_FILE` in the build environment, `gdk-pixbuf` no longer sets it when added to `buildInputs`, and you no longer need to add `gdk-pixbuf` or `librsvg` to `buildInputs` unless the program directly depends on it.
- To include additional gdk-pixbuf modules, set `extraGdkPixbufModules` with an array of packages.
- - Manually wrapping `$GDK_PIXBUF_MODULE_FILE`:
- The `librsvg` loaders.cache still contains all of the loaders from `gdk-pixbuf`. This might change in the future, so it is recommended that you explicitly include both.
- As this change allows users to extend programs with their own loaders, it is recommended that you `--prefix` rather than `--set` `$GDK_PIXBUF_MODULE_FILE` with your values.
- For example: `makeWrapper ... --prefix GDK_PIXBUF_MODULE_FILE : "${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache:${gdk-pixbuf}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"`
-
- `switch-to-configuration` (the script that is run when running `nixos-rebuild switch` for example) has been reworked
* The interface that allows activation scripts to restart units has been streamlined. Restarting and reloading is now done by a single file `/run/nixos/activation-restart-list` that honors `restartIfChanged` and `reloadIfChanged` of the units.
* Preferring to reload instead of restarting can still be achieved using `/run/nixos/activation-reload-list`.
diff --git a/nixos/doc/manual/release-notes/rl-2211.section.md b/nixos/doc/manual/release-notes/rl-2211.section.md
index 7d2eacce57fed..1deb01105c956 100644
--- a/nixos/doc/manual/release-notes/rl-2211.section.md
+++ b/nixos/doc/manual/release-notes/rl-2211.section.md
@@ -17,6 +17,17 @@ In addition to numerous new and upgraded packages, this release has the followin
built for `stdenv.hostPlatform` (i.e. produced by `stdenv.cc`) by evaluating
`stdenv.buildPlatform.canExecute stdenv.hostPlatform`.
+- How `gdk-pixbuf` modules are set has changed.
+ - `gdk-pixbuf` has been patched to accept multiple `loaders.cache` files in `$GDK_PIXBUF_MODULE_FILE`, separated by `:`
+ - Setting modules through `wrapGAppsHook` (preferred method):
+ `wrapGAppsHook` now automatically includes modules from `gdk-pixbuf` and `librsvg`. This is backwards-compatible for most packages.
+ It no longer looks for a module file in `$GDK_PIXBUF_MODULE_FILE` in the build environment, `gdk-pixbuf` no longer sets it when added to `buildInputs`, and you no longer need to add `gdk-pixbuf` or `librsvg` to `buildInputs` unless the program directly depends on it.
+ To include additional gdk-pixbuf modules, set `extraGdkPixbufModules` with an array of packages.
+ - Manually wrapping `$GDK_PIXBUF_MODULE_FILE`:
+ The `librsvg` loaders.cache still contains all of the loaders from `gdk-pixbuf`. This might change in the future, so it is recommended that you explicitly include both.
+ As this change allows users to extend programs with their own loaders, it is recommended that you `--prefix` rather than `--set` `$GDK_PIXBUF_MODULE_FILE` with your values.
+ For example: `makeWrapper ... --prefix GDK_PIXBUF_MODULE_FILE : "${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache:${gdk-pixbuf}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"`
+
- PHP now defaults to PHP 8.1, updated from 8.0.
From 31da251850a8aaac519dc9a1c08213cce8d49b5e Mon Sep 17 00:00:00 2001
From: cwyc <16950437+cwyc@users.noreply.github.com>
Date: Wed, 1 Jun 2022 12:18:22 -0400
Subject: [PATCH 09/10] expanded package tests found issue: there should be a
better way to report that a loader is invalid will be squashed before merge
---
.../multiple-module-files-test/default.nix | 59 ++++++---
.../multiple-module-files-test/sample.gif | Bin 0 -> 2293 bytes
.../multiple-module-files-test/sample.svg | 64 ++++-----
.../test-loader.nix | 18 +++
.../test-loader/loader.c | 123 ++++++++++++++++++
.../test-loader/meson.build | 11 ++
.../test-loader/meson_options.txt | 1 +
7 files changed, 226 insertions(+), 50 deletions(-)
create mode 100644 pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/sample.gif
create mode 100644 pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader.nix
create mode 100644 pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/loader.c
create mode 100644 pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/meson.build
create mode 100644 pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/meson_options.txt
diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/default.nix b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/default.nix
index f56c0e509f228..1faaabf2f506d 100644
--- a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/default.nix
+++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/default.nix
@@ -1,34 +1,57 @@
# Simple tests for multiple module files functionality.
-# In the future, would like to test precedence, more than two files, unexpected inputs/fuzzing.
-{ runCommand, gdk-pixbuf, librsvg}:
-runCommand "pixbuf-mmf-test" {} ''
+# gdk-pixbuf-thumbnailer is used as a simple, command-line consumer of loaders.
+# In the future, would like to test unexpected inputs/fuzzing.
+{ runCommand, gdk-pixbuf, librsvg, callPackage, imagemagick}:
+let
+ thumbnailer = "${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer";
+
+ pixbufloader = gdk-pixbuf + "/" + gdk-pixbuf.cacheFile;
+ svgloader = librsvg + "/" + gdk-pixbuf.cacheFile;
+ redloader = (callPackage ./test-loader.nix {outputColor="#FF0000";}) + "/" + gdk-pixbuf.cacheFile;
+ blueloader = (callPackage ./test-loader.nix {outputColor="#0000FF";}) + "/" + gdk-pixbuf.cacheFile;
+
+ svgsample = ./sample.svg;
+ gifsample = ./sample.gif;
+in runCommand "pixbuf-mmf-test" {} ''
mkdir -p $out
set +e
- function test {
+ function svgtest {
modulepath=$1
- testfile=$2
- GDK_PIXBUF_MODULE_FILE=$modulepath ${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer $testfile $out/$(basename $testfile) > /dev/null
+ GDK_PIXBUF_MODULE_FILE=$modulepath "${thumbnailer}" "${svgsample}" "$out/thumbnail.png"
}
- test ${gdk-pixbuf}/${gdk-pixbuf.cacheFile} ${./sample.svg}
- if ! (($?)); then
- >&2 echo "This shouldn't happen? SVG parsing succeeded even though librsvg wasn't supplied."
+ function colortest {
+ modulepath=$1
+ checkcolor=$2
+ GDK_PIXBUF_MODULE_FILE=$modulepath "${thumbnailer}" "${gifsample}" "$out/thumbnail.png"
+ "${imagemagick}/bin/convert" "$out/thumbnail.png" -resize 1x1 "$out/summarized.txt"
+ grep "$checkcolor" "$out/summarized.txt"
+ }
+
+ # sanity check
+ if svgtest "${pixbufloader}"; then
+ >&2 echo "Test failed. SVG parsing succeeded even though librsvg loader wasn't provided. This shouldn't happen?"
exit 1
fi
- test ${gdk-pixbuf}/${gdk-pixbuf.cacheFile}:${librsvg}/${gdk-pixbuf.cacheFile} ${./sample.svg}
- if (($?)); then
- >&2 echo "Test failed."
- exit 1
+ # basic check for multiple file loading
+ if ! svgtest "${pixbufloader}:${svgloader}"; then
+ >&2 echo "Test failed. Second module file couldn't be loaded."
+ exit 2
fi
- test ${librsvg}/${gdk-pixbuf.cacheFile}:${gdk-pixbuf}/${gdk-pixbuf.cacheFile} ${./sample.svg}
- if (($?)); then
- >&2 echo "Test failed."
- exit 1
+ # check that priority goes to earlier entries in the list
+ if ! colortest "${redloader}:${pixbufloader}:${blueloader}" "#FF0000"; then
+ if colortest "${redloader}:${pixbufloader}:${blueloader}" "#0000FF"; then
+ >&2 echo "Test failed. Path order priority is incorrect."
+ exit 3
+ else
+ >&2 echo "Test failed. Unknown error with test loader code."
+ exit 4
+ fi
fi
- set -e
+ echo "Tests succeeded for gdk-pixbuf multiple module files patch."
exit 0
''
diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/sample.gif b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/sample.gif
new file mode 100644
index 0000000000000000000000000000000000000000..46c56831391b28ef899d5f22d7afc136e8e0da08
GIT binary patch
literal 2293
zcmeH``#;kQ1ILGrO=I8HlC6cIQl8VJ;)LTo$Jb^qNyIs+R9h{aqDLyB+cq;ZmW{cq
zHb(9?Q4(dj4arvSDRYTRNiNAPUKucz%06pI_gv&kyg{>*L}^wzZ?uAT-DV7vkyZ
zdGO#tUteE8KRX5D;+w{Q0o3u<-EkD_5>WL_}P@diC11Yd3D(xOwwtOiT=$
z&5n(Y<#0H0adBKOH$FZ-At8as`O-@jj3Sy@$8_29vShYufCS64rJ^r)t$
z=JDglwY9Z%b#+gkJbC)`X?=aYTrPk1>{&xYLt|rOQ&UrOb8|~ei$bAjZEbC9Yinfzzxk&%(n(b2K7v3Kv@jgOB{Oia9g|Ng^=41*%2U0^qsJ~n7vbOnI$UlBEKOX~u
zuR%5<@UBvkJQ}`Xr@ulfZiofU+_PO}IZg3~d(RFkWVtPgCPXgYtwPe8Y~fSn-&&E^
zo@RA=XJ)h(jEnv?vc}LSoZCOc8EuSnft7+B*0h*>NU@jH2kex6;WY
zBQ_Q()9UIGt|QS%;wL0Lkfgl8yYS`3U8Whx6V5NN8c7;4yhsx%Y;kEc3yHPWW%36`
z6Pk@+bx(3wr;Sj?%hDg|;Eu3c$3i1W-kG`U+ckS#@0IM!C7_LWZ(4(Ps=TInApMF^
zbzG4A%a&+&4S(oVJm53vE+?MC{^FxsOj^U$%}uzKPc-h}V%9s0^a3z6%my!yFYJq)2iT5%a?$
zGE;b2h3x*DB{ro5^>_;mk9(WB{IQd%6_2k|jXGO+rUA^&D#b|`wwGGNGw6*kHXT=L
zp$;}cFtt2M!ESs4h&Rzht;2QcphLyj)F|jLSQVb=F4XaiI$+B@e2zoc%;wf!NJjFp
zLLIajhko0UO|Bdw?e(y~0}i3PV&TVg*q^n{+u!R2@BPR
zV(ErxEJo3cK8t1ygLk34qCxO54FcwGz)~b+NAQv}7tsNTO^q7c8d6Q4Z%3nOB6$g!
zWZMd0)!WSPn3As9E0Hrv@ukFtX6+DXvz2%+#y2%Y{_|j7KQb9{K=~NH`?j(P9>*VZzCX?wfrpp!WgrNJ4B#fv4*}ecbMA~5
zO~lAWXSRbCJ?i3uf9eJ!i!~dUmsk4(RI+x$HzL
z$P&qP5$ku7jDRSZMo=qIjv5?m1mhv2wW7lGvg
zbKk?RC)sP-Gj@7MX)LI?)d?#8Bd%-WqLzm%M&}eM#zPRC!89e86~Jf3^a#BV(E@h~
zaO?;vVS`*fzst#Jw|5B}z`EnM9J19O$aB;!JWV{x;p-pO2m;V7wk8KKl78_+)T)WQ
zCP?5XfWTCm5zYHsVh!IVn88o=s155dPS7}qf}t7*`c|ebBNjt7C!P8Zp!nqkP0mIf
zKfUVk9w-kGL$+@}Qg2tV#}tInNcll|BYBt#1m0zi$}Gd879SM<~i$r
zc52u-&Pv5|X|zg2APAMgx{kM`8fP$ohl
diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader.nix b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader.nix
new file mode 100644
index 0000000000000..dae657b720705
--- /dev/null
+++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader.nix
@@ -0,0 +1,18 @@
+{ stdenv
+, gdk-pixbuf
+, pkg-config
+, meson
+, ninja
+, outputColor ? "#ffffff"
+}:
+stdenv.mkDerivation {
+ name = "gdk-pixbuf-test-loader";
+ src = ./test-loader;
+ buildInputs = [gdk-pixbuf];
+ nativeBuildInputs = [pkg-config meson ninja];
+ postInstall = ''
+ mkdir -p $(dirname $out/${gdk-pixbuf.cacheFile})
+ ${gdk-pixbuf.dev}/bin/gdk-pixbuf-query-loaders $out/lib/libtest_loader.so > $out/${gdk-pixbuf.cacheFile}
+ '';
+ mesonFlags = ["-DoutputColor=${outputColor}"];
+}
\ No newline at end of file
diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/loader.c b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/loader.c
new file mode 100644
index 0000000000000..59cb1c36b6725
--- /dev/null
+++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/loader.c
@@ -0,0 +1,123 @@
+#define GDK_PIXBUF_ENABLE_BACKEND
+#include
+#include
+#undef GDK_PIXBUF_ENABLE_BACKEND
+
+
+#ifndef PIXBUF_COLOR
+#error PIXBUF_COLOR must be set to a hex color string.
+#endif
+
+
+G_MODULE_EXPORT void fill_vtable(GdkPixbufModule* module);
+
+G_MODULE_EXPORT void fill_info(GdkPixbufFormat* info);
+
+
+typedef struct {
+ GdkPixbufModuleUpdatedFunc update_func;
+ GdkPixbufModulePreparedFunc prepare_func;
+ GdkPixbufModuleSizeFunc size_func;
+ gpointer user_data;
+} TestPixbufCtx;
+
+
+static gpointer begin_load(
+ GdkPixbufModuleSizeFunc size_func,
+ GdkPixbufModulePreparedFunc prepare_func,
+ GdkPixbufModuleUpdatedFunc update_func,
+ gpointer user_data,
+ GError** error
+) {
+ TestPixbufCtx* tpc;
+
+ tpc = g_new0(TestPixbufCtx, 1);
+ tpc->size_func = size_func;
+ tpc->prepare_func = prepare_func;
+ tpc->update_func = update_func;
+ tpc->user_data = user_data;
+
+ return tpc;
+}
+
+
+static char * xpm[] = {
+ // width, height, #colors, #chars_per_pixel
+ "1 1 1 1",
+ // palette
+ "a c " PIXBUF_COLOR,
+ // image
+ "a"
+};
+
+static gboolean stop_load(gpointer context, GError** error) {
+ TestPixbufCtx* tpc = (TestPixbufCtx*) context;
+ int width, height;
+ int requested_width, requested_height;
+ g_autoptr(GdkPixbuf) pixbuf;
+
+
+ width = 1;
+ height = 1;
+ requested_width = width;
+ requested_height = height;
+
+ if (tpc->size_func) {
+ (*tpc->size_func)(&requested_width, &requested_height, tpc->user_data);
+ }
+
+ pixbuf = gdk_pixbuf_new_from_xpm_data(xpm);
+
+ if (tpc->prepare_func) {
+ (*tpc->prepare_func)(pixbuf, NULL, tpc->user_data);
+ }
+
+ if (tpc->update_func != NULL) {
+ (*tpc->update_func)(pixbuf, 0, 0, gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf), tpc->user_data);
+ }
+
+ g_clear_object(&pixbuf);
+ g_free(tpc);
+
+ return TRUE;
+}
+
+
+static gboolean load_increment(gpointer context, const guchar* buf, guint size, GError** error) {
+ return TRUE;
+}
+
+
+void fill_vtable(GdkPixbufModule* module) {
+ module->begin_load = begin_load;
+ module->stop_load = stop_load;
+ module->load_increment = load_increment;
+}
+
+
+void fill_info(GdkPixbufFormat* info) {
+ static GdkPixbufModulePattern signature[] = {
+ {"GIF8", NULL, 100},
+ {NULL, NULL, 0}
+ };
+
+ static gchar* mime_types[] = {
+ "image/gif",
+ NULL
+ };
+
+ static gchar* extensions[] = {
+ "gif",
+ NULL
+ };
+
+ info->name = "test";
+ info->signature = signature;
+ info->domain = NULL;
+ info->description = "Loader for testing priority of loaders";
+ info->mime_types = mime_types;
+ info->extensions = extensions;
+ info->flags = GDK_PIXBUF_FORMAT_THREADSAFE;
+ info->disabled = FALSE;
+ info->license = "MIT";
+}
\ No newline at end of file
diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/meson.build b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/meson.build
new file mode 100644
index 0000000000000..d4ff6ebbf14fa
--- /dev/null
+++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/meson.build
@@ -0,0 +1,11 @@
+project('gdk-pixbuf-test-loader', 'c')
+
+gdk_pixbuf = dependency('gdk-pixbuf-2.0')
+outputColor = get_option('outputColor')
+
+shared_library('test_loader',
+ sources: ['loader.c'],
+ dependencies: [gdk_pixbuf],
+ install: true,
+ c_args: ['-DPIXBUF_COLOR="' + outputColor + '"']
+)
\ No newline at end of file
diff --git a/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/meson_options.txt b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/meson_options.txt
new file mode 100644
index 0000000000000..6d0d68a7d0792
--- /dev/null
+++ b/pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/test-loader/meson_options.txt
@@ -0,0 +1 @@
+option('outputColor', type:'string')
\ No newline at end of file
From 86b36ddedfacd964f4606313ead2e4931d6e87b2 Mon Sep 17 00:00:00 2001
From: cwyc <16950437+cwyc@users.noreply.github.com>
Date: Thu, 2 Jun 2022 13:01:06 -0400
Subject: [PATCH 10/10] cleaned up setuphook test will squash before merge
---
.../setup-hooks/wrap-gapps-hook/default.nix | 15 +--------------
.../wrap-gapps-hook/tests/sample-module.nix | 13 +++++++++++++
2 files changed, 14 insertions(+), 14 deletions(-)
create mode 100644 pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/sample-module.nix
diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix b/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
index 274e8f0806731..2879b18830ea3 100644
--- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
+++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix
@@ -43,6 +43,7 @@ makeSetupHook {
passthru.tests = let
sample-project = ./tests/sample-project;
+ mock-pixbuf-module = callPackage ./tests/sample-module.nix {};
testLib = callPackage ./tests/lib.nix { };
inherit (testLib) expectSomeLineContainingYInFileXToMentionZ;
@@ -68,20 +69,6 @@ makeSetupHook {
''
);
- # Stopgap as no modules have been packaged yet
- mock-pixbuf-module = stdenv.mkDerivation {
- name = "mock-gdk-pixbuf-module";
- 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
diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/sample-module.nix b/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/sample-module.nix
new file mode 100644
index 0000000000000..09bff039c3ad7
--- /dev/null
+++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/sample-module.nix
@@ -0,0 +1,13 @@
+{stdenv, gdk-pixbuf}:
+stdenv.mkDerivation {
+ name = "mock-gdk-pixbuf-module";
+ outputs = ["out" "bin"];
+ dontUnpack = true;
+ buildPhase = ''
+ mkdir -p $bin
+ mkdir -p $out/$(dirname ${gdk-pixbuf.cacheFile})
+ touch $out/${gdk-pixbuf.cacheFile}
+ '';
+ dontInstall = true;
+ dontFixup = true;
+}
\ No newline at end of file