about summary refs log tree commit diff
path: root/pkgs/by-name/gm
diff options
context:
space:
mode:
authorAndrew Marshall <andrew@johnandrewmarshall.com>2024-05-19 17:54:12 -0400
committerAndrew Marshall <andrew@johnandrewmarshall.com>2024-05-20 09:24:47 -0400
commit5678aa05216e45ad1fec72f5769db61f7dff87b4 (patch)
tree3ded2d98e20db030f9a6b9deebb4cb8c30ac7761 /pkgs/by-name/gm
parent4a6b83b05df1a8bd7d99095ec4b4d271f2956b64 (diff)
gmic-qt: build from Git source to avoid mutable tarball
The previous tarball src sometimes gets mutated (see e.g. [this
comment][1]). This was changed from the Git src in
fd3e2b49f4a3138a1c3e2dd854578f64b9c772cd (see also [upstream
discussion][2]). However the delta seems simple; it had error:

```
In file included from /build/source/src/GmicProcessor.cpp:48:
/nix/store/jk1dp7v01pisw0flybqwyjg63in6r9fp-gmic-3.3.5-dev/include/gmic.h:191:21: fatal error: gmic.cpp: No such file or directory
  191 | #define cimg_plugin "gmic.cpp"
```

workaround this by linking `gmic.cpp` into the expected location as it
appears in the tarball.

cimg is now needed in buildInputs as it is bundled in the tarball, but
not the Git src.

Change the updateScript to simpler one that can use the Git tags.

This may appear to be downgrading, but this is only because the previous
drv used the gmic version, not the gmic-qt version.

[1]: https://github.com/NixOS/nixpkgs/pull/311734#issuecomment-2118663822
[2]: https://github.com/c-koi/gmic-qt/pull/175
Diffstat (limited to 'pkgs/by-name/gm')
-rw-r--r--pkgs/by-name/gm/gmic-qt/package.nix44
1 files changed, 15 insertions, 29 deletions
diff --git a/pkgs/by-name/gm/gmic-qt/package.nix b/pkgs/by-name/gm/gmic-qt/package.nix
index cae45005c57f6..8c3ff6ce4aeff 100644
--- a/pkgs/by-name/gm/gmic-qt/package.nix
+++ b/pkgs/by-name/gm/gmic-qt/package.nix
@@ -1,26 +1,22 @@
 { lib
 , cimg
 , cmake
-, coreutils
 , curl
-, fetchzip
+, fetchFromGitHub
 , fftw
 , gimp
 , gimpPlugins
 , gmic
-, gnugrep
-, gnused
 , graphicsmagick
 , libjpeg
 , libpng
 , libsForQt5
 , libtiff
 , ninja
-, nix-update
+, nix-update-script
 , openexr
 , pkg-config
 , stdenv
-, writeShellScript
 , zlib
 , variant ? "standalone"
 }:
@@ -53,15 +49,15 @@ assert lib.assertMsg
 
 stdenv.mkDerivation (finalAttrs: {
   pname = "gmic-qt${lib.optionalString (variant != "standalone") "-${variant}"}";
-  version = "3.3.6";
+  version = "3.3.5";
 
-  src = fetchzip {
-    url = "https://gmic.eu/files/source/gmic_${finalAttrs.version}.tar.gz";
-    hash = "sha256-LZwAMLvQ+X6xkvnL+7LA/UmwDBGgapUtFHNJuV04F+Y=";
+  src = fetchFromGitHub {
+    owner = "c-koi";
+    repo = "gmic-qt";
+    rev = "v.${finalAttrs.version}";
+    hash = "sha256-WApuIWqVgVJAM2WdfOiqoQ2U+9kIuq8fy6wvJ55KoIc=";
   };
 
-  sourceRoot = "${finalAttrs.src.name}/gmic-qt";
-
   nativeBuildInputs = [
     cmake
     libsForQt5.wrapQtAppsHook
@@ -70,6 +66,7 @@ stdenv.mkDerivation (finalAttrs: {
   ];
 
   buildInputs = [
+    cimg
     curl
     fftw
     gmic
@@ -88,6 +85,9 @@ stdenv.mkDerivation (finalAttrs: {
     patchShebangs \
       translations/filters/csv2ts.sh \
       translations/lrelease.sh
+
+    mkdir ../src
+    ln -s ${gmic.src}/src/gmic.cpp ../src/gmic.cpp
   '';
 
   cmakeFlags = [
@@ -108,23 +108,9 @@ stdenv.mkDerivation (finalAttrs: {
       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"
-    '';
+    updateScript = nix-update-script {
+      extraArgs = [ "--version-regex" "^v\\.(.*)" ];
+    };
   };
 
   meta = {