1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 meson,
6 ninja,
7 gdk-pixbuf,
8 gd,
9 pkg-config,
10
11 # Enable linking against image loading libraries as part of the
12 # implementation of the sixel_helper_{load,write}_image_file() functions.
13 # These helper functions are not needed for the main functionality of the
14 # library to encode image buffers to sixels.
15 #
16 # libsixel already uses vendored stb image loading to provide basic
17 # implementations, but also allows for the "gd" library to be linked for
18 # a wider set of image formats.
19 # This pulls in a large amount of deps bloating the resulting library.
20 #
21 # Default off, but configurable in case you really need it.
22 withGd ? false,
23}:
24
25stdenv.mkDerivation (finalAttrs: {
26 pname = "libsixel";
27 version = "1.10.5";
28
29 src = fetchFromGitHub {
30 owner = "libsixel";
31 repo = "libsixel";
32 rev = "v${finalAttrs.version}";
33 hash = "sha256-obzBZAknN3N7+Bvtd0+JHuXcemVb7wRv+Pt4VjS6Bck=";
34 };
35
36 buildInputs = lib.optionals withGd [
37 gdk-pixbuf
38 gd
39 ];
40
41 nativeBuildInputs = [
42 meson
43 ninja
44 pkg-config
45 ];
46
47 doCheck = true;
48
49 mesonFlags = [
50 "-Dtests=enabled"
51 "-Dimg2sixel=enabled"
52 "-Dsixel2png=enabled"
53
54 (lib.mesonEnable "gd" withGd)
55
56 # build system seems to be broken here; error message indicates pkconfig
57 # issue.
58 # Not to worry: jpeg and png are handled by the built-in stb and/or gd lib.
59 "-Djpeg=disabled"
60 "-Dpng=disabled"
61 ];
62
63 meta = with lib; {
64 description = "SIXEL library for console graphics, and converter programs";
65 homepage = "https://github.com/libsixel/libsixel";
66 maintainers = with lib.maintainers; [ hzeller ];
67 license = licenses.mit;
68 platforms = platforms.unix;
69 };
70})