Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, fetchFromGitHub, fetchurl, rust, rustPlatform, cargo-c, python3 }: 2 3let 4 rustTargetPlatformSpec = rust.toRustTargetSpec stdenv.hostPlatform; 5in 6rustPlatform.buildRustPackage rec { 7 pname = "libimagequant"; 8 version = "4.2.0"; 9 10 src = fetchFromGitHub { 11 owner = "ImageOptim"; 12 repo = pname; 13 rev = version; 14 hash = "sha256-51xTCymZKLuw1Xeje6EyKqHdbmqBV1Fdhx+OsO3bZ6Q="; 15 }; 16 17 cargoLock = { 18 lockFile = ./Cargo.lock; 19 }; 20 21 postPatch = '' 22 ln -s ${./Cargo.lock} Cargo.lock 23 ''; 24 25 nativeBuildInputs = [ cargo-c ]; 26 27 postBuild = '' 28 pushd imagequant-sys 29 cargo cbuild --release --frozen --prefix=${placeholder "out"} --target ${rustTargetPlatformSpec} 30 popd 31 ''; 32 33 postInstall = '' 34 pushd imagequant-sys 35 cargo cinstall --release --frozen --prefix=${placeholder "out"} --target ${rustTargetPlatformSpec} 36 popd 37 ''; 38 39 passthru.tests = { 40 inherit (python3.pkgs) pillow; 41 }; 42 43 meta = with lib; { 44 homepage = "https://pngquant.org/lib/"; 45 description = "Image quantization library"; 46 longDescription = "Small, portable C library for high-quality conversion of RGBA images to 8-bit indexed-color (palette) images."; 47 license = licenses.gpl3Plus; 48 platforms = platforms.unix; 49 maintainers = with maintainers; [ ma9e marsam ]; 50 }; 51}