From 54e0dba1d2ac0ed0b7219ade72d6301eb206147e Mon Sep 17 00:00:00 2001 From: lelgenio Date: Tue, 30 Jan 2024 23:24:14 -0300 Subject: [PATCH 1/3] 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 { }; From d4bb486c8df40b44acf6909c0a7ce9f875c1d933 Mon Sep 17 00:00:00 2001 From: lelgenio Date: Tue, 30 Jan 2024 23:24:34 -0300 Subject: [PATCH 2/3] krita-plugin-gmic: init at 3.2.4.1 --- pkgs/applications/graphics/krita/wrapper.nix | 6 ++- pkgs/by-name/kr/krita-plugin-gmic/package.nix | 51 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 pkgs/by-name/kr/krita-plugin-gmic/package.nix diff --git a/pkgs/applications/graphics/krita/wrapper.nix b/pkgs/applications/graphics/krita/wrapper.nix index ff6158e23e1a..6d62412e5662 100644 --- a/pkgs/applications/graphics/krita/wrapper.nix +++ b/pkgs/applications/graphics/krita/wrapper.nix @@ -2,7 +2,11 @@ , libsForQt5 , symlinkJoin , unwrapped ? libsForQt5.callPackage ./. { } -, binaryPlugins ? [ ] +, krita-plugin-gmic +, binaryPlugins ? [ + # Default plugins provided by upstream appimage + krita-plugin-gmic + ] }: symlinkJoin { diff --git a/pkgs/by-name/kr/krita-plugin-gmic/package.nix b/pkgs/by-name/kr/krita-plugin-gmic/package.nix new file mode 100644 index 000000000000..4cd46efd083a --- /dev/null +++ b/pkgs/by-name/kr/krita-plugin-gmic/package.nix @@ -0,0 +1,51 @@ +{ lib +, stdenv +, fetchFromGitHub +, cmake +, extra-cmake-modules +, fftw +, krita +, libsForQt5 +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "krita-plugin-gmic"; + version = "3.2.4.1"; + + src = fetchFromGitHub { + owner = "amyspark"; + repo = "gmic"; + rev = "v${finalAttrs.version}"; + hash = "sha256-SYE8kGvN7iD5OqiEEZpB/eRle67PrB5DojMC79qAQtg="; + }; + sourceRoot = "${finalAttrs.src.name}/gmic-qt"; + dontWrapQtApps = true; + + postPatch = '' + patchShebangs \ + translations/filters/csv2ts.sh \ + translations/lrelease.sh + ''; + + nativeBuildInputs = [ cmake extra-cmake-modules ]; + + buildInputs = [ + fftw + krita.unwrapped + libsForQt5.kcoreaddons + libsForQt5.qttools + ]; + + cmakeFlags = [ + (lib.cmakeFeature "GMIC_QT_HOST" "krita-plugin") + # build krita's gmic instead of using the one from nixpkgs + (lib.cmakeBool "ENABLE_SYSTEM_GMIC" false) + ]; + + meta = with lib; { + homepage = "https://github.com/amyspark/gmic"; + description = "GMic plugin for Krita"; + license = lib.licenses.cecill21; + maintainers = with maintainers; [ lelgenio ]; + }; +}) From 1816172445bb714c9b4766f93c90aeb7f9b7e58f Mon Sep 17 00:00:00 2001 From: lelgenio Date: Wed, 7 Feb 2024 15:12:22 -0300 Subject: [PATCH 3/3] doc: add krita plugins section --- doc/packages/index.md | 1 + doc/packages/krita.section.md | 37 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 doc/packages/krita.section.md diff --git a/doc/packages/index.md b/doc/packages/index.md index 1f45018ffc4a..38dba5b3498f 100644 --- a/doc/packages/index.md +++ b/doc/packages/index.md @@ -14,6 +14,7 @@ fish.section.md fuse.section.md ibus.section.md kakoune.section.md +krita.section.md linux.section.md locales.section.md etc-files.section.md diff --git a/doc/packages/krita.section.md b/doc/packages/krita.section.md new file mode 100644 index 000000000000..ba427bd62ba1 --- /dev/null +++ b/doc/packages/krita.section.md @@ -0,0 +1,37 @@ +# Krita {#sec-krita} + +## Python plugins {#krita-python-plugins} + +"pykrita" plugins should be installed following +[Krita's manual](https://docs.krita.org/en/user_manual/python_scripting/install_custom_python_plugin.html). +This generally involves extracting the extension to `~/.local/share/krita/pykrita/`. + +## Binary plugins {#krita-binary-plugins} + +Binary plugins are Dynamically Linked Libraries to be loaded by Krita. + +_Note: You most likely won't need to deal with binary plugins, +all known plugins are bundled and enabled by default._ + +### Installing binary plugins {#krita-install-binary-plugins} + +You can choose what plugins are added to Krita by overriding the +`binaryPlugins` attribute. + +If you want to add plugins instead of replacing, you can read the +list of previous plugins via `pkgs.krita.binaryPlugins`: + +```nix +(pkgs.krita.override (old: { + binaryPlugins = old.binaryPlugins ++ [ your-plugin ]; +})) +``` + +### Example structure of a binary plugin {#krita-binary-plugin-structure} + +``` +/nix/store/00000000000000000000000000000000-krita-plugin-example-1.2.3 +└── lib + └── kritaplugins + └── krita_example.so +```