On Wed, Mar 05, 2025 at 01:51:19AM -0800, Jordan Justen wrote:
>...
> Given the uncertain timeline for libgit2 1.9 in unstable/testing, I
> guess I better try to address this in 2.24. Thanks for the ideas.

The attached patches fix the build in unstable for me.

> -Jordan

cu
Adrian
From 2ee91551b4f2144ceab70884376adfb21b2ae0b4 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <sly...@gmail.com>
Date: Sun, 29 Dec 2024 15:54:53 +0000
Subject: libcmd: update to support lowdown-1.4 API

Upstream change
https://github.com/kristapsdz/lowdown/commit/bab1d75079ac3866fc14e1fa4825ae64a94a7c0e
moved a few fields from `lowdown_opts` toa  new `lowdown_opts_term`
struct. As a result the build started failing as:

    nix-cmd> [2/17] Compiling C++ object libnixcmd.so.p/markdown.cc.o
    nix-cmd> FAILED: libnixcmd.so.p/markdown.cc.o
    nix-cmd> g++ -Ilibnixcmd.so.p -I. -I.. -I/nix/store/b0bnrk5lacxbpgxgnc28r8q3wcazrgxj-nix-util-2.26.0pre-dev/include/nix -I/nix/store/cxnynq9ykyj4xxv6wf6dw7r0aw5x6n9k-libarchive-3.7.7-dev/include -I/nix/store/bfgjwkcb8snkizx578rzdahi75m8zyh4-nlohmann_json-3.11.3/include -I/nix/store/3sx8bq3sip6j2nv1m5xx4gbdp33v7iy6-nix-store-2.26.0pre-dev/include/nix -I/nix/store/sih2dgqzvsbv7p510lkfmas7s7wbsl4j-nix-fetchers-2.26.0pre-dev/include/nix -I/nix/store/68p8s20fsiiakj7nys7grbaixfnhsdzs-nix-expr-2.26.0pre-dev/include/nix -I/nix/store/gw7wknhzhfzzj9zww2kyi5xrzgf1ndki-boehm-gc-8.2.8-dev/include -I/nix/store/3jwb9j4vnsk5saq3wfyyp9il3mhs41l9-nix-flake-2.26.0pre-dev/include/nix -I/nix/store/8nwjvmq7m48v8g646jrxkikv6x47bc3m-nix-main-2.26.0pre-dev/include/nix -I/nix/store/rb0hzsw5wc1a7daizhpj824mbxlvijrq-lowdown-1.4.0-dev/include -I/nix/store/m388ywpk53fsp8r98brfd7nf1f5sskv0-editline-1.17.1-dev/include -fdiagnostics-color=always -D_GLIBCXX_ASSERTIONS=1 -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++2a -include config-util.hh -include config-store.hh -include config-expr.hh -include config-main.hh -include config-cmd.hh -Wdeprecated-copy -Werror=suggest-override -Werror=switch -Werror=switch-enum -Werror=unused-result -Wignored-qualifiers -Wimplicit-fallthrough -Wno-deprecated-declarations -O3 -fPIC -pthread -std=c++2a -std=c++2a -std=c++2a -std=c++2a -std=c++2a -std=c++2a -MD -MQ libnixcmd.so.p/markdown.cc.o -MF libnixcmd.so.p/markdown.cc.o.d -o libnixcmd.so.p/markdown.cc.o -c ../markdown.cc
    nix-cmd> ../markdown.cc: In function 'std::string nix::doRenderMarkdownToTerminal(std::string_view)':
    nix-cmd> ../markdown.cc:28:5: error: 'lowdown_opts' has no non-static data member named 'cols'
    nix-cmd>    28 |     };
    nix-cmd>       |     ^

The change adds version-based conditional to support both pre-1.4 and
1.4 forms of the initialization.

Closes: https://github.com/NixOS/nix/issues/12113
(cherry picked from commit edbfe863ce4ae4b89e554f29807e62674055f251)
---
 src/libcmd/markdown.cc | 12 ++++++++++++
 src/libcmd/meson.build |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/src/libcmd/markdown.cc b/src/libcmd/markdown.cc
index 6a0d05d9f..4566e6ba6 100644
--- a/src/libcmd/markdown.cc
+++ b/src/libcmd/markdown.cc
@@ -16,13 +16,25 @@ static std::string doRenderMarkdownToTerminal(std::string_view markdown)
 {
     int windowWidth = getWindowSize().second;
 
+#if HAVE_LOWDOWN_1_4
+    struct lowdown_opts_term opts_term {
+        .cols = (size_t) std::max(windowWidth - 5, 60),
+        .hmargin = 0,
+        .vmargin = 0,
+    };
+#endif
     struct lowdown_opts opts
     {
         .type = LOWDOWN_TERM,
+#if HAVE_LOWDOWN_1_4
+        .term = opts_term,
+#endif
         .maxdepth = 20,
+#if !HAVE_LOWDOWN_1_4
         .cols = (size_t) std::max(windowWidth - 5, 60),
         .hmargin = 0,
         .vmargin = 0,
+#endif
         .feat = LOWDOWN_COMMONMARK | LOWDOWN_FENCED | LOWDOWN_DEFLIST | LOWDOWN_TABLES,
         .oflags = LOWDOWN_TERM_NOLINK,
     };
diff --git a/src/libcmd/meson.build b/src/libcmd/meson.build
index c484cf998..f1a5a56c8 100644
--- a/src/libcmd/meson.build
+++ b/src/libcmd/meson.build
@@ -38,6 +38,8 @@ deps_public += nlohmann_json
 lowdown = dependency('lowdown', version : '>= 0.9.0', required : get_option('markdown'))
 deps_private += lowdown
 configdata.set('HAVE_LOWDOWN', lowdown.found().to_int())
+# The API changed slightly around terminal initialization.
+configdata.set('HAVE_LOWDOWN_1_4', lowdown.version().version_compare('>= 1.4.0').to_int())
 
 readline_flavor = get_option('readline-flavor')
 if readline_flavor == 'editline'
-- 
2.30.2

>From 0a36cf51fa2ff0cb95fb6b2d733d5ecf0b5fef6f Mon Sep 17 00:00:00 2001
From: Adrian Bunk <b...@debian.org>
Date: Wed, 5 Mar 2025 19:08:49 +0200
Subject: Define HAVE_LOWDOWN_1_4 for lowdown >= 1.4 also with autoconf

---
 configure.ac | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configure.ac b/configure.ac
index c2b643c27..a38fa8c4d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -402,6 +402,8 @@ AS_CASE(["$enable_markdown"],
       CXXFLAGS="$LOWDOWN_CFLAGS $CXXFLAGS"
       have_lowdown=1
       AC_DEFINE(HAVE_LOWDOWN, 1, [Whether lowdown is available and should be used for Markdown rendering.])
+      PKG_CHECK_MODULES([LOWDOWN_1_4], [lowdown >= 1.4],[
+        AC_DEFINE(HAVE_LOWDOWN_1_4, 1, [Whether lowdown >= 1.4 is available.])])
     ], [
       AS_IF([test "x$enable_markdown" == "xyes"], [AC_MSG_ERROR([--enable-markdown was specified, but lowdown was not found.])])
     ])
-- 
2.30.2

Reply via email to