nixpkgs/pkgs/by-name/op/optipng/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

48 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";
};
}