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
|
|
|
rustPlatform.buildRustPackage rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "libimagequant";
|
2023-11-16 04:20:00 +00:00
|
|
|
version = "4.2.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ImageOptim";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2023-11-16 04:20:00 +00:00
|
|
|
hash = "sha256-cZgnJOmj+xJDcewsxH2Jp5AAnFZKVuYxKPtoGeN03g4=";
|
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
|
2023-11-16 04:20:00 +00:00
|
|
|
${rust.envVars.setEnv} cargo cbuild --release --frozen --prefix=${placeholder "out"} --target ${stdenv.hostPlatform.rust.rustcTarget}
|
2023-03-04 12:14:45 +00:00
|
|
|
popd
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
postInstall = ''
|
|
|
|
pushd imagequant-sys
|
2023-11-16 04:20:00 +00:00
|
|
|
${rust.envVars.setEnv} cargo cinstall --release --frozen --prefix=${placeholder "out"} --target ${stdenv.hostPlatform.rust.rustcTarget}
|
2023-03-04 12:14:45 +00:00
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|