about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/graphics/gmic-qt/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/graphics/gmic-qt/default.nix')
-rw-r--r--nixpkgs/pkgs/tools/graphics/gmic-qt/default.nix120
1 files changed, 74 insertions, 46 deletions
diff --git a/nixpkgs/pkgs/tools/graphics/gmic-qt/default.nix b/nixpkgs/pkgs/tools/graphics/gmic-qt/default.nix
index 29d326439d7f..a8cf4b85c83e 100644
--- a/nixpkgs/pkgs/tools/graphics/gmic-qt/default.nix
+++ b/nixpkgs/pkgs/tools/graphics/gmic-qt/default.nix
@@ -1,31 +1,31 @@
 { lib
-, mkDerivation
-, variant ? "standalone"
-, fetchFromGitHub
+, stdenv
+, fetchzip
+, cimg
 , cmake
-, pkg-config
-, ninja
-, opencv3
-, openexr
-, graphicsmagick
+, coreutils
+, curl
 , fftw
-, zlib
+, gimp
+, gimpPlugins
+, gmic
+, gnugrep
+, gnused
+, graphicsmagick
 , libjpeg
-, libtiff
 , libpng
-, curl
-, krita ? null
-, gimp ? null
-, gmic
-, cimg
+, libtiff
+, ninja
+, nix-update
+, opencv3
+, openexr
+, pkg-config
 , qtbase
 , qttools
+, wrapQtAppsHook
 , writeShellScript
-, common-updater-scripts
-, gnugrep
-, gnused
-, coreutils
-, jq
+, zlib
+, variant ? "standalone"
 }:
 
 let
@@ -38,13 +38,6 @@ let
       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";
     };
@@ -52,30 +45,32 @@ let
 
 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.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.";
+assert lib.assertMsg
+  (builtins.all (d: d != null) variants.${variant}.extraDeps or [])
+  "gmic-qt variant \"${variant}\" is missing one of its dependencies.";
 
-mkDerivation rec {
+stdenv.mkDerivation (finalAttrs: {
   pname = "gmic-qt${lib.optionalString (variant != "standalone") "-${variant}"}";
-  version = "3.1.5";
+  version = "3.2.5";
 
-  src = fetchFromGitHub {
-    owner = "c-koi";
-    repo = "gmic-qt";
-    rev = "v.${version}";
-    sha256 = "rSBdh6jhiVZogZADEKn3g7bkGPnWWOEnRF0jNCe1BCk=";
+  src = fetchzip {
+    url = "https://gmic.eu/files/source/gmic_${finalAttrs.version}.tar.gz";
+    hash = "sha256-mfDcRG6zEjEuemCaLUOLzbbcq8FN9+n+EqN0NeR9H7U=";
   };
 
   nativeBuildInputs = [
     cmake
     pkg-config
     ninja
+    wrapQtAppsHook
   ];
 
   buildInputs = [
     gmic
-    cimg
     qtbase
     qttools
     fftw
@@ -89,10 +84,9 @@ mkDerivation rec {
     curl
   ] ++ variants.${variant}.extraDeps or [];
 
-  cmakeFlags = [
-    "-DGMIC_QT_HOST=${if variant == "standalone" then "none" else variant}"
-    "-DENABLE_SYSTEM_GMIC:BOOL=ON"
-  ];
+  preConfigure = ''
+    cd gmic-qt
+  '';
 
   postPatch = ''
     patchShebangs \
@@ -100,15 +94,49 @@ mkDerivation rec {
       translations/lrelease.sh
   '';
 
+  cmakeFlags = [
+    "-DGMIC_QT_HOST=${if variant == "standalone" then "none" else variant}"
+    "-DENABLE_SYSTEM_GMIC=ON"
+    "-DENABLE_DYNAMIC_LINKING=ON"
+  ];
+
   postFixup = lib.optionalString (variant == "gimp") ''
     echo "wrapping $out/${gimp.targetPluginDir}/gmic_gimp_qt/gmic_gimp_qt"
     wrapQtApp "$out/${gimp.targetPluginDir}/gmic_gimp_qt/gmic_gimp_qt"
   '';
 
-  meta = with lib; {
-    description = variants.${variant}.description;
+  passthru = {
+    tests = {
+      gimp-plugin = gimpPlugins.gmic;
+      # Needs to update them all in lockstep.
+      inherit cimg gmic;
+    };
+
+    updateScript = writeShellScript "gmic-qt-update-script" ''
+      set -euo pipefail
+
+      export PATH="${lib.makeBinPath [ coreutils curl gnugrep gnused nix-update ]}:$PATH"
+
+      latestVersion=$(curl 'https://gmic.eu/files/source/' \
+                       | grep -E 'gmic_[^"]+\.tar\.gz' \
+                       | sed -E 's/.+<a href="gmic_([^"]+)\.tar\.gz".+/\1/g' \
+                       | sort --numeric-sort --reverse | head -n1)
+
+      if [[ '${finalAttrs.version}' = "$latestVersion" ]]; then
+          echo "The new version same as the old version."
+          exit 0
+      fi
+
+      nix-update --version "$latestVersion"
+    '';
+  };
+
+  meta = {
     homepage = "http://gmic.eu/";
-    license = licenses.gpl3Plus;
-    platforms = platforms.unix;
+    inherit (variants.${variant}) description;
+    license = lib.licenses.gpl3Plus;
+    maintainers = [ lib.maintainers.lilyinstarlight ];
+    platforms = lib.platforms.unix;
+    mainProgram = "gmic_qt";
   };
-}
+})