summary refs log tree commit diff
path: root/pkgs/tools/graphics/gmic-qt/default.nix
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2019-09-07 12:33:56 +0200
committerJan Tojnar <jtojnar@gmail.com>2019-09-07 19:55:11 +0200
commitd8749430e43c05e3ee1602eb1a12d53362ae29e7 (patch)
tree87dacc7e7af97915f9f6b5dfa3130c0086500137 /pkgs/tools/graphics/gmic-qt/default.nix
parent8ad04d92f6be2254f58024842fbdbea7afd5e1c5 (diff)
downloadnixpkgs-d8749430e43c05e3ee1602eb1a12d53362ae29e7.tar
nixpkgs-d8749430e43c05e3ee1602eb1a12d53362ae29e7.tar.gz
nixpkgs-d8749430e43c05e3ee1602eb1a12d53362ae29e7.tar.bz2
nixpkgs-d8749430e43c05e3ee1602eb1a12d53362ae29e7.tar.lz
nixpkgs-d8749430e43c05e3ee1602eb1a12d53362ae29e7.tar.xz
nixpkgs-d8749430e43c05e3ee1602eb1a12d53362ae29e7.tar.zst
nixpkgs-d8749430e43c05e3ee1602eb1a12d53362ae29e7.zip
gmic-qt: allow building non-Krita hosts
* Use qt5’s mkDerivation
* Also switch gimpPlugins.gmic to qmic-qt
Diffstat (limited to 'pkgs/tools/graphics/gmic-qt/default.nix')
-rw-r--r--pkgs/tools/graphics/gmic-qt/default.nix73
1 files changed, 60 insertions, 13 deletions
diff --git a/pkgs/tools/graphics/gmic-qt/default.nix b/pkgs/tools/graphics/gmic-qt/default.nix
index 44e9243d91c..b8714e9b355 100644
--- a/pkgs/tools/graphics/gmic-qt/default.nix
+++ b/pkgs/tools/graphics/gmic-qt/default.nix
@@ -1,5 +1,8 @@
-{ stdenv
+{ lib
+, mkDerivation
 , fetchurl
+, fetchpatch
+, variant ? "standalone"
 , fetchFromGitHub
 , cmake
 , pkgconfig
@@ -12,17 +15,44 @@
 , libtiff
 , libpng
 , curl
-, krita
+, krita ? null
+, gimp ? null
 , qtbase
 , qttools
 , fetchgit
 }:
 
 let
+  variants = {
+    gimp = {
+      extraDeps = [
+        gimp
+        gimp.gtk
+      ];
+      description = "GIMP plugin for the G'MIC image processing framework";
+    };
+
+    krita = {
+      extraDeps = [
+        krita
+      ];
+      description = "Krita plugin for the G'MIC image processing framework";
+    };
+
+    standalone = {
+      description = "Versatile front-end to the image processing framework G'MIC";
+    };
+  };
+
+in
+
+assert lib.assertMsg (builtins.hasAttr variant variants) "gmic-qt variant “${variant}” is not supported. Please use one of ${lib.concatStringsSep ", " (builtins.attrNames variants)}.";
+
+assert lib.assertMsg (builtins.all (d: d != null) variants.${variant}.extraDeps or []) "gmic-qt variant “${variant}” is missing one of its dependencies.";
+
+mkDerivation rec {
+  pname = "gmic-qt${lib.optionalString (variant != "standalone") ''-${variant}''}";
   version = "2.3.6";
-in stdenv.mkDerivation rec {
-  pname = "gmic_krita_qt";
-  inherit version;
 
   gmic-community = fetchFromGitHub {
     owner = "dtschump";
@@ -58,6 +88,24 @@ in stdenv.mkDerivation rec {
     sha256 = "0j9wqlq67dwzir36yg58xy5lbblwizvgcvlmzcv9d6l901d5ayf3";
   };
 
+  patches = [
+    # Add install targets
+    (fetchpatch {
+      url = https://github.com/c-koi/gmic-qt/commit/ec4babbaf06a8711a4fd841f7de4106cda765109.patch;
+      sha256 = "1rim6vjx3k0yw8mplq8ampb2ykfabjj6d8vynmp8lm6n8id99yr0";
+    })
+
+    # Fix translations installation
+    (fetchpatch {
+      url = https://github.com/c-koi/gmic-qt/commit/91f92ba589d6559541d5dfacf39dab4e0faaa106.patch;
+      sha256 = "1kh39349qcna386lx80kgj87xxlyh95xmwnv539z4zqnpzyqdxfs";
+    })
+
+    # Install GIMP plug-in to a correct destination
+    # https://github.com/c-koi/gmic-qt/pull/78
+    ./fix-gimp-plugin-path.patch
+  ];
+
   unpackPhase = ''
     cp -r ${gmic} gmic
     ln -s ${gmic-community} gmic-community
@@ -91,20 +139,19 @@ in stdenv.mkDerivation rec {
     openexr
     graphicsmagick
     curl
-    krita
-  ];
+  ] ++ variants.${variant}.extraDeps or [];
 
   cmakeFlags = [
-    "-DGMIC_QT_HOST=krita"
+    "-DGMIC_QT_HOST=${if variant == "standalone" then "none" else variant}"
   ];
 
-  installPhase = ''
-    mkdir -p $out/bin;
-    install -Dm755 gmic_krita_qt "$out/bin/gmic_krita_qt"
+  postFixup = lib.optionalString (variant == "gimp") ''
+    echo "wrapping $out/${gimp.targetPluginDir}/gmic_gimp_qt"
+    wrapQtApp "$out/${gimp.targetPluginDir}/gmic_gimp_qt"
   '';
 
-  meta = with stdenv.lib; {
-    description = "Krita plugin for the G'MIC image processing framework";
+  meta = with lib; {
+    description = variants.${variant}.description;
     homepage = http://gmic.eu/;
     license = licenses.gpl3;
     platforms = platforms.unix;