koreader: use nixpkgs' lua-rapidjson

This commit is contained in:
2024-02-04 20:45:33 +00:00
parent b87934d5f8
commit 8a47eb92ed
2 changed files with 21 additions and 9 deletions

View File

@@ -99,12 +99,16 @@ let
}); });
luaEnv = luajit52.withPackages (ps: with ps; [ luaEnv = luajit52.withPackages (ps: with ps; [
(buildLuarocksPackage { (buildLuarocksPackage {
# needed by KOReader's lua-Spore
pname = "luajson"; pname = "luajson";
version = "1.3.4-1"; version = "1.3.4-1";
src = fetchgit { src = fetchgit {
url = "https://github.com/harningt/luajson.git"; url = "https://github.com/harningt/luajson.git";
rev = "1.3.4"; # rev = "1.3.4";
hash = "sha256-JaJsjN5Gp+8qswfzl5XbHRQMfaCAJpWDWj9DYWJ0gEI="; # 1.3.4 (released 2017) has some incompatible bugs with lpeg library.
# see: <https://github.com/harningt/luajson/commit/6ecaf9bea8b121a9ffca5a470a2080298557b55d>
rev = "6ecaf9bea8b121a9ffca5a470a2080298557b55d";
hash = "sha256-56G0NqIpavKHMQWUxy+Bp7G4ZKrQwUZ2C5e7GJxUJeg=";
}; };
knownRockspec = (fetchurl { knownRockspec = (fetchurl {
url = "mirror://luarocks/luajson-1.3.4-1.rockspec"; url = "mirror://luarocks/luajson-1.3.4-1.rockspec";
@@ -112,7 +116,13 @@ let
}).outPath; }).outPath;
propagatedBuildInputs = [ lpeg ]; propagatedBuildInputs = [ lpeg ];
}) })
lpeg
rapidjson
]); ]);
rockspecFor = luaPkgName: let
pkg = luaEnv.pkgs."${luaPkgName}";
in
"${luaEnv}/${pkg.rocksSubdir}/${luaPkgName}/${pkg.rockspecVersion}/${luaPkgName}-${pkg.rockspecVersion}.rockspec";
crossTargets = { crossTargets = {
# koreader-base Makefile targets to use when compiling for the given host platform # koreader-base Makefile targets to use when compiling for the given host platform
# only used when cross compiling # only used when cross compiling
@@ -225,13 +235,14 @@ let
LIBWEBPDEMUX_LIB="${lib.getLib libwebp}/lib/libwebpdemux.so" \ LIBWEBPDEMUX_LIB="${lib.getLib libwebp}/lib/libwebpdemux.so" \
LIBWEBPSHARPYUV_LIB="${lib.getLib libwebp}/lib/libwebpsharpyuv.so" \ LIBWEBPSHARPYUV_LIB="${lib.getLib libwebp}/lib/libwebpsharpyuv.so" \
LIBWEBP_DIR="${lib.getDev libwebp}" \ LIBWEBP_DIR="${lib.getDev libwebp}" \
LPEG_ROCK="${luaEnv}/${luaEnv.pkgs.lpeg.rocksSubdir}/lpeg/${luaEnv.pkgs.lpeg.rockspecVersion}/lpeg-${luaEnv.pkgs.lpeg.rockspecVersion}.rockspec" \ LPEG_ROCK="${rockspecFor "lpeg"}" \
LUAROCKS_BINARY="${lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) (stdenv.hostPlatform.emulator buildPackages)} ${luajit52}/bin/lua ${luaEnv.pkgs.luarocks}/bin/.luarocks-wrapped" \ LUAROCKS_BINARY="${lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) (stdenv.hostPlatform.emulator buildPackages)} ${luajit52}/bin/lua ${luaEnv.pkgs.luarocks}/bin/.luarocks-wrapped" \
LUAJIT="${luaEnv}/bin/luajit" \ LUAJIT="${luaEnv}/bin/luajit" \
LUAJIT_JIT="${luaEnv}/share/lua/5.1/jit" \ LUAJIT_JIT="${luaEnv}/share/lua/5.1/jit" \
LUAJIT_LIB="${lib.getLib luaEnv}/lib/libluajit-5.1.so" \ LUAJIT_LIB="${lib.getLib luaEnv}/lib/libluajit-5.1.so" \
LUA_INCDIR="${lib.getDev luaEnv}/include" \ LUA_INCDIR="${lib.getDev luaEnv}/include" \
LUA_LIBDIR="${lib.getLib luaEnv}/lib/libluajit-5.1.so" \ LUA_LIBDIR="${lib.getLib luaEnv}/lib/libluajit-5.1.so" \
LUA_RAPIDJSON_ROCK="${rockspecFor "rapidjson"}" \
OPENSSL_LIB="${lib.getLib openssl}/lib/libssl.so" \ OPENSSL_LIB="${lib.getLib openssl}/lib/libssl.so" \
OPENSSL_DIR="${opensslAll}" \ OPENSSL_DIR="${opensslAll}" \
SSL_LIB="${lib.getLib openssl}/lib/libssl.so.3" \ SSL_LIB="${lib.getLib openssl}/lib/libssl.so.3" \
@@ -407,6 +418,7 @@ stdenv.mkDerivation rec {
--replace-warn '$(THIRDPARTY_DIR)/libunibreak/*.*' "" \ --replace-warn '$(THIRDPARTY_DIR)/libunibreak/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/libwebp/*.*' "" \ --replace-warn '$(THIRDPARTY_DIR)/libwebp/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/lpeg/*.*' "" \ --replace-warn '$(THIRDPARTY_DIR)/lpeg/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/lua-rapidjson/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/luajit/*.*' "" \ --replace-warn '$(THIRDPARTY_DIR)/luajit/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/openssh/*.*' "" \ --replace-warn '$(THIRDPARTY_DIR)/openssh/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/openssl/*.*' "" \ --replace-warn '$(THIRDPARTY_DIR)/openssl/*.*' "" \

View File

@@ -192,12 +192,12 @@ in
# source.hash = "sha256-S57/NR+0hF1KTdn+cbVkJh3MTfklSwtZua1CYKduVlk="; # source.hash = "sha256-S57/NR+0hF1KTdn+cbVkJh3MTfklSwtZua1CYKduVlk=";
# # package = luajit; #< could be fixed; follows a different install structure # # package = luajit; #< could be fixed; follows a different install structure
# }; # };
lua-rapidjson = { # lua-rapidjson = {
source.url = "https://github.com/xpol/lua-rapidjson"; # source.url = "https://github.com/xpol/lua-rapidjson";
source.rev = "242b40c8eaceb0cc43bcab88309736461cac1234"; # source.rev = "242b40c8eaceb0cc43bcab88309736461cac1234";
source.hash = "sha256-y/czEVPtCt4uN1n49Qi7BrgZmkG+SDXlM5D2GvvO2qg="; # source.hash = "sha256-y/czEVPtCt4uN1n49Qi7BrgZmkG+SDXlM5D2GvvO2qg=";
# package: TODO: packaged in nix as a luarocks package # # package: TODO: packaged in nix as a luarocks package
}; # };
luasec = { luasec = {
source.url = "https://github.com/brunoos/luasec"; source.url = "https://github.com/brunoos/luasec";
source.rev = "tags/v1.3.1"; source.rev = "tags/v1.3.1";