2023-05-24 13:37:59 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2022-07-14 12:49:19 +00:00
|
|
|
, fetchFromGitHub
|
2020-04-24 23:36:52 +00:00
|
|
|
, fetchurl
|
2022-07-14 12:49:19 +00:00
|
|
|
, cimg
|
2023-05-24 13:37:59 +00:00
|
|
|
, cmake
|
2022-07-14 12:49:19 +00:00
|
|
|
, common-updater-scripts
|
2023-05-24 13:37:59 +00:00
|
|
|
, coreutils
|
2022-07-14 12:49:19 +00:00
|
|
|
, curl
|
2023-05-24 13:37:59 +00:00
|
|
|
, fftw
|
|
|
|
, gmic-qt
|
2022-07-14 12:49:19 +00:00
|
|
|
, gnugrep
|
|
|
|
, gnused
|
2023-05-24 13:37:59 +00:00
|
|
|
, graphicsmagick
|
2022-07-14 12:49:19 +00:00
|
|
|
, jq
|
2023-05-24 13:37:59 +00:00
|
|
|
, libjpeg
|
|
|
|
, libpng
|
|
|
|
, libtiff
|
|
|
|
, ninja
|
|
|
|
, opencv
|
|
|
|
, openexr
|
|
|
|
, pkg-config
|
|
|
|
, writeShellScript
|
|
|
|
, zlib
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "gmic";
|
2023-07-15 17:15:38 +00:00
|
|
|
version = "3.2.6";
|
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-05-24 13:37:59 +00:00
|
|
|
rev = "v.${finalAttrs.version}";
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-kaI5rcAz3Cw/xzWgJhMRu/cQwVrvLRAPiB5BhzPMOHY=";
|
2022-07-14 12:49:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# TODO: build this from source
|
2023-05-24 13:37:59 +00:00
|
|
|
# Reference: src/Makefile, directive gmic_stdlib.h
|
2022-07-14 12:49:19 +00:00
|
|
|
gmic_stdlib = fetchurl {
|
|
|
|
name = "gmic_stdlib.h";
|
2023-05-24 13:37:59 +00:00
|
|
|
url = "http://gmic.eu/gmic_stdlib${lib.replaceStrings ["."] [""] finalAttrs.version}.h";
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-7JzFU4HvAtC5Nz5vusKCnJ8VMuKfSi1yFmjj0Hh+vA4=";
|
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
|
2023-05-24 13:37:59 +00:00
|
|
|
graphicsmagick
|
2020-04-24 23:36:52 +00:00
|
|
|
libjpeg
|
|
|
|
libpng
|
2023-05-24 13:37:59 +00:00
|
|
|
libtiff
|
2020-11-24 20:58:05 +00:00
|
|
|
opencv
|
2020-04-24 23:36:52 +00:00
|
|
|
openexr
|
2023-05-24 13:37:59 +00:00
|
|
|
zlib
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
cmakeFlags = [
|
2023-10-09 19:29:22 +00:00
|
|
|
(lib.cmakeBool "BUILD_LIB_STATIC" false)
|
|
|
|
(lib.cmakeBool "ENABLE_CURL" false)
|
|
|
|
(lib.cmakeBool "ENABLE_DYNAMIC_LINKING" true)
|
|
|
|
(lib.cmakeBool "USE_SYSTEM_CIMG" true)
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
postPatch = ''
|
2023-05-24 13:37:59 +00:00
|
|
|
cp -r ${finalAttrs.gmic_stdlib} src/gmic_stdlib.h
|
2022-07-14 12:49:19 +00:00
|
|
|
|
|
|
|
# CMake build files were moved to subdirectory.
|
|
|
|
mv resources/CMakeLists.txt resources/cmake .
|
2023-05-24 13:37:59 +00:00
|
|
|
''
|
|
|
|
+ lib.optionalString stdenv.isDarwin ''
|
2022-11-02 22:02:43 +00:00
|
|
|
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 = {
|
2023-05-24 13:37:59 +00:00
|
|
|
# Needs to update them all in lockstep.
|
|
|
|
inherit cimg gmic-qt;
|
2023-02-22 10:55:15 +00:00
|
|
|
};
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
updateScript = writeShellScript "gmic-update-script" ''
|
2022-07-14 12:49:19 +00:00
|
|
|
set -o errexit
|
2023-05-24 13:37:59 +00:00
|
|
|
PATH=${lib.makeBinPath [ common-updater-scripts coreutils curl gnugrep gnused jq ]}
|
2022-07-14 12:49:19 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
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)
|
2022-07-14 12:49:19 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
if [[ "${finalAttrs.version}" = "$latestVersion" ]]; then
|
2022-07-14 12:49:19 +00:00
|
|
|
echo "The new version same as the old version."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
for component in src gmic_stdlib; do
|
2023-05-24 13:37:59 +00:00
|
|
|
# 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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
meta = {
|
2020-05-29 06:06:01 +00:00
|
|
|
homepage = "https://gmic.eu/";
|
2023-05-24 13:37:59 +00:00
|
|
|
description = "Open and full-featured framework for image processing";
|
|
|
|
license = lib.licenses.cecill21;
|
2023-10-09 19:29:22 +00:00
|
|
|
maintainers = [
|
|
|
|
lib.maintainers.AndersonTorres
|
|
|
|
lib.maintainers.lilyinstarlight
|
|
|
|
];
|
2023-05-24 13:37:59 +00:00
|
|
|
platforms = lib.platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2023-05-24 13:37:59 +00:00
|
|
|
})
|