{ stdenv , lib , fetchFromGitHub , fetchurl , cmake , ninja , pkg-config , opencv , openexr , graphicsmagick , cimg , fftw , zlib , libjpeg , libtiff , libpng , writeShellScript , common-updater-scripts , curl , gnugrep , gnused , coreutils , jq , gmic-qt }: stdenv.mkDerivation rec { pname = "gmic"; version = "3.2.2"; outputs = [ "out" "lib" "dev" "man" ]; src = fetchFromGitHub { owner = "GreycLab"; repo = "gmic"; rev = "v.${version}"; hash = "sha256-XLDnIs7IRIhQtz+qgdNypJODk6WJRPQ2M6LU6DJ+T7I="; }; # 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"; hash = "sha256-lABUPhwlzoRODX7z8arOEU0JJszcXREhZ20WRToKNY4="; }; nativeBuildInputs = [ cmake ninja pkg-config ]; buildInputs = [ cimg fftw zlib libjpeg libtiff libpng opencv openexr graphicsmagick ]; cmakeFlags = [ "-DBUILD_LIB_STATIC=OFF" "-DENABLE_CURL=OFF" "-DENABLE_DYNAMIC_LINKING=ON" "-DUSE_SYSTEM_CIMG=ON" ]; 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 . '' + lib.optionalString stdenv.isDarwin '' substituteInPlace CMakeLists.txt \ --replace "LD_LIBRARY_PATH" "DYLD_LIBRARY_PATH" ''; passthru = { tests = { # Needs to update in lockstep. inherit gmic-qt; }; 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/.+