From a974e43a90865245b2cd9a544299d8d7565f74a1 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Fri, 10 Jan 2025 08:22:25 -0800 Subject: [PATCH] libsixel: make linking against gd a choosable option. --- pkgs/by-name/li/libsixel/package.nix | 32 ++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/pkgs/by-name/li/libsixel/package.nix b/pkgs/by-name/li/libsixel/package.nix index 186920ccf282..76d028ced1e5 100644 --- a/pkgs/by-name/li/libsixel/package.nix +++ b/pkgs/by-name/li/libsixel/package.nix @@ -7,19 +7,33 @@ gdk-pixbuf, gd, pkg-config, + + # Enable linking against image loading libraries as part of the + # implementation of the sixel_helper_{load,write}_image_file() functions. + # These helper functions are not needed for the main functionality of the + # library to encode image buffers to sixels. + # + # libsixel already uses vendored stb image loading to provide basic + # implementations, but also allows for the "gd" library to be linked for + # a wider set of image formats. + # This pulls in a large amount of deps bloating the resulting library. + # + # Default off, but configurable in case you really need it. + withGd ? false, }: -stdenv.mkDerivation rec { + +stdenv.mkDerivation (finalAttrs: { pname = "libsixel"; version = "1.10.5"; src = fetchFromGitHub { owner = "libsixel"; repo = "libsixel"; - rev = "v${version}"; + rev = "v${finalAttrs.version}"; hash = "sha256-obzBZAknN3N7+Bvtd0+JHuXcemVb7wRv+Pt4VjS6Bck="; }; - buildInputs = [ + buildInputs = lib.optionals withGd [ gdk-pixbuf gd ]; @@ -34,8 +48,14 @@ stdenv.mkDerivation rec { mesonFlags = [ "-Dtests=enabled" - # build system seems to be broken here, it still seems to handle jpeg - # through some other ways. + "-Dimg2sixel=enabled" + "-Dsixel2png=enabled" + + (lib.mesonEnable "gd" withGd) + + # build system seems to be broken here; error message indicates pkconfig + # issue. + # Not to worry: jpeg and png are handled by the built-in stb and/or gd lib. "-Djpeg=disabled" "-Dpng=disabled" ]; @@ -47,4 +67,4 @@ stdenv.mkDerivation rec { license = licenses.mit; platforms = platforms.unix; }; -} +})