gnome._gdkPixbufCacheBuilder_DO_NOT_USE: Extract from nixos/gdk-pixbuf
Unlike previously, we now fail loudly when a package not containing a gdk-pixbuf modules is passed.
This commit is contained in:
parent
4fb7c5fd58
commit
c789af6065
|
@ -1,34 +1,17 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.xserver.gdk-pixbuf;
|
cfg = config.services.xserver.gdk-pixbuf;
|
||||||
|
|
||||||
# Get packages to generate the cache for. We always include gdk-pixbuf.
|
loadersCache = pkgs.gnome._gdkPixbufCacheBuilder_DO_NOT_USE {
|
||||||
effectivePackages = unique ([pkgs.gdk-pixbuf] ++ cfg.modulePackages);
|
extraLoaders = lib.unique (cfg.modulePackages);
|
||||||
|
};
|
||||||
# Generate the cache file by running gdk-pixbuf-query-loaders for each
|
|
||||||
# package and concatenating the results.
|
|
||||||
loadersCache = pkgs.runCommand "gdk-pixbuf-loaders.cache" { preferLocalBuild = true; } ''
|
|
||||||
(
|
|
||||||
for package in ${concatStringsSep " " effectivePackages}; do
|
|
||||||
module_dir="$package/${pkgs.gdk-pixbuf.moduleDir}"
|
|
||||||
if [[ ! -d $module_dir ]]; then
|
|
||||||
echo "Warning (services.xserver.gdk-pixbuf): missing module directory $module_dir" 1>&2
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
GDK_PIXBUF_MODULEDIR="$module_dir" \
|
|
||||||
${pkgs.stdenv.hostPlatform.emulator pkgs.buildPackages} ${pkgs.gdk-pixbuf.dev}/bin/gdk-pixbuf-query-loaders
|
|
||||||
done
|
|
||||||
) > "$out"
|
|
||||||
'';
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
services.xserver.gdk-pixbuf.modulePackages = mkOption {
|
services.xserver.gdk-pixbuf.modulePackages = lib.mkOption {
|
||||||
type = types.listOf types.package;
|
type = lib.types.listOf lib.types.package;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = lib.mdDoc "Packages providing GDK-Pixbuf modules, for cache generation.";
|
description = lib.mdDoc "Packages providing GDK-Pixbuf modules, for cache generation.";
|
||||||
};
|
};
|
||||||
|
@ -37,7 +20,7 @@ in
|
||||||
# If there is any package configured in modulePackages, we generate the
|
# If there is any package configured in modulePackages, we generate the
|
||||||
# loaders.cache based on that and set the environment variable
|
# loaders.cache based on that and set the environment variable
|
||||||
# GDK_PIXBUF_MODULE_FILE to point to it.
|
# GDK_PIXBUF_MODULE_FILE to point to it.
|
||||||
config = mkIf (cfg.modulePackages != []) {
|
config = lib.mkIf (cfg.modulePackages != []) {
|
||||||
environment.variables = {
|
environment.variables = {
|
||||||
GDK_PIXBUF_MODULE_FILE = "${loadersCache}";
|
GDK_PIXBUF_MODULE_FILE = "${loadersCache}";
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
lib.makeScope pkgs.newScope (self: with self; {
|
lib.makeScope pkgs.newScope (self: with self; {
|
||||||
updateScript = callPackage ./update.nix { };
|
updateScript = callPackage ./update.nix { };
|
||||||
|
|
||||||
|
# Temporary helper until gdk-pixbuf supports multiple cache files.
|
||||||
|
# This will go away, do not use outside Nixpkgs.
|
||||||
|
_gdkPixbufCacheBuilder_DO_NOT_USE = callPackage ./gdk-pixbuf-cache-builder.nix { };
|
||||||
|
|
||||||
libsoup = pkgs.libsoup.override { gnomeSupport = true; };
|
libsoup = pkgs.libsoup.override { gnomeSupport = true; };
|
||||||
libchamplain = pkgs.libchamplain.override { libsoup = libsoup; };
|
libchamplain = pkgs.libchamplain.override { libsoup = libsoup; };
|
||||||
|
|
||||||
|
|
37
pkgs/desktops/gnome/gdk-pixbuf-cache-builder.nix
Normal file
37
pkgs/desktops/gnome/gdk-pixbuf-cache-builder.nix
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
runCommand,
|
||||||
|
pkg-config,
|
||||||
|
gdk-pixbuf,
|
||||||
|
lib,
|
||||||
|
stdenv,
|
||||||
|
buildPackages,
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
extraLoaders,
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
# Get packages to generate the cache for. We always include gdk-pixbuf.
|
||||||
|
loaderPackages = [
|
||||||
|
gdk-pixbuf
|
||||||
|
] ++ extraLoaders;
|
||||||
|
in
|
||||||
|
|
||||||
|
# Generate the cache file by running gdk-pixbuf-query-loaders for each
|
||||||
|
# package and concatenating the results.
|
||||||
|
runCommand "gdk-pixbuf-loaders.cache" {
|
||||||
|
preferLocalBuild = true;
|
||||||
|
} ''
|
||||||
|
(
|
||||||
|
for package in ${lib.escapeShellArgs loaderPackages}; do
|
||||||
|
module_dir="$package/${gdk-pixbuf.moduleDir}"
|
||||||
|
if [[ ! -d "$module_dir" ]]; then
|
||||||
|
echo "Error: gdkPixbufCacheBuilder: Passed package “''${package}” does not contain GdkPixbuf loaders in “${gdk-pixbuf.moduleDir}”." 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
GDK_PIXBUF_MODULEDIR="$module_dir" \
|
||||||
|
${stdenv.hostPlatform.emulator buildPackages} ${gdk-pixbuf.dev}/bin/gdk-pixbuf-query-loaders
|
||||||
|
done
|
||||||
|
) > "$out"
|
||||||
|
''
|
Loading…
Reference in a new issue