Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 214 lines 5.9 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 pkg-config, 6 libtool, 7 bzip2Support ? true, 8 bzip2, 9 zlibSupport ? true, 10 zlib, 11 libX11Support ? !stdenv.hostPlatform.isMinGW, 12 libX11, 13 libXtSupport ? !stdenv.hostPlatform.isMinGW, 14 libXt, 15 fontconfigSupport ? true, 16 fontconfig, 17 freetypeSupport ? true, 18 freetype, 19 ghostscriptSupport ? false, 20 ghostscript, 21 libjpegSupport ? true, 22 libjpeg, 23 djvulibreSupport ? true, 24 djvulibre, 25 lcms2Support ? true, 26 lcms2, 27 openexrSupport ? !stdenv.hostPlatform.isMinGW, 28 openexr, 29 libjxlSupport ? true, 30 libjxl, 31 libpngSupport ? true, 32 libpng, 33 liblqr1Support ? true, 34 liblqr1, 35 libraqmSupport ? true, 36 libraqm, 37 librawSupport ? true, 38 libraw, 39 librsvgSupport ? !stdenv.hostPlatform.isMinGW, 40 librsvg, 41 pango, 42 libtiffSupport ? true, 43 libtiff, 44 libxml2Support ? true, 45 libxml2, 46 openjpegSupport ? !stdenv.hostPlatform.isMinGW, 47 openjpeg, 48 libwebpSupport ? !stdenv.hostPlatform.isMinGW, 49 libwebp, 50 libheifSupport ? true, 51 libheif, 52 fftwSupport ? true, 53 fftw, 54 potrace, 55 coreutils, 56 curl, 57 testers, 58 nixos-icons, 59 perlPackages, 60 python3, 61}: 62 63assert libXtSupport -> libX11Support; 64assert libraqmSupport -> freetypeSupport; 65 66let 67 arch = 68 if stdenv.hostPlatform.system == "i686-linux" then 69 "i686" 70 else if 71 stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "x86_64-darwin" 72 then 73 "x86-64" 74 else if stdenv.hostPlatform.system == "armv7l-linux" then 75 "armv7l" 76 else if 77 stdenv.hostPlatform.system == "aarch64-linux" || stdenv.hostPlatform.system == "aarch64-darwin" 78 then 79 "aarch64" 80 else if stdenv.hostPlatform.system == "powerpc64le-linux" then 81 "ppc64le" 82 else 83 null; 84in 85 86stdenv.mkDerivation (finalAttrs: { 87 pname = "imagemagick"; 88 version = "7.1.2-0"; 89 90 src = fetchFromGitHub { 91 owner = "ImageMagick"; 92 repo = "ImageMagick"; 93 tag = finalAttrs.version; 94 hash = "sha256-4x0+yELmXstv9hPuwzMGcKiTa1rZtURZgwSSVIhzAkE="; 95 }; 96 97 outputs = [ 98 "out" 99 "dev" 100 "doc" 101 ]; # bin/ isn't really big 102 outputMan = "out"; # it's tiny 103 104 enableParallelBuilding = true; 105 106 configureFlags = [ 107 # specify delegates explicitly otherwise `convert` will invoke the build 108 # coreutils for filetypes it doesn't natively support. 109 "MVDelegate=${lib.getExe' coreutils "mv"}" 110 "RMDelegate=${lib.getExe' coreutils "rm"}" 111 "--with-frozenpaths" 112 (lib.withFeatureAs (arch != null) "gcc-arch" arch) 113 (lib.withFeature librsvgSupport "rsvg") 114 (lib.withFeature librsvgSupport "pango") 115 (lib.withFeature liblqr1Support "lqr") 116 (lib.withFeature libjxlSupport "jxl") 117 (lib.withFeatureAs ghostscriptSupport "gs-font-dir" "${ghostscript.fonts}/share/fonts") 118 (lib.withFeature ghostscriptSupport "gslib") 119 (lib.withFeature fftwSupport "fftw") 120 ] 121 ++ lib.optionals stdenv.hostPlatform.isMinGW [ 122 # due to libxml2 being without DLLs ATM 123 "--enable-static" 124 "--disable-shared" 125 ]; 126 127 nativeBuildInputs = [ 128 pkg-config 129 libtool 130 ]; 131 132 buildInputs = [ 133 potrace 134 ] 135 ++ lib.optional zlibSupport zlib 136 ++ lib.optional fontconfigSupport fontconfig 137 ++ lib.optional ghostscriptSupport ghostscript 138 ++ lib.optional liblqr1Support liblqr1 139 ++ lib.optional libpngSupport libpng 140 ++ lib.optional libraqmSupport libraqm 141 ++ lib.optional librawSupport libraw 142 ++ lib.optional libtiffSupport libtiff 143 ++ lib.optional libxml2Support libxml2 144 ++ lib.optional libheifSupport libheif 145 ++ lib.optional djvulibreSupport djvulibre 146 ++ lib.optional libjxlSupport libjxl 147 ++ lib.optional openexrSupport openexr 148 ++ lib.optionals librsvgSupport [ 149 librsvg 150 pango 151 ] 152 ++ lib.optional openjpegSupport openjpeg; 153 154 propagatedBuildInputs = [ 155 curl 156 ] 157 ++ lib.optional bzip2Support bzip2 158 ++ lib.optional freetypeSupport freetype 159 ++ lib.optional libjpegSupport libjpeg 160 ++ lib.optional lcms2Support lcms2 161 ++ lib.optional libX11Support libX11 162 ++ lib.optional libXtSupport libXt 163 ++ lib.optional libwebpSupport libwebp 164 ++ lib.optional fftwSupport fftw; 165 166 postInstall = '' 167 (cd "$dev/include" && ln -s ImageMagick* ImageMagick) 168 # Q16HDRI = 16 bit quantum depth with HDRI support, and is the default ImageMagick configuration 169 # If the default is changed, or the derivation is modified to use a different configuration 170 # this will need to be changed below. 171 moveToOutput "bin/*-config" "$dev" 172 moveToOutput "lib/ImageMagick-*/config-Q16HDRI" "$dev" # includes configure params 173 configDestination=($out/share/ImageMagick-*) 174 grep -v '/nix/store' $dev/lib/ImageMagick-*/config-Q16HDRI/configure.xml > $configDestination/configure.xml 175 for file in "$dev"/bin/*-config; do 176 substituteInPlace "$file" --replace pkg-config \ 177 "PKG_CONFIG_PATH='$dev/lib/pkgconfig' '$(command -v $PKG_CONFIG)'" 178 done 179 '' 180 + lib.optionalString ghostscriptSupport '' 181 for la in $out/lib/*.la; do 182 sed 's|-lgs|-L${lib.getLib ghostscript}/lib -lgs|' -i $la 183 done 184 ''; 185 186 passthru.tests = { 187 version = testers.testVersion { package = finalAttrs.finalPackage; }; 188 inherit nixos-icons; 189 inherit (perlPackages) ImageMagick; 190 inherit (python3.pkgs) img2pdf willow; 191 pkg-config = testers.hasPkgConfigModules { 192 package = finalAttrs.finalPackage; 193 version = lib.head (lib.splitString "-" finalAttrs.version); 194 }; 195 }; 196 197 meta = with lib; { 198 homepage = "http://www.imagemagick.org/"; 199 changelog = "https://github.com/ImageMagick/Website/blob/main/ChangeLog.md"; 200 description = "Software suite to create, edit, compose, or convert bitmap images"; 201 pkgConfigModules = [ 202 "ImageMagick" 203 "MagickWand" 204 ]; 205 platforms = platforms.unix; 206 maintainers = with maintainers; [ 207 dotlambda 208 rhendric 209 faukah 210 ]; 211 license = licenses.asl20; 212 mainProgram = "magick"; 213 }; 214})