2023-01-22 04:20:00 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchurl, rust, rustPlatform, cargo-c, python3 }:
|
2018-09-28 21:18:49 +00:00
|
|
|
|
2023-01-22 04:20:00 +00:00
|
|
|
let
|
|
|
|
rustTargetPlatformSpec = rust.toRustTargetSpec stdenv.hostPlatform;
|
|
|
|
in
|
|
|
|
rustPlatform.buildRustPackage rec {
|
2019-06-01 03:13:43 +00:00
|
|
|
pname = "libimagequant";
|
2023-03-10 04:20:00 +00:00
|
|
|
version = "4.1.1";
|
2018-09-28 21:18:49 +00:00
|
|
|
|
2019-06-01 03:13:43 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ImageOptim";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2023-03-10 04:20:00 +00:00
|
|
|
hash = "sha256-sCxscs4D2p7LNDpcrKfAc315/NbxbQXtsyc33zUmccM=";
|
2019-06-01 03:13:43 +00:00
|
|
|
};
|
2018-09-28 21:18:49 +00:00
|
|
|
|
2023-01-22 04:20:00 +00:00
|
|
|
cargoLock = {
|
|
|
|
lockFile = ./Cargo.lock;
|
|
|
|
};
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
cp ${./Cargo.lock} Cargo.lock
|
|
|
|
'';
|
|
|
|
|
|
|
|
cargoHash = "sha256-0HOmItooNsGq6iTIb9M5IPXMwYh2nQ03qfjomkg0d00=";
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cargo-c ];
|
|
|
|
|
|
|
|
postBuild = ''
|
|
|
|
pushd imagequant-sys
|
|
|
|
cargo cbuild --release --frozen --prefix=${placeholder "out"} --target ${rustTargetPlatformSpec}
|
|
|
|
popd
|
2019-06-01 03:13:43 +00:00
|
|
|
'';
|
2018-09-28 21:18:49 +00:00
|
|
|
|
2023-01-22 04:20:00 +00:00
|
|
|
postInstall = ''
|
|
|
|
pushd imagequant-sys
|
|
|
|
cargo cinstall --release --frozen --prefix=${placeholder "out"} --target ${rustTargetPlatformSpec}
|
|
|
|
popd
|
|
|
|
'';
|
2021-03-05 02:31:13 +00:00
|
|
|
|
2023-01-22 04:20:00 +00:00
|
|
|
passthru.tests = {
|
|
|
|
inherit (python3.pkgs) pillow;
|
|
|
|
};
|
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
meta = with lib; {
|
2019-06-01 03:13:43 +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 ];
|
|
|
|
};
|
|
|
|
}
|