git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #42562 from ambrop72/gdk-pixbuf-fix

Use a NixOS module for generating the gdk-pixbuf loaders cache.

commita112f16a75af5f4c70986992507d945027c1f38f authorJan Tojnar <jtojnar@gmail.com> dateFri 12 Oct 2018, 15:52 (8 years ago) parent6bd73e8d9fa88d
4 files changed+50−5
nixos/modules/module-list.nix+1 nixos/modules/services/x11/desktop-managers/plasma5.nix+2−4 nixos/modules/services/x11/desktop-managers/xfce.nix+2−1 nixos/modules/services/x11/gdk-pixbuf.nix+45
nixos/modules/module-list.nix+1
@@ -742,6 +742,7 @@
742742 ./services/x11/hardware/multitouch.nix
743743 ./services/x11/hardware/synaptics.nix
744744 ./services/x11/hardware/wacom.nix
745+ ./services/x11/gdk-pixbuf.nix
745746 ./services/x11/redshift.nix
746747 ./services/x11/urxvtd.nix
747748 ./services/x11/window-managers/awesome.nix
nixos/modules/services/x11/desktop-managers/plasma5.nix+2−4
@@ -185,10 +185,8 @@ in
185185 target = "X11/xkb";
186186 };
187187
188− environment.variables = {
189− # Enable GTK applications to load SVG icons
190− GDK_PIXBUF_MODULE_FILE = "${pkgs.librsvg.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache";
191− };
188+ # Enable GTK applications to load SVG icons
189+ services.xserver.gdk-pixbuf.modulePackages = [ pkgs.librsvg ];
192190
193191 fonts.fonts = with pkgs; [ noto-fonts hack-font ];
194192 fonts.fontconfig.defaultFonts = {
nixos/modules/services/x11/desktop-managers/xfce.nix+2−1
@@ -101,10 +101,11 @@ in
101101 ];
102102
103103 environment.variables = {
104− GDK_PIXBUF_MODULE_FILE = "${pkgs.librsvg.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache";
105104 GIO_EXTRA_MODULES = [ "${pkgs.xfce.gvfs}/lib/gio/modules" ];
106105 };
107106
107+ services.xserver.gdk-pixbuf.modulePackages = [ pkgs.librsvg ];
108+
108109 services.xserver.desktopManager.session = [{
109110 name = "xfce";
110111 bgSupport = true;
nixos/modules/services/x11/gdk-pixbuf.nixnew file+45
@@ -0,0 +1,45 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.xserver.gdk-pixbuf;
7+
8+ # Get packages to generate the cache for. We always include gdk_pixbuf.
9+ effectivePackages = unique ([pkgs.gdk_pixbuf] ++ cfg.modulePackages);
10+
11+ # Generate the cache file by running gdk-pixbuf-query-loaders for each
12+ # package and concatenating the results.
13+ loadersCache = pkgs.runCommand "gdk-pixbuf-loaders.cache" {} ''
14+ (
15+ for package in ${concatStringsSep " " effectivePackages}; do
16+ module_dir="$package/${pkgs.gdk_pixbuf.moduleDir}"
17+ if [[ ! -d $module_dir ]]; then
18+ echo "Warning (services.xserver.gdk-pixbuf): missing module directory $module_dir" 1>&2
19+ continue
20+ fi
21+ GDK_PIXBUF_MODULEDIR="$module_dir" \
22+ ${pkgs.gdk_pixbuf.dev}/bin/gdk-pixbuf-query-loaders
23+ done
24+ ) > "$out"
25+ '';
26+in
27+
28+{
29+ options = {
30+ services.xserver.gdk-pixbuf.modulePackages = mkOption {
31+ type = types.listOf types.package;
32+ default = [ ];
33+ description = "Packages providing GDK-Pixbuf modules, for cache generation.";
34+ };
35+ };
36+
37+ # If there is any package configured in modulePackages, we generate the
38+ # loaders.cache based on that and set the environment variable
39+ # GDK_PIXBUF_MODULE_FILE to point to it.
40+ config = mkIf (cfg.modulePackages != []) {
41+ environment.variables = {
42+ GDK_PIXBUF_MODULE_FILE = "${loadersCache}";
43+ };
44+ };
45+}