nixpkgs/pkgs/applications/graphics/ImageMagick/7.0.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

139 lines
3.6 KiB
Nix
Raw Normal View History

2022-02-25 20:09:42 +00:00
{ lib
, stdenv
, fetchFromGitHub
, pkg-config
, libtool
, bzip2
, zlib
, libX11
, libXext
, libXt
, fontconfig
, freetype
, ghostscript
, libjpeg
, djvulibre
, lcms2
, openexr
, libjxl
, libpng
, liblqr1
, libraw
, librsvg
, libtiff
, libxml2
, openjpeg
, libwebp
, libheif
, potrace
, curl
, ApplicationServices
2021-04-28 07:53:27 +00:00
, Foundation
2022-02-25 20:09:42 +00:00
, testVersion
, imagemagick
2016-12-28 13:15:53 +00:00
}:
let
arch =
if stdenv.hostPlatform.system == "i686-linux" then "i686"
else if stdenv.hostPlatform.system == "x86_64-linux" || stdenv.hostPlatform.system == "x86_64-darwin" then "x86-64"
else if stdenv.hostPlatform.system == "armv7l-linux" then "armv7l"
2022-02-25 20:09:42 +00:00
else if stdenv.hostPlatform.system == "aarch64-linux" || stdenv.hostPlatform.system == "aarch64-darwin" then "aarch64"
2020-10-03 01:46:18 +00:00
else if stdenv.hostPlatform.system == "powerpc64le-linux" then "ppc64le"
else null;
2016-12-28 13:15:53 +00:00
in
stdenv.mkDerivation rec {
pname = "imagemagick";
2022-02-21 18:57:19 +00:00
version = "7.1.0-26";
2016-12-28 13:15:53 +00:00
src = fetchFromGitHub {
owner = "ImageMagick";
repo = "ImageMagick";
rev = version;
2022-02-21 18:57:19 +00:00
hash = "sha256-q1CL64cfyb5fN9aVYJfls+v0XRFd4jH+B8n+UJqPE1I=";
2016-12-28 13:15:53 +00:00
};
outputs = [ "out" "dev" "doc" ]; # bin/ isn't really big
outputMan = "out"; # it's tiny
enableParallelBuilding = true;
configureFlags =
[ "--with-frozenpaths" ]
++ (if arch != null then [ "--with-gcc-arch=${arch}" ] else [ "--without-gcc-arch" ])
2016-12-28 13:15:53 +00:00
++ lib.optional (librsvg != null) "--with-rsvg"
++ lib.optional (liblqr1 != null) "--with-lqr"
# libjxl is broken on aarch64 (see meta.broken in libjxl) for now,
# let's disable it for now to unbreak the imagemagick build.
++ lib.optional (libjxl != null && !stdenv.isAarch64) "--with-jxl"
2016-12-28 13:15:53 +00:00
++ lib.optionals (ghostscript != null)
2022-02-25 20:09:42 +00:00
[
"--with-gs-font-dir=${ghostscript}/share/ghostscript/fonts"
2016-12-28 13:15:53 +00:00
"--with-gslib"
]
++ lib.optionals stdenv.hostPlatform.isMinGW
2016-12-28 13:15:53 +00:00
[ "--enable-static" "--disable-shared" ] # due to libxml2 being without DLLs ATM
2022-02-25 20:09:42 +00:00
;
2016-12-28 13:15:53 +00:00
nativeBuildInputs = [ pkg-config libtool ];
2016-12-28 13:15:53 +00:00
buildInputs =
2022-02-25 20:09:42 +00:00
[
zlib
fontconfig
freetype
ghostscript
potrace
liblqr1
libpng
libraw
libtiff
libxml2
libheif
djvulibre
2016-12-28 13:15:53 +00:00
]
# libjxl is broken on aarch64 (see meta.broken in libjxl) for now,
# let's disable it for now to unbreak the imagemagick build.
++ lib.optionals (!stdenv.isAarch64)
[ libjxl ]
++ lib.optionals (!stdenv.hostPlatform.isMinGW)
2016-12-28 13:15:53 +00:00
[ openexr librsvg openjpeg ]
2021-04-28 07:53:27 +00:00
++ lib.optionals stdenv.isDarwin [
ApplicationServices
Foundation
];
2016-12-28 13:15:53 +00:00
propagatedBuildInputs =
2022-02-25 20:09:42 +00:00
[ bzip2 freetype libjpeg lcms2 curl ]
++ lib.optionals (!stdenv.hostPlatform.isMinGW)
2016-12-28 13:15:53 +00:00
[ libX11 libXext libXt libwebp ]
2022-02-25 20:09:42 +00:00
;
2016-12-28 13:15:53 +00:00
postInstall = ''
(cd "$dev/include" && ln -s ImageMagick* ImageMagick)
moveToOutput "bin/*-config" "$dev"
moveToOutput "lib/ImageMagick-*/config-Q16HDRI" "$dev" # includes configure params
for file in "$dev"/bin/*-config; do
substituteInPlace "$file" --replace pkg-config \
"PKG_CONFIG_PATH='$dev/lib/pkgconfig' '${pkg-config}/bin/${pkg-config.targetPrefix}pkg-config'"
2016-12-28 13:15:53 +00:00
done
'' + lib.optionalString (ghostscript != null) ''
for la in $out/lib/*.la; do
sed 's|-lgs|-L${lib.getLib ghostscript}/lib -lgs|' -i $la
done
'';
passthru.tests.version =
testVersion { package = imagemagick; };
meta = with lib; {
homepage = "http://www.imagemagick.org/";
2016-12-28 13:15:53 +00:00
description = "A software suite to create, edit, compose, or convert bitmap images";
platforms = platforms.linux ++ platforms.darwin;
2021-06-26 09:32:57 +00:00
maintainers = with maintainers; [ erictapen dotlambda ];
2018-08-22 21:51:23 +00:00
license = licenses.asl20;
2021-04-27 17:44:47 +00:00
mainProgram = "magick";
2016-12-28 13:15:53 +00:00
};
}