Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenv 3, fetchFromGitHub 4, fetchurl 5, cimg 6, cmake 7, common-updater-scripts 8, coreutils 9, curl 10, fftw 11, gmic-qt 12, gnugrep 13, gnused 14, graphicsmagick 15, jq 16, libjpeg 17, libpng 18, libtiff 19, ninja 20, opencv 21, openexr 22, pkg-config 23, writeShellScript 24, zlib 25}: 26 27stdenv.mkDerivation (finalAttrs: { 28 pname = "gmic"; 29 version = "3.2.4"; 30 31 outputs = [ "out" "lib" "dev" "man" ]; 32 33 src = fetchFromGitHub { 34 owner = "GreycLab"; 35 repo = "gmic"; 36 rev = "v.${finalAttrs.version}"; 37 hash = "sha256-ITKsPhfDfkHmE7a04cxrpIKsSVlrPN944ySu2DCnyEU="; 38 }; 39 40 # TODO: build this from source 41 # Reference: src/Makefile, directive gmic_stdlib.h 42 gmic_stdlib = fetchurl { 43 name = "gmic_stdlib.h"; 44 url = "http://gmic.eu/gmic_stdlib${lib.replaceStrings ["."] [""] finalAttrs.version}.h"; 45 hash = "sha256-ExMCxFkkctqrdSy5M/TXD5GBRmRA9YEdsYW8nWiTEYY="; 46 }; 47 48 nativeBuildInputs = [ 49 cmake 50 ninja 51 pkg-config 52 ]; 53 54 buildInputs = [ 55 cimg 56 fftw 57 graphicsmagick 58 libjpeg 59 libpng 60 libtiff 61 opencv 62 openexr 63 zlib 64 ]; 65 66 cmakeFlags = [ 67 "-DBUILD_LIB_STATIC=OFF" 68 "-DENABLE_CURL=OFF" 69 "-DENABLE_DYNAMIC_LINKING=ON" 70 "-DUSE_SYSTEM_CIMG=ON" 71 ]; 72 73 postPatch = '' 74 cp -r ${finalAttrs.gmic_stdlib} src/gmic_stdlib.h 75 76 # CMake build files were moved to subdirectory. 77 mv resources/CMakeLists.txt resources/cmake . 78 '' 79 + lib.optionalString stdenv.isDarwin '' 80 substituteInPlace CMakeLists.txt \ 81 --replace "LD_LIBRARY_PATH" "DYLD_LIBRARY_PATH" 82 ''; 83 84 passthru = { 85 tests = { 86 # Needs to update them all in lockstep. 87 inherit cimg gmic-qt; 88 }; 89 90 updateScript = writeShellScript "gmic-update-script" '' 91 set -o errexit 92 PATH=${lib.makeBinPath [ common-updater-scripts coreutils curl gnugrep gnused jq ]} 93 94 latestVersion=$(curl 'https://gmic.eu/files/source/' \ 95 | grep -E 'gmic_[^"]+\.tar\.gz' \ 96 | sed -E 's/.+<a href="gmic_([^"]+)\.tar\.gz".+/\1/g' \ 97 | sort --numeric-sort --reverse | head -n1) 98 99 if [[ "${finalAttrs.version}" = "$latestVersion" ]]; then 100 echo "The new version same as the old version." 101 exit 0 102 fi 103 104 for component in src gmic_stdlib; do 105 # The script will not perform an update when the version attribute is 106 # up to date from previous platform run; we need to clear it before 107 # each run 108 update-source-version "--source-key=$component" "gmic" 0 "${lib.fakeHash}" 109 update-source-version "--source-key=$component" "gmic" $latestVersion 110 done 111 ''; 112 }; 113 114 meta = { 115 homepage = "https://gmic.eu/"; 116 description = "Open and full-featured framework for image processing"; 117 license = lib.licenses.cecill21; 118 maintainers = [ lib.maintainers.lilyinstarlight ]; 119 platforms = lib.platforms.unix; 120 }; 121})