at master 68 lines 1.6 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 rust, 6 rustPlatform, 7 cargo-c, 8 python3, 9 10 # tests 11 testers, 12 vips, 13 libimagequant, 14}: 15 16rustPlatform.buildRustPackage rec { 17 pname = "libimagequant"; 18 version = "4.3.4"; 19 20 src = fetchFromGitHub { 21 owner = "ImageOptim"; 22 repo = "libimagequant"; 23 rev = version; 24 hash = "sha256-2P8FiRfOuCHxJrB+rnDDOFsrFjPv5GMBK/5sq7eb32w="; 25 }; 26 27 cargoLock = { 28 # created it by running `cargo update` in the source tree. 29 lockFile = ./Cargo.lock; 30 }; 31 32 postPatch = '' 33 ln -s ${./Cargo.lock} Cargo.lock 34 ''; 35 36 nativeBuildInputs = [ cargo-c ]; 37 38 postBuild = '' 39 pushd imagequant-sys 40 ${rust.envVars.setEnv} cargo cbuild --release --frozen --prefix=${placeholder "out"} --target ${stdenv.hostPlatform.rust.rustcTarget} 41 popd 42 ''; 43 44 postInstall = '' 45 pushd imagequant-sys 46 ${rust.envVars.setEnv} cargo cinstall --release --frozen --prefix=${placeholder "out"} --target ${stdenv.hostPlatform.rust.rustcTarget} 47 popd 48 ''; 49 50 passthru.tests = { 51 inherit vips; 52 inherit (python3.pkgs) pillow; 53 54 pkg-config = testers.hasPkgConfigModules { 55 package = libimagequant; 56 moduleNames = [ "imagequant" ]; 57 }; 58 }; 59 60 meta = with lib; { 61 homepage = "https://pngquant.org/lib/"; 62 description = "Image quantization library"; 63 longDescription = "Small, portable C library for high-quality conversion of RGBA images to 8-bit indexed-color (palette) images."; 64 license = licenses.gpl3Plus; 65 platforms = platforms.unix; 66 maintainers = with maintainers; [ ma9e ]; 67 }; 68}