depot/third_party/nixpkgs/pkgs/tools/graphics/optipng/default.nix
Default email bcb2f287e1 Project import generated by Copybara.
GitOrigin-RevId: d603719ec6e294f034936c0d0dc06f689d91b6c3
2024-06-20 20:27:18 +05:30

47 lines
1.2 KiB
Nix

{ lib, stdenv, fetchurl, libpng
, static ? stdenv.hostPlatform.isStatic
}:
# This package comes with its own copy of zlib, libpng and pngxtern
stdenv.mkDerivation rec {
pname = "optipng";
version = "0.7.8";
src = fetchurl {
url = "mirror://sourceforge/optipng/optipng-${version}.tar.gz";
hash = "sha256-JaO9aEgfIVAsyqD0wT+E3PayAzjkxOjFHyzvvYUTOYw=";
};
buildInputs = [ libpng ];
# Workaround for crash in cexcept.h. See
# https://github.com/NixOS/nixpkgs/issues/28106
preConfigure = ''
export LD=$CC
'';
# OptiPNG does not like --static, --build or --host
dontDisableStatic = true;
dontAddStaticConfigureFlags = true;
configurePlatforms = [ ];
configureFlags = [
"--with-system-zlib"
"--with-system-libpng"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
#"-prefix=$out"
];
postInstall = if stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform.isWindows then ''
mv "$out"/bin/optipng{,.exe}
'' else null;
meta = with lib; {
homepage = "https://optipng.sourceforge.net/";
description = "PNG optimizer";
license = licenses.zlib;
platforms = platforms.unix;
mainProgram = "optipng";
};
}