1{
2 lib,
3 fetchFromGitHub,
4 stdenv,
5 zlib,
6 ninja,
7 meson,
8 pkg-config,
9 cmake,
10 libpng,
11}:
12
13stdenv.mkDerivation rec {
14 pname = "libspng";
15 version = "0.7.4";
16
17 src = fetchFromGitHub {
18 owner = "randy408";
19 repo = "libspng";
20 rev = "v${version}";
21 sha256 = "sha256-BiRuPQEKVJYYgfUsglIuxrBoJBFiQ0ygQmAFrVvCz4Q=";
22 };
23
24 # disable two tests broken after libpng update
25 # https://github.com/randy408/libspng/issues/276
26 postPatch = ''
27 cat tests/images/meson.build | grep -v "'ch1n3p04'" | grep -v "'ch2n3p08'" > tests/images/meson.build-patched
28 mv tests/images/meson.build-patched tests/images/meson.build
29 '';
30
31 doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
32
33 mesonBuildType = "release";
34
35 mesonFlags = [
36 # this is required to enable testing
37 # https://github.com/randy408/libspng/blob/bc383951e9a6e04dbc0766f6737e873e0eedb40b/tests/README.md#testing
38 "-Ddev_build=true"
39 ];
40
41 outputs = [
42 "out"
43 "dev"
44 ];
45
46 strictDeps = true;
47
48 nativeCheckInputs = [
49 cmake
50 ];
51
52 buildInputs = [
53 zlib
54 libpng
55 ];
56
57 nativeBuildInputs = [
58 ninja
59 meson
60 pkg-config
61 ];
62
63 meta = with lib; {
64 description = "Simple, modern libpng alternative";
65 homepage = "https://libspng.org/";
66 license = with licenses; [ bsd2 ];
67 maintainers = with maintainers; [ humancalico ];
68 platforms = platforms.all;
69 };
70}