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
    ];
}
```
This commit is contained in:
lelgenio 2024-01-30 23:24:14 -03:00
parent ba746ff713
commit 54e0dba1d2
3 changed files with 28 additions and 8 deletions

View File

@ -1,4 +1,4 @@
{ mkDerivation, lib, stdenv, fetchpatch, makeWrapper, fetchurl, cmake, extra-cmake-modules
{ mkDerivation, lib, stdenv, fetchpatch, fetchurl, cmake, extra-cmake-modules
, karchive, kconfig, kwidgetsaddons, kcompletion, kcoreaddons
, kguiaddons, ki18n, kitemmodels, kitemviews, kwindowsystem
, kio, kcrash, breeze-icons
@ -13,7 +13,7 @@
}:
mkDerivation rec {
pname = "krita";
pname = "krita-unwrapped";
inherit version;
src = fetchurl {
@ -36,7 +36,7 @@ mkDerivation rec {
})
];
nativeBuildInputs = [ cmake extra-cmake-modules pkg-config python3Packages.sip makeWrapper ];
nativeBuildInputs = [ cmake extra-cmake-modules pkg-config python3Packages.sip ];
buildInputs = [
karchive kconfig kwidgetsaddons kcompletion kcoreaddons kguiaddons
@ -72,14 +72,11 @@ mkDerivation rec {
"-DBUILD_KRITA_QT_DESIGNER_PLUGINS=ON"
];
preInstall = ''
qtWrapperArgs+=(--prefix PYTHONPATH : "$PYTHONPATH")
'';
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;
};

View File

@ -0,0 +1,23 @@
{ lib
, libsForQt5
, symlinkJoin
, unwrapped ? libsForQt5.callPackage ./. { }
, binaryPlugins ? [ ]
}:
symlinkJoin {
name = lib.replaceStrings [ "-unwrapped" ] [ "" ] unwrapped.name;
inherit (unwrapped) version buildInputs nativeBuildInputs meta;
paths = [ unwrapped ] ++ binaryPlugins;
postBuild = ''
wrapQtApp "$out/bin/krita" \
--prefix PYTHONPATH : "$PYTHONPATH" \
--set KRITA_PLUGIN_PATH "$out/lib/kritaplugins"
'';
passthru = {
inherit unwrapped binaryPlugins;
};
}

View File

@ -32833,7 +32833,7 @@ with pkgs;
krane = callPackage ../applications/networking/cluster/krane { };
krita = libsForQt5.callPackage ../applications/graphics/krita { };
krita = callPackage ../applications/graphics/krita/wrapper.nix { };
ksuperkey = callPackage ../tools/X11/ksuperkey { };