koreader-from-src: use nixpkgs nanosvg (or, most of it)

This commit is contained in:
Colin 2024-03-22 14:29:23 +00:00
parent fe2fb40565
commit a316c87db6
2 changed files with 20 additions and 8 deletions

View File

@ -65,6 +65,7 @@
, libpng
, libunibreak
, libwebp
, nanosvg
, openssl
, openssh
, sdcv
@ -87,6 +88,15 @@ let
rev = "v${version}";
hash = "sha256-/51pOGSAoaS0gOKlqNKruwaKY5qylzCpeNUrWyzYTpA=";
};
nanosvg-headers-ko = symlinkJoin {
# koreader's heavily-patched mupdf is dependent on a koreader-specific `stb_image_write` extension to nanosvg.
# nanosvg is used as a header-only library, so just patch that extension straight into the src.
name = "nanosvg-headers-ko";
paths = [
"${nanosvg.src}/src"
"${src}/base/thirdparty/nanosvg"
];
};
# XXX: for some inscrutable reason, `enable52Compat` is *partially* broken, only when cross compiling.
# `table.unpack` is non-nil, but `table.pack` is nil.
# the normal path is for `enable52Compat` to set `env.NIX_CFLAGS_COMPILE = "-DLUAJIT_ENABLE_LUA52COMPAT";`
@ -279,6 +289,8 @@ let
LUA_LIBDIR="${lib.getLib luaEnv}/lib/libluajit-5.1.so" \
LUA_RAPIDJSON_ROCK="${rockspecFor "rapidjson"}" \
LUA_SPORE_ROCK="${rockspecFor "lua-spore"}" \
NANOSVG_HEADERS="${nanosvg-headers-ko}" \
NANOSVG_INCLUDE_DIR="${nanosvg-headers-ko}" \
OPENSSL_LIB="${lib.getLib openssl}/lib/libssl.so" \
OPENSSL_DIR="${opensslAll}" \
SSL_LIB="${lib.getLib openssl}/lib/libssl.so.3" \
@ -515,7 +527,7 @@ stdenv.mkDerivation rec {
passthru = {
# exposed for debugging
inherit luajit52 luaEnv rockspecFor;
inherit luajit52 luaEnv nanosvg-headers-ko rockspecFor;
inherit (overlayedLuaPkgs luaEnv.pkgs)
luajson
htmlparser

View File

@ -241,13 +241,13 @@ in
# package = libAndDev mupdf; # nixpkgs' mupdf is incompatible with koreader's `libwrap-mupdf`
# package = libAndDev mupdf_1_17; # does not compile
};
nanosvg = {
source.url = "https://github.com/memononen/nanosvg.git";
source.rev = "93ce879dc4c04a3ef1758428ec80083c38610b1f";
source.hash = "sha256-ZtenaXJqMZr2+BxYENG1zUoQ+Qoxlxy0m/1YfJBKAFk=";
machineAgnostic = true;
package = nanosvg.src; # KOReader only wants the .h files, but decides to do that without even building it.
};
# nanosvg = {
# source.url = "https://github.com/memononen/nanosvg.git";
# source.rev = "93ce879dc4c04a3ef1758428ec80083c38610b1f";
# source.hash = "sha256-ZtenaXJqMZr2+BxYENG1zUoQ+Qoxlxy0m/1YfJBKAFk=";
# machineAgnostic = true;
# package = nanosvg.src; # KOReader only wants the .h files, but decides to do that without even building it.
# };
# openssh = {
# source.url = "https://github.com/openssh/openssh-portable.git";
# source.rev = "V_8_6_P1";