2023-03-04 12:14:45 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchurl, rust, rustPlatform, cargo-c, python3 }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
let
|
|
|
|
rustTargetPlatformSpec = rust.toRustTargetSpec stdenv.hostPlatform;
|
|
|
|
in
|
|
|
|
rustPlatform.buildRustPackage rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "libimagequant";
|
2023-05-24 13:37:59 +00:00
|
|
|
version = "4.2.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ImageOptim";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2023-05-24 13:37:59 +00:00
|
|
|
hash = "sha256-51xTCymZKLuw1Xeje6EyKqHdbmqBV1Fdhx+OsO3bZ6Q=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
cargoLock = {
|
|
|
|
lockFile = ./Cargo.lock;
|
|
|
|
};
|
|
|
|
|
|
|
|
postPatch = ''
|
2023-05-24 13:37:59 +00:00
|
|
|
ln -s ${./Cargo.lock} Cargo.lock
|
2023-03-04 12:14:45 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cargo-c ];
|
|
|
|
|
|
|
|
postBuild = ''
|
|
|
|
pushd imagequant-sys
|
|
|
|
cargo cbuild --release --frozen --prefix=${placeholder "out"} --target ${rustTargetPlatformSpec}
|
|
|
|
popd
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
postInstall = ''
|
|
|
|
pushd imagequant-sys
|
|
|
|
cargo cinstall --release --frozen --prefix=${placeholder "out"} --target ${rustTargetPlatformSpec}
|
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru.tests = {
|
|
|
|
inherit (python3.pkgs) pillow;
|
|
|
|
};
|
2021-03-09 03:18:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://pngquant.org/lib/";
|
|
|
|
description = "Image quantization library";
|
|
|
|
longDescription = "Small, portable C library for high-quality conversion of RGBA images to 8-bit indexed-color (palette) images.";
|
|
|
|
license = licenses.gpl3Plus;
|
|
|
|
platforms = platforms.unix;
|
|
|
|
maintainers = with maintainers; [ ma9e marsam ];
|
|
|
|
};
|
|
|
|
}
|