2022-07-14 12:49:19 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
2020-04-24 23:36:52 +00:00
|
|
|
, fetchurl
|
|
|
|
, cmake
|
|
|
|
, ninja
|
2020-05-29 06:06:01 +00:00
|
|
|
, pkg-config
|
2020-11-24 20:58:05 +00:00
|
|
|
, opencv
|
2020-04-24 23:36:52 +00:00
|
|
|
, openexr
|
|
|
|
, graphicsmagick
|
2022-07-14 12:49:19 +00:00
|
|
|
, cimg
|
2020-04-24 23:36:52 +00:00
|
|
|
, fftw
|
|
|
|
, zlib
|
|
|
|
, libjpeg
|
|
|
|
, libtiff
|
|
|
|
, libpng
|
2022-07-14 12:49:19 +00:00
|
|
|
, writeShellScript
|
|
|
|
, common-updater-scripts
|
|
|
|
, curl
|
|
|
|
, gnugrep
|
|
|
|
, gnused
|
|
|
|
, coreutils
|
|
|
|
, jq
|
2023-02-22 10:55:15 +00:00
|
|
|
, gmic-qt
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "gmic";
|
2023-04-12 12:48:02 +00:00
|
|
|
version = "3.2.3";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
outputs = [ "out" "lib" "dev" "man" ];
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
src = fetchFromGitHub {
|
2023-03-24 00:07:29 +00:00
|
|
|
owner = "GreycLab";
|
2022-07-14 12:49:19 +00:00
|
|
|
repo = "gmic";
|
2023-02-02 18:25:31 +00:00
|
|
|
rev = "v.${version}";
|
2023-04-12 12:48:02 +00:00
|
|
|
hash = "sha256-slEyZoYSNFrZ0d8a+mnJeqWQLqcJTPrkfpDpdag/vLA=";
|
2022-07-14 12:49:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# TODO: build this from source
|
|
|
|
# https://github.com/dtschump/gmic/blob/b36b2428db5926af5eea5454f822f369c2d9907e/src/Makefile#L675-L729
|
|
|
|
gmic_stdlib = fetchurl {
|
|
|
|
name = "gmic_stdlib.h";
|
|
|
|
url = "http://gmic.eu/gmic_stdlib${lib.replaceStrings ["."] [""] version}.h";
|
2023-04-12 12:48:02 +00:00
|
|
|
hash = "sha256-ExMCxFkkctqrdSy5M/TXD5GBRmRA9YEdsYW8nWiTEYY=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
ninja
|
2020-05-29 06:06:01 +00:00
|
|
|
pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
2022-07-14 12:49:19 +00:00
|
|
|
cimg
|
2020-04-24 23:36:52 +00:00
|
|
|
fftw
|
|
|
|
zlib
|
|
|
|
libjpeg
|
|
|
|
libtiff
|
|
|
|
libpng
|
2020-11-24 20:58:05 +00:00
|
|
|
opencv
|
2020-04-24 23:36:52 +00:00
|
|
|
openexr
|
|
|
|
graphicsmagick
|
|
|
|
];
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DBUILD_LIB_STATIC=OFF"
|
2020-05-29 06:06:01 +00:00
|
|
|
"-DENABLE_CURL=OFF"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DENABLE_DYNAMIC_LINKING=ON"
|
2022-07-14 12:49:19 +00:00
|
|
|
"-DUSE_SYSTEM_CIMG=ON"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
postPatch = ''
|
|
|
|
# TODO: build from source
|
|
|
|
cp -r ${gmic_stdlib} src/gmic_stdlib.h
|
|
|
|
|
|
|
|
# CMake build files were moved to subdirectory.
|
|
|
|
mv resources/CMakeLists.txt resources/cmake .
|
2022-11-02 22:02:43 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
substituteInPlace CMakeLists.txt \
|
|
|
|
--replace "LD_LIBRARY_PATH" "DYLD_LIBRARY_PATH"
|
2022-07-14 12:49:19 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
passthru = {
|
2023-02-22 10:55:15 +00:00
|
|
|
tests = {
|
|
|
|
# Needs to update in lockstep.
|
|
|
|
inherit gmic-qt;
|
|
|
|
};
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
updateScript = writeShellScript "${pname}-update-script" ''
|
|
|
|
set -o errexit
|
|
|
|
PATH=${lib.makeBinPath [ common-updater-scripts curl gnugrep gnused coreutils jq ]}
|
|
|
|
|
|
|
|
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 [[ "${version}" = "$latestVersion" ]]; then
|
|
|
|
echo "The new version same as the old version."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
for component in src gmic_stdlib; do
|
|
|
|
# The script will not perform an update when the version attribute is up to date from previous platform run
|
|
|
|
# We need to clear it before each run
|
2023-02-22 10:55:15 +00:00
|
|
|
update-source-version "--source-key=$component" "gmic" 0 "${lib.fakeHash}"
|
2022-07-14 12:49:19 +00:00
|
|
|
update-source-version "--source-key=$component" "gmic" $latestVersion
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Open and full-featured framework for image processing";
|
2020-05-29 06:06:01 +00:00
|
|
|
homepage = "https://gmic.eu/";
|
2023-03-24 00:07:29 +00:00
|
|
|
license = licenses.cecill21;
|
|
|
|
maintainers = [ maintainers.lilyinstarlight ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|