nixpkgs/pkgs/applications/graphics/krita/generic.nix
lelgenio 54e0dba1d2 krita: create wrapper
You can tell Krita to look for plugins at an alternative
directory using KRITA_PLUGIN_PATH env variable.

Unfortunately you can only specify a single path at a time.
Some plugins necessary for krita to funciton are built
in the same derivation, this necessitates the use of `symlinkJoin`.

This patch adds a wrapper around krita that allows yout to add
more plugins than those provided by default.

Example structure of a plugin:

/nix/store/00000000000000000000000000000000-krita-plugin-example-1.2.3
└── lib
   └── kritaplugins
      └── krita_example.so

Once you have a plugin, you can add it to krita:

```nix
pkgs.krita.override {
    plugins = pkgs.krita.plugins ++ [
        your-plugin
    ];
}
```
2024-02-27 21:30:27 -03:00

84 lines
3.2 KiB
Nix

{ mkDerivation, lib, stdenv, fetchpatch, fetchurl, cmake, extra-cmake-modules
, karchive, kconfig, kwidgetsaddons, kcompletion, kcoreaddons
, kguiaddons, ki18n, kitemmodels, kitemviews, kwindowsystem
, kio, kcrash, breeze-icons
, boost, libraw, fftw, eigen, exiv2, fribidi, libaom, libheif, libkdcraw, lcms2, gsl, openexr, giflib
, libjxl, mlt , openjpeg, opencolorio, xsimd, poppler, curl, ilmbase, immer, kseexpr, lager
, libmypaint , libunibreak, libwebp
, qtmultimedia, qtx11extras, quazip, SDL2, zug, pkg-config
, python3Packages
, version
, kde-channel
, hash
}:
mkDerivation rec {
pname = "krita-unwrapped";
inherit version;
src = fetchurl {
url = "mirror://kde/${kde-channel}/krita/${version}/krita-${version}.tar.gz";
inherit hash;
};
patches = [
# Fixes build with SIP 6.8
(fetchpatch {
name = "bump-SIP-ABI-version-to-12.8.patch";
url = "https://invent.kde.org/graphics/krita/-/commit/2d71c47661d43a4e3c1ab0c27803de980bdf2bb2.diff";
hash = "sha256-U3E44nj4vra++PJV20h4YHjES78kgrJtr4ktNeQfOdA=";
})
# Fixes build with libjxl 0.9.0
(fetchpatch {
name = "fix-build-with-libjxl-0.9.0.patch";
url = "https://invent.kde.org/graphics/krita/-/commit/ace7edcca6ad322581ab39620f21ccf3ffbd3b5a.diff";
hash = "sha256-dXk4+HNS0+Ie/8V4+Oj4rBJrJbNHG57gIzPymXLEc9M=";
})
];
nativeBuildInputs = [ cmake extra-cmake-modules pkg-config python3Packages.sip ];
buildInputs = [
karchive kconfig kwidgetsaddons kcompletion kcoreaddons kguiaddons
ki18n kitemmodels kitemviews kwindowsystem kio kcrash breeze-icons
boost libraw fftw eigen exiv2 fribidi lcms2 gsl openexr lager libaom libheif libkdcraw giflib
libjxl mlt openjpeg opencolorio xsimd poppler curl ilmbase immer kseexpr libmypaint
libunibreak libwebp qtmultimedia qtx11extras quazip SDL2 zug
python3Packages.pyqt5
];
env.NIX_CFLAGS_COMPILE = toString ([ "-I${ilmbase.dev}/include/OpenEXR" ]
++ lib.optional stdenv.cc.isGNU "-Wno-deprecated-copy");
# Krita runs custom python scripts in CMake with custom PYTHONPATH which krita determined in their CMake script.
# Patch the PYTHONPATH so python scripts can import sip successfully.
postPatch = let
pythonPath = python3Packages.makePythonPath (with python3Packages; [ sip setuptools ]);
in ''
substituteInPlace cmake/modules/FindSIP.cmake \
--replace 'PYTHONPATH=''${_sip_python_path}' 'PYTHONPATH=${pythonPath}'
substituteInPlace cmake/modules/SIPMacros.cmake \
--replace 'PYTHONPATH=''${_krita_python_path}' 'PYTHONPATH=${pythonPath}'
substituteInPlace plugins/impex/jp2/jp2_converter.cc \
--replace '<openjpeg.h>' '<${openjpeg.incDir}/openjpeg.h>'
'';
cmakeBuildType = "RelWithDebInfo";
cmakeFlags = [
"-DPYQT5_SIP_DIR=${python3Packages.pyqt5}/${python3Packages.python.sitePackages}/PyQt5/bindings"
"-DPYQT_SIP_DIR_OVERRIDE=${python3Packages.pyqt5}/${python3Packages.python.sitePackages}/PyQt5/bindings"
"-DBUILD_KRITA_QT_DESIGNER_PLUGINS=ON"
];
meta = with lib; {
description = "A free and open source painting application";
homepage = "https://krita.org/";
maintainers = with maintainers; [ abbradar sifmelcara nek0 ];
mainProgram = "krita";
platforms = platforms.linux;
license = licenses.gpl3Only;
};
}