nixpkgs/pkgs/applications/graphics/gimp/default.nix
Ihar Hrachyshka dd0f03a56c treewide: remove usage of deprecated apple_sdk framework stubs
They are not doing anything right now. This is in preparation for their
complete removal from the tree.

Note: several changes that affect the derivation inputs (e.g. removal of
references to stub paths in build instructions) were left out. They will
be cleaned up the next iteration and will require special care.

Note: this PR is a result of a mix of ugly regex (not AST) based
automation and some manual labor. For reference, the regex automation
part was hacked in: https://github.com/booxter/nix-clean-apple_sdk

Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
2025-04-19 20:28:20 -04:00

328 lines
7.9 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
stdenv,
lib,
fetchurl,
replaceVars,
meson,
ninja,
pkg-config,
babl,
cfitsio,
gegl,
gtk3,
glib,
gdk-pixbuf,
graphviz,
isocodes,
pango,
cairo,
libarchive,
luajit,
freetype,
fontconfig,
lcms,
libpng,
libiff,
libilbm,
libjpeg,
libjxl,
poppler,
poppler_data,
libtiff,
libmng,
librsvg,
libwmf,
zlib,
libzip,
ghostscript,
aalib,
shared-mime-info,
python3,
libexif,
gettext,
wrapGAppsHook3,
libxslt,
gobject-introspection,
vala,
gi-docgen,
perl,
appstream-glib,
desktop-file-utils,
xorg,
glib-networking,
json-glib,
libmypaint,
llvmPackages,
gexiv2,
harfbuzz,
mypaint-brushes1,
libwebp,
libheif,
gjs,
libgudev,
openexr,
xvfb-run,
dbus,
adwaita-icon-theme,
alsa-lib,
desktopToDarwinBundle,
}:
let
python = python3.withPackages (
pp: with pp; [
pygobject3
]
);
in
stdenv.mkDerivation (finalAttrs: {
pname = "gimp";
version = "3.0.2";
outputs = [
"out"
"dev"
"devdoc"
];
src = fetchurl {
url = "https://download.gimp.org/gimp/v${lib.versions.majorMinor finalAttrs.version}/gimp-${finalAttrs.version}.tar.xz";
hash = "sha256-VG3cMMstDnkSPH/LTXghHh7npqrOkaagrYy8v26lcaI=";
};
patches = [
# to remove compiler from the runtime closure, reference was retained via
# gimp --version --verbose output
(replaceVars ./remove-cc-reference.patch {
cc_version = stdenv.cc.cc.name;
})
# Use absolute paths instead of relying on PATH
# to make sure plug-ins are loaded by the correct interpreter.
# TODO: This now only appears to be used on Windows.
(replaceVars ./hardcode-plugin-interpreters.patch {
python_interpreter = python.interpreter;
PYTHON_EXE = null;
})
# D-Bus configuration is not available in the build sandbox
# so we need to pick up the one from the package.
(replaceVars ./tests-dbus-conf.patch {
session_conf = "${dbus.out}/share/dbus-1/session.conf";
})
];
nativeBuildInputs =
[
meson
ninja
pkg-config
gettext
wrapGAppsHook3
libxslt # for xsltproc
gobject-introspection
perl
vala
# for docs
gi-docgen
# for tests
desktop-file-utils
]
++ lib.optionals stdenv.hostPlatform.isLinux [
dbus
xvfb-run
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
desktopToDarwinBundle
];
buildInputs =
[
appstream-glib # for library
babl
cfitsio
gegl
gtk3
glib
gdk-pixbuf
pango
cairo
libarchive
gexiv2
harfbuzz
isocodes
freetype
fontconfig
lcms
libpng
libiff
libilbm
libjpeg
libjxl
poppler
poppler_data
libtiff
openexr
libmng
librsvg
libwmf
zlib
libzip
ghostscript
aalib
shared-mime-info
json-glib
libwebp
libheif
python
libexif
xorg.libXpm
xorg.libXmu
glib-networking
libmypaint
mypaint-brushes1
# New file dialogue crashes with “Icon 'image-missing' not present in theme Symbolic” without an icon theme.
adwaita-icon-theme
# for Lua plug-ins
(luajit.withPackages (pp: [
pp.lgi
]))
]
++ lib.optionals stdenv.hostPlatform.isLinux [
alsa-lib
# for JavaScript plug-ins
gjs
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
llvmPackages.openmp
]
++ lib.optionals stdenv.hostPlatform.isLinux [
libgudev
];
propagatedBuildInputs = [
# needed by gimp-3.0.pc
gegl
cairo
pango
gexiv2
];
mesonFlags =
[
"-Dbug-report-url=https://github.com/NixOS/nixpkgs/issues/new"
"-Dicc-directory=/run/current-system/sw/share/color/icc"
"-Dcheck-update=no"
(lib.mesonEnable "gudev" stdenv.hostPlatform.isLinux)
(lib.mesonEnable "headless-tests" stdenv.hostPlatform.isLinux)
(lib.mesonEnable "linux-input" stdenv.hostPlatform.isLinux)
# Not very important to do downstream, save a dependency.
"-Dappdata-test=disabled"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
"-Dalsa=disabled"
"-Djavascript=disabled"
];
doCheck = true;
env = {
# The check runs before glib-networking is registered
GIO_EXTRA_MODULES = "${glib-networking}/lib/gio/modules";
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-DGDK_OSX_BIG_SUR=16";
# Check if librsvg was built with --disable-pixbuf-loader.
PKG_CONFIG_GDK_PIXBUF_2_0_GDK_PIXBUF_MODULEDIR = "${librsvg}/${gdk-pixbuf.moduleDir}";
};
postPatch = ''
patchShebangs \
app/tests/create_test_env.sh \
tools/gimp-mkenums
# GIMP is executed at build time so we need to fix this.
# TODO: Look into if we can fix the interp thing.
chmod +x plug-ins/python/{colorxhtml,file-openraster,foggify,gradients-save-as-css,histogram-export,palette-offset,palette-sort,palette-to-gradient,python-eval,spyro-plus}.py
patchShebangs \
plug-ins/python/{colorxhtml,file-openraster,foggify,gradients-save-as-css,histogram-export,palette-offset,palette-sort,palette-to-gradient,python-eval,spyro-plus}.py
'';
preBuild =
let
librarySuffix =
if stdenv.hostPlatform.extensions.library == ".so" then
"3.0.so.0"
else if stdenv.hostPlatform.extensions.library == ".dylib" then
"3.0.0.dylib"
else
throw "Unsupported library extension ${stdenv.hostPlatform.extensions.library}";
in
''
# Our gobject-introspection patches make the shared library paths absolute
# in the GIR files. When running GIMP in build or check phase, it will try
# to use plug-ins, which import GIMP introspection files which will try
# to load the GIMP libraries which will not be installed yet.
# So we need to replace the absolute path with a local one.
# We are using a symlink that will be overridden during installation.
mkdir -p "$out/lib"
ln -s "$PWD/libgimp/libgimp-${librarySuffix}" \
"$PWD/libgimpbase/libgimpbase-${librarySuffix}" \
"$PWD/libgimpcolor/libgimpcolor-${librarySuffix}" \
"$PWD/libgimpconfig/libgimpconfig-${librarySuffix}" \
"$PWD/libgimpmath/libgimpmath-${librarySuffix}" \
"$PWD/libgimpmodule/libgimpmodule-${librarySuffix}" \
"$out/lib/"
'';
preCheck = ''
# Avoid Error retrieving accessibility bus address
export NO_AT_BRIDGE=1
# Fix storing recent file list in tests
export HOME="$TMPDIR"
export XDG_DATA_DIRS="${glib.getSchemaDataDirPath gtk3}:${adwaita-icon-theme}/share:$XDG_DATA_DIRS"
'';
preFixup = ''
gappsWrapperArgs+=(--prefix PATH : "${
lib.makeBinPath [
# for dot for gegl:introspect (Debug » Show Image Graph, hidden by default on stable release)
graphviz
# for gimp-script-fu-interpreter-3.0 invoked by shebang of some plug-ins
"$out"
]
}")
'';
postFixup = ''
# Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
moveToOutput "share/doc" "$devdoc"
'';
passthru = {
# The declarations for `gimp-with-plugins` wrapper,
# used for determining plug-in installation paths
majorVersion = "${lib.versions.major finalAttrs.version}.0";
targetLibDir = "lib/gimp/${finalAttrs.passthru.majorVersion}";
targetDataDir = "share/gimp/${finalAttrs.passthru.majorVersion}";
targetPluginDir = "${finalAttrs.passthru.targetLibDir}/plug-ins";
targetScriptDir = "${finalAttrs.passthru.targetDataDir}/scripts";
# probably its a good idea to use the same gtk in plugins ?
gtk = gtk3;
};
meta = with lib; {
description = "GNU Image Manipulation Program";
homepage = "https://www.gimp.org/";
maintainers = with maintainers; [ jtojnar ];
license = licenses.gpl3Plus;
platforms = platforms.linux;
mainProgram = "gimp";
};
})