From 54e0dba1d2ac0ed0b7219ade72d6301eb206147e Mon Sep 17 00:00:00 2001 From: lelgenio Date: Tue, 30 Jan 2024 23:24:14 -0300 Subject: [PATCH] krita: create wrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 ]; } ``` --- pkgs/applications/graphics/krita/generic.nix | 11 ++++------ pkgs/applications/graphics/krita/wrapper.nix | 23 ++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 +- 3 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 pkgs/applications/graphics/krita/wrapper.nix diff --git a/pkgs/applications/graphics/krita/generic.nix b/pkgs/applications/graphics/krita/generic.nix index 9416a4708e4c..8df637ffa1ce 100644 --- a/pkgs/applications/graphics/krita/generic.nix +++ b/pkgs/applications/graphics/krita/generic.nix @@ -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; }; diff --git a/pkgs/applications/graphics/krita/wrapper.nix b/pkgs/applications/graphics/krita/wrapper.nix new file mode 100644 index 000000000000..ff6158e23e1a --- /dev/null +++ b/pkgs/applications/graphics/krita/wrapper.nix @@ -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; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3f02e66bd02e..8c9f5f829219 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 { };