koreader: replace vendored dependencies with their nixpkgs equivalents much more effectively

the old method was still causing everything to be re-compiled within koreader, rather than linking against the nix store.

decreases build time to about 3m on a desktop
This commit is contained in:
2024-02-04 19:39:32 +00:00
parent 4a96fa233a
commit abdbb83e10
3 changed files with 450 additions and 185 deletions

View File

@@ -22,6 +22,7 @@
{ config, lib, pkgs, sane-lib, ... }:
let
cfg = config.sane.programs.koreader;
feeds = sane-lib.feeds;
allFeeds = config.sane.feeds;
wantedFeeds = feeds.filterByFormat [ "text" ] allFeeds;
@@ -81,4 +82,10 @@ in {
# could be more explicit if i symlinked the history.lua file to somewhere it can persist better.
persist.byStore.plaintext = [ ".config/koreader" ];
};
nixpkgs.config.permittedInsecurePackages = lib.optionals cfg.enabled [
# koreader uses an ancient openssl.
# TODO: can i DI a newer version into it, anyway?
"openssl-1.1.1w"
];
}

View File

@@ -8,8 +8,19 @@
# koreader and all its deps are installed to $out/lib/koreader
# - i.e. it vendors its runtime deps
#
# there's probably a simpler implementation of this which just coverrides the rules defined in koreader/base/Makefile.third.
# - maybe, even, if we just satisfy the rules there (i.e. drop our files directly to the output which the Makefile rule would otherwise produce), then all's good?
# a good way to substitute nixpkgs deps in place of KOReader's vendored deps is to
# inject them into base/Makefile.third, via makeFlags.
# failing that, we can patch the source of each vendored library into base/thirdparty/*/CMakeLists.txt
# and KOReader will build them from-source perfectly, but that's more involved on our end.
#
# TODO:
# - don't vendor fonts
# - package enough of KOReader's deps to remove `sources.nix`
# - SDL2 (only used by macos??)
# - FBINK
# - NANOSVG (slightly complicated; koreader needs access to its source code)
# - SRELL
# - build crengine dep via nixpkgs `coolreader` pkg (with source patched to <https://github.com/koreader/crengine>)?
{ lib
, autoPatchelfHook
, autoconf
@@ -31,10 +42,38 @@
, pkgs
, python3
, ragel
, SDL2
, stdenv
, substituteAll
, which
# third-party dependencies which KOReader would ordinarily vendor
, symlinkJoin
, curl
, czmq
, djvulibre
, dropbear
, freetype
, fribidi
# , gettext
, giflib
, glib
, gnutar
, harfbuzz
, libiconvReal
, libjpeg_turbo
, libpng
, libunibreak
, libwebp
, openssl_1_1
, openssh
, sdcv
, SDL2 # koreader doesn't actually vendor this, just expects it'll magically be available
, sqlite
, utf8proc
, zlib
, zeromq4
, zstd
, zsync
}:
let
sources = callPackage ./sources.nix { luajit = luajit52; };
@@ -101,6 +140,160 @@ let
# ln -s "$prebuilt" "$build_dir/$lib-prefix/src/$lib"
# ln -s "$prebuilt" "$build_dir/$lib-prefix/src/$lib-build"
'';
getContrib = pkg: stdenv.mkDerivation {
inherit (pkg) name src;
dontConfigure = true;
dontBuild = true;
installPhase = ''
mkdir "$out"
cp -R ./contrib/ "$out/contrib"
'';
};
lib' = lib;
fhsLib = pkg: { lib ? true, include ? true, flatLib ? false, flatInclude ? false, contrib ? false }: symlinkJoin {
inherit (pkg) name;
paths = (lib'.optionals lib [
"${lib'.getLib pkg}"
]) ++ (lib'.optionals include [
"${lib'.getDev pkg}"
]) ++ (lib'.optionals flatLib [
"${lib'.getLib pkg}/lib"
]) ++ (lib'.optionals flatInclude [
"${lib'.getDev pkg}/include"
]) ++ (lib'.optionals contrib [
"${getContrib pkg}"
]);
};
# mostly for k2pdf, which expects lib/ and include/ for each dep to live side-by-side
libAndDev = pkg: fhsLib pkg { lib = true; include = true; };
# these probably have more dirs than they really need.
djvulibreAll = fhsLib djvulibre { lib=true; include=true; flatInclude=true; };
opensslAll = fhsLib openssl_1_1 { lib=false; include=true; flatLib=true; };
utf8procAll = fhsLib utf8proc { lib=true; include=false; flatInclude=true; };
# KOreader uses ZLIB_DIR as:
# - -L${ZLIB_DIR}
# - -I${ZLIB_DIR}
# - -I${ZLIB_DIR}/include
zlibAll = fhsLib zlib { lib=false; include=true; flatLib=true; flatInclude=true; contrib=true; };
libunibreak' = libunibreak.overrideAttrs (canon: {
patches = (canon.patches or []) ++ [
"${src}/base/thirdparty/libunibreak/add_lb_get_char_class.patch"
];
});
# values to provide to koreader/base/Makefile.defs.
# should be ok to put this in `makeFlags` array, but i can't get that to work!
# LUAROCKS_BINARY substitution is to support the cross-compilation case (i.e. emulate it during the build process)
makefileDefs = ''
CURL_LIB="${lib.getLib curl}/lib/libcurl.so" \
CURL_DIR="${lib.getDev curl}" \
CZMQ_LIB="${lib.getLib czmq}/lib/libczmq.so" \
CZMQ_DIR="${lib.getDev czmq}" \
DJVULIBRE_LIB="${lib.getLib djvulibre}/lib/libdjvulibre.so" \
DJVULIBRE_LIB_LINK_FLAG="-L ${lib.getLib djvulibre}/lib -l:libdjvulibre.so" \
DJVULIBRE_DIR="${djvulibreAll}" \
FREETYPE_LIB="${lib.getLib freetype}/lib/libfreetype.so" \
FREETYPE_LIB_LINK_FLAG="-L ${lib.getLib freetype}/lib -l:libfreetype.so" \
FREETYPE_DIR="${lib.getDev freetype}" \
FRIBIDI_LIB="${lib.getLib fribidi}/lib/libfribidi.so" \
FRIBIDI_LIB_LINK_FLAG="-L ${lib.getLib fribidi}/lib -l:libfribidi.so" \
FRIBIDI_DIR="${lib.getDev fribidi}" \
GETTEXT_DIR="${lib.getDev gettext}" \
LIBGETTEXT="${lib.getLib gettext}/lib/preloadable_libintl.so" \
GIF_LIB="${lib.getLib giflib}/lib/libgif.so" \
GIF_DIR="${lib.getDev giflib}" \
GLIB="${lib.getLib glib}/lib/libglib-2.0.so" \
GLIB_DIR="${lib.getDev glib}" \
HARFBUZZ_LIB="${lib.getLib harfbuzz}/lib/libharfbuzz.so" \
HARFBUZZ_LIB_LINK_FLAG="-L ${lib.getLib harfbuzz}/lib -l:libharfbuzz.so" \
HARFBUZZ_DIR="${lib.getDev harfbuzz}" \
JPEG_LIB="${lib.getLib libjpeg_turbo}/lib/libjpeg.so" \
JPEG_LIB_LINK_FLAG="-L ${lib.getLib libjpeg_turbo}/lib -l:libjpeg.so" \
JPEG_DIR="${lib.getDev libjpeg_turbo}" \
TURBOJPEG_LIB="${lib.getLib libjpeg_turbo}/lib/libturbojpeg.so" \
LIBICONV="${lib.getLib libiconvReal}/lib/libiconv.so" \
LIBICONV_DIR="${lib.getDev libiconvReal}" \
LIBUNIBREAK_LIB="${lib.getLib libunibreak'}/lib/libunibreak.so" \
LIBUNIBREAK_DIR="${libAndDev libunibreak'}" \
LIBUNIBREAK_LIB_LINK_FLAG="-L ${lib.getLib libunibreak'}/lib -l:libunibreak.so" \
LIBWEBP_LIB="${lib.getLib libwebp}/lib/libwebp.so" \
LIBWEBPDEMUX_LIB="${lib.getLib libwebp}/lib/libwebpdemux.so" \
LIBWEBPSHARPYUV_LIB="${lib.getLib libwebp}/lib/libwebpsharpyuv.so" \
LIBWEBP_DIR="${lib.getDev libwebp}" \
LUAROCKS_BINARY="${lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) (stdenv.hostPlatform.emulator buildPackages)} ${luajit52}/bin/lua ${luaEnv.pkgs.luarocks}/bin/.luarocks-wrapped" \
LUAJIT="${luajit52}/bin/luajit" \
LUAJIT_JIT="${luajit52}/share/lua/5.1/jit" \
LUAJIT_LIB="${lib.getLib luajit52}/lib/libluajit-5.1.so" \
LUA_INCDIR="${lib.getDev luajit52}/include" \
LUA_LIBDIR="${lib.getLib luajit52}/lib/libluajit-5.1.so" \
OPENSSL_LIB="${lib.getLib openssl_1_1}/lib/libssl.so" \
OPENSSL_DIR="${opensslAll}" \
SSL_LIB="${lib.getLib openssl_1_1}/lib/libssl.so.1.1" \
CRYPTO_LIB="${lib.getLib openssl_1_1}/lib/libcrypto.so" \
PNG_LIB="${lib.getLib libpng}/lib/libpng.so" \
PNG_DIR="${libAndDev libpng}" \
SQLITE_LIB="${lib.getLib sqlite}/lib/libsqlite3.so" \
SQLITE_DIR="${lib.getDev sqlite}" \
UTF8PROC_LIB="${lib.getLib utf8proc}/lib/libutf8proc.so" \
UTF8PROC_DIR="${utf8procAll}" \
ZLIB="${lib.getLib zlib}/lib/libz.so" \
ZLIB_DIR="${zlibAll}" \
ZLIB_STATIC="${zlib.static}/lib/libz.a" \
ZMQ_LIB="${lib.getLib zeromq4}/lib/libzmq.so" \
ZMQ_DIR="${lib.getDev zeromq4}" \
ZSTD_LIB="${lib.getLib zstd}/lib/libzstd.so" \
ZSTD_DIR="${lib.getDev zstd}" \
ZSTD_DESTDIR="${lib.getDev zstd}" \
'';
# DO_STRIP=0 else it'll try to strip our externally built libraries, and error because those live in the nix store.
makeFlags = ''
TARGET=${target} DEBIAN=1 SHELL=sh VERBOSE=1 \
DO_STRIP=0 \
${makefileDefs} \
'';
symlinkThirdpartyBins = outdir: ''
ln -sf "${lib.getBin dropbear}/bin/dropbear" "${outdir}/dropbear"
ln -sf "${lib.getExe gnutar}" "${outdir}/tar"
ln -sf "${lib.getBin openssh}/libexec/sftp-server" "${outdir}/sftp-server"
ln -sf "${lib.getBin sdcv}/bin/sdcv" "${outdir}/sdcv"
ln -sf "${lib.getBin zsync}/bin/zsync" "${outdir}/zsync2"
'';
thirdparty = [
curl
czmq
djvulibre
dropbear
freetype
fribidi
gettext
giflib
glib
gnutar
harfbuzz
libiconvReal
libjpeg_turbo
libpng
libunibreak'
libwebp
openssl_1_1
openssh
sdcv
SDL2
sqlite
utf8proc
zlib
zeromq4
zstd
zsync
];
in
stdenv.mkDerivation rec {
pname = "koreader-from-src";
@@ -139,7 +332,7 @@ stdenv.mkDerivation rec {
buildPackages.stdenv.cc # TODO: move to depsBuildBuild?
autoconf # autotools is used by some thirdparty libraries
automake
autoPatchelfHook # TODO: needed?
autoPatchelfHook # used by us, in fixupPhase, to ensure substituted thirdparty deps can be loaded at runtime
cmake # for koreader/base submodule
dpkg
gettext
@@ -163,33 +356,74 @@ stdenv.mkDerivation rec {
let
env = "${buildPackages.coreutils}/bin/env";
in ''
substituteInPlace ../openssl/config --replace '/usr/bin/env' '${env}'
substituteInPlace ../openssl/Configure --replace '/usr/bin/env' '${env}'
${lib.optionalString false /* only needed if using the koreader vendored deps */ ''
substituteInPlace ../openssl/config --replace '/usr/bin/env' '${env}'
substituteInPlace ../openssl/Configure --replace '/usr/bin/env' '${env}'
chmod +x ../glib/gio/gio-querymodules-wrapper.py
chmod +x ../glib/gio/tests/gengiotypefuncs.py
chmod +x ../glib/gobject/tests/taptestrunner.py
# need directory write perm in order to patchShebangs
chmod u+w ../glib/{gio,gio/tests,glib,gobject/tests,tests}
chmod +x ../glib/gio/gio-querymodules-wrapper.py
chmod +x ../glib/gio/tests/gengiotypefuncs.py
chmod +x ../glib/gobject/tests/taptestrunner.py
# need directory write perm in order to patchShebangs
chmod u+w ../glib/{gio,gio/tests,glib,gobject/tests,tests}
patchShebangs ../glib/gio/data-to-c.py
patchShebangs ../glib/gio/gio-querymodules-wrapper.py
patchShebangs ../glib/gio/tests/gengiotypefuncs.py
patchShebangs ../glib/glib/update-gtranslit.py
patchShebangs ../glib/gobject/tests/taptestrunner.py
patchShebangs ../glib/tests/gen-casefold-txt.py
patchShebangs ../glib/tests/gen-casemap-txt.py
patchShebangs ../glib/gio/data-to-c.py
patchShebangs ../glib/gio/gio-querymodules-wrapper.py
patchShebangs ../glib/gio/tests/gengiotypefuncs.py
patchShebangs ../glib/glib/update-gtranslit.py
patchShebangs ../glib/gobject/tests/taptestrunner.py
patchShebangs ../glib/tests/gen-casefold-txt.py
patchShebangs ../glib/tests/gen-casemap-txt.py
substituteInPlace ../glib/gio/gdbus-2.0/codegen/gdbus-codegen.in --replace '/usr/bin/env @PYTHON@' '@PYTHON@'
substituteInPlace ../glib/glib/gtester-report.in --replace '/usr/bin/env @PYTHON@' '@PYTHON@'
substituteInPlace ../glib/gobject/glib-genmarshal.in --replace '/usr/bin/env @PYTHON@' '@PYTHON@'
substituteInPlace ../glib/gobject/glib-mkenums.in --replace '/usr/bin/env @PYTHON@' '@PYTHON@'
substituteInPlace ../glib/gio/gdbus-2.0/codegen/gdbus-codegen.in --replace '/usr/bin/env @PYTHON@' '@PYTHON@'
substituteInPlace ../glib/glib/gtester-report.in --replace '/usr/bin/env @PYTHON@' '@PYTHON@'
substituteInPlace ../glib/gobject/glib-genmarshal.in --replace '/usr/bin/env @PYTHON@' '@PYTHON@'
substituteInPlace ../glib/gobject/glib-mkenums.in --replace '/usr/bin/env @PYTHON@' '@PYTHON@'
substituteInPlace ../harfbuzz/autogen.sh --replace 'which pkg-config' 'which $PKG_CONFIG'
substituteInPlace ../fribidi/autogen.sh --replace 'which pkg-config' 'which $PKG_CONFIG'
substituteInPlace ../harfbuzz/autogen.sh --replace 'which pkg-config' 'which $PKG_CONFIG'
substituteInPlace ../fribidi/autogen.sh --replace 'which pkg-config' 'which $PKG_CONFIG'
''}
substituteInPlace base/Makefile.defs --replace \
'LUAROCKS_BINARY=luarocks' 'LUAROCKS_BINARY=${lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) (stdenv.hostPlatform.emulator buildPackages)} ${luajit52}/bin/lua ${luaEnv.pkgs.luarocks}/bin/.luarocks-wrapped'
# dlopen libraries by name only, allowing them to be found via LD_LIBRARY_PATH
# instead of just via $out/libs. this is required whenever we direct KOreader to use system libs instead of its vendored libs.
for f in $(shopt -s globstar; ls **/*.lua) ; do
substituteInPlace "$f" \
--replace-quiet 'ffi.load("libs/' 'ffi.load("'
done
# reduce deps so that Make doesn't try to rebuild all the thirdparty libraries.
# could probably do this better, like by changing the atime of all of thirdparty/ to match /nix/store products
# substituteInPlace base/Makefile.third --replace-warn '/*.*' '/'
substituteInPlace base/Makefile.third \
--replace-warn '$(THIRDPARTY_DIR)/curl/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/czmq/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/djvulibre/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/dropbear/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/freetype2/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/fribidi/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/gettext/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/giflib/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/glib/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/harfbuzz/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/libiconv/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/libjpeg-turbo/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/libpng/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/libunibreak/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/libwebp/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/luajit/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/openssh/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/openssl/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/sdcv/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/sqlite/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/tar/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/utf8proc/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/zlib/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/libzmq/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/zstd/*.*' "" \
--replace-warn '$(THIRDPARTY_DIR)/zsync2/*.*' "" \
# lots of places in Makefile.third (incorrectly) assume lib paths are relative to CURDIR,
# so link /nix into CURDIR to allow them to work anyway
ln -s /nix base/nix
'';
dontConfigure = true;
@@ -260,23 +494,47 @@ stdenv.mkDerivation rec {
sources.thirdparty
)}
make TARGET=${target} DEBIAN=1 SHELL=sh VERBOSE=1
# outDir should match OUTPUT_DIR in koreader-base
outDir="/build/koreader/base/build/${stdenv.hostPlatform.config}"
mkdir -p "$outDir"
${symlinkThirdpartyBins "$outDir"}
make ${makeFlags}
'';
env = lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
CHOST = stdenv.hostPlatform.config;
};
installPhase = ''
make TARGET=${target} DEBIAN=1 debianupdate
# XXX: build without INSTALL_DIR="$out" as make arg because that conflicts with vars used by third-party libs.
# instead, `make` and then manually install koreader to $out ourselves.
# TODO: might be safe to specify `INSTALL_DIR` here as an env var instead, though?
make debianupdate ${makeFlags}
mv koreader-${target}-${stdenv.hostPlatform.config}/debian/usr $out
# XXX: nixpkgs' `koreader` adds glib and gtk3-x11 to LD_LIBRARY_PATH as well.
wrapProgram $out/bin/koreader --prefix LD_LIBRARY_PATH : ${
lib.makeLibraryPath [ SDL2 ]
(lib.makeLibraryPath thirdparty) + ":$out/lib/koreader/libs"
}
'';
preFixup = ''
# koreader installation copies the thirdparty binaries like tar, sdcv, which we injected earlier.
# but we specifically want these to live in the nix store and be symlinked into koreader instead.
# TODO: this might symlink binaries which koreader doesn't actually use...
# i should either only overwrite the binaries which DO exist at this point,
# or find some other way to inject them (i can maybe just put them on KOreader's PATH?).
${symlinkThirdpartyBins "$out/lib/koreader"}
${lib.concatStringsSep "\n" (builtins.map (dep: ''
if [ -e "${lib.getLib dep}/lib" ]; then
addAutoPatchelfSearchPath "${lib.getLib dep}/lib"
fi
'') thirdparty)
}
'';
# XXX: ^ don't specify INSTALL_DIR="$out" as make arg because that conflicts with vars used by third-party libs
# might be safe to specify that as an env var, though?
# XXX: nixpkgs adds glib and gtk3-x11 to LD_LIBRARY_PATH as well
passthru = {
# exposed for debugging

View File

@@ -64,61 +64,61 @@ in
thirdparty = {
# providing `package` is just a way to optimize builds, by getting KOReader to use the built nixpkg instead of building it itself from source.
# if it fails during an update, it should always be safe to delete the package key.
curl = {
source.url = "https://github.com/curl/curl.git";
source.rev = "tags/curl-7_80_0";
source.hash = "sha256-kzozc0Io+1f4UMivSV2IhzJDQXmad4wNhXN/Y2Lsg3Q=";
package = curl;
};
czmq = {
source.url = "https://github.com/zeromq/czmq.git";
source.rev = "2a0ddbc4b2dde623220d7f4980ddd60e910cfa78";
source.hash = "sha256-p4Cl2PLVgRQ0S4qr3VClJXjvAd2LUBU9oRUvOCfVnyw=";
# package = czmq; # koreader wants v1, nixpkgs has v4
};
djvulibre = {
source.url = "https://gitlab.com/koreader/djvulibre.git";
source.rev = "6a1e5ba1c9ef81c205a4b270c3f121a1e106f4fc";
source.hash = "sha256-OWSbxdr93FH3ed0D+NSFWIah7VDTcL3LIGOciY+f4dk=";
# package = djvulibre; # "cp -fL /build/koreader/base/thirdparty/djvulibre/build/aarch64-unknown-linux-gnu/djvulibre-prefix/src/djvulibre/libdjvu/.libs/libdjvulibre.so.21 ..."
};
# curl = {
# source.url = "https://github.com/curl/curl.git";
# source.rev = "tags/curl-7_80_0";
# source.hash = "sha256-kzozc0Io+1f4UMivSV2IhzJDQXmad4wNhXN/Y2Lsg3Q=";
# package = curl;
# };
# czmq = {
# source.url = "https://github.com/zeromq/czmq.git";
# source.rev = "2a0ddbc4b2dde623220d7f4980ddd60e910cfa78";
# source.hash = "sha256-p4Cl2PLVgRQ0S4qr3VClJXjvAd2LUBU9oRUvOCfVnyw=";
# # package = czmq; # koreader wants v1, nixpkgs has v4
# };
# djvulibre = {
# source.url = "https://gitlab.com/koreader/djvulibre.git";
# source.rev = "6a1e5ba1c9ef81c205a4b270c3f121a1e106f4fc";
# source.hash = "sha256-OWSbxdr93FH3ed0D+NSFWIah7VDTcL3LIGOciY+f4dk=";
# # package = djvulibre; # "cp -fL /build/koreader/base/thirdparty/djvulibre/build/aarch64-unknown-linux-gnu/djvulibre-prefix/src/djvulibre/libdjvu/.libs/libdjvulibre.so.21 ..."
# };
fbink = {
source.url = "https://github.com/NiLuJe/FBInk.git";
source.rev = "ae9dd275de369b1b34e1b566bca29573f06f38a2";
source.hash = "sha256-wkyl9xtw9ocjGGArvfGa1qjamwgywPktnZJNfdychB0=";
# package: not packaged for nix
};
freetype2 = {
source.url = "https://gitlab.com/koreader/freetype2.git";
source.rev = "VER-2-13-2";
source.hash = "sha256-yylSmVM3D5xnbFx9qEEHFIP/K0x/WDXZr0MA4C7ng7k=";
package = libAndDev freetype;
};
fribidi = {
source.url = "https://github.com/fribidi/fribidi.git";
source.rev = "tags/v1.0.12";
source.hash = "sha256-L4m/F9rs8fiv9rSf8oy7P6cthhupc6R/lCv30PLiQ4M=";
package = libAndDev fribidi;
};
giflib = {
source.url = "https://gitlab.com/koreader/giflib.git";
source.rev = "5.1.4";
source.hash = "sha256-znbY4tliXHXVLBd8sTKrbglOdCUb7xhcCQsDDWcQfhw=";
package = giflib;
};
glib = {
source.url = "https://github.com/GNOME/glib.git";
source.rev = "2.58.3";
source.hash = "sha256-KmJXCJ6h2QhPyK1axk+Y9+yJzO0wnCczcogopxGShJc=";
# package = libAndDev glib; # breaks sdcv build
};
harfbuzz = {
source.url = "https://github.com/harfbuzz/harfbuzz.git";
source.rev = "8.3.0";
source.hash = "sha256-sO0Kd2wAbMm+Auf7tXsDNal7hqND8iwkb0M/9WWt9sI=";
# package = harfbuzz;
package = libAndDev harfbuzz;
};
# freetype2 = {
# source.url = "https://gitlab.com/koreader/freetype2.git";
# source.rev = "VER-2-13-2";
# source.hash = "sha256-yylSmVM3D5xnbFx9qEEHFIP/K0x/WDXZr0MA4C7ng7k=";
# package = libAndDev freetype;
# };
# fribidi = {
# source.url = "https://github.com/fribidi/fribidi.git";
# source.rev = "tags/v1.0.12";
# source.hash = "sha256-L4m/F9rs8fiv9rSf8oy7P6cthhupc6R/lCv30PLiQ4M=";
# package = libAndDev fribidi;
# };
# giflib = {
# source.url = "https://gitlab.com/koreader/giflib.git";
# source.rev = "5.1.4";
# source.hash = "sha256-znbY4tliXHXVLBd8sTKrbglOdCUb7xhcCQsDDWcQfhw=";
# package = giflib;
# };
# glib = {
# source.url = "https://github.com/GNOME/glib.git";
# source.rev = "2.58.3";
# source.hash = "sha256-KmJXCJ6h2QhPyK1axk+Y9+yJzO0wnCczcogopxGShJc=";
# # package = libAndDev glib; # breaks sdcv build
# };
# harfbuzz = {
# source.url = "https://github.com/harfbuzz/harfbuzz.git";
# source.rev = "8.3.0";
# source.hash = "sha256-sO0Kd2wAbMm+Auf7tXsDNal7hqND8iwkb0M/9WWt9sI=";
# # package = harfbuzz;
# package = libAndDev harfbuzz;
# };
kobo-usbms = {
source.url = "https://github.com/koreader/KoboUSBMS.git";
source.rev = "3daab316d3aff2b43ced9c0b18e6ecdeec953e4a";
@@ -131,42 +131,42 @@ in
source.hash = "sha256-SDXKam768xvZZvTbXe3sssvZyeLEEiY97Vrzx8hoc6g=";
# package = leptonica; # k2pdf needs leptonica src. # cp -f /build/koreader/base/thirdparty/libk2pdfopt/build/aarch64-unknown-linux-gnu/libk2pdfopt-prefix/src/libk2pdfopt/leptonica_mod/dewarp2.c
};
libjpeg-turbo = {
source.url = "https://github.com/libjpeg-turbo/libjpeg-turbo.git";
source.rev = "3.0.1";
source.hash = "sha256-ofdecix4m0FA9gdyQh7zYn99SYBbH2+a7jfoZlsadoA=";
# package = libAndDev libjpeg_turbo;
};
# libjpeg-turbo = {
# source.url = "https://github.com/libjpeg-turbo/libjpeg-turbo.git";
# source.rev = "3.0.1";
# source.hash = "sha256-ofdecix4m0FA9gdyQh7zYn99SYBbH2+a7jfoZlsadoA=";
# # package = libAndDev libjpeg_turbo;
# };
libk2pdfopt = {
source.url = "https://github.com/koreader/libk2pdfopt.git";
source.rev = "09f1e011a618c8ec06b4caa67079682119d2aaa7";
source.hash = "sha256-37sZ46dG6Z1Wk7NrhKAKl5j9r1bN6g01cd5Iyt/2coM=";
# package = k2pdfopt; # nixpkgs k2pdfopt does not compile (broken deps). also, uses old insecure mupdf 1.17 (oh well, koreader is even older)
};
libpng = {
source.url = "https://github.com/glennrp/libpng.git";
source.rev = "v1.6.40";
source.hash = "sha256-Rad7Y5Z9PUCipBTQcB7LEP8fIVTG3JsnMeknUkZ/rRg=";
# package = libAndDev libpng; # "/build/koreader/base/thirdparty/libpng/build/aarch64-unknown-linux-gnu/libpng-prefix/src/libpng-build/.libs/libpng16.so.16"
};
libunibreak = {
source.url = "https://github.com/adah1972/libunibreak.git";
source.rev = "tags/libunibreak_5_1";
source.hash = "sha256-hjgT5DCQ6KFXKlxk9LLzxGHz6B71X/3Ot7ipK3KY85A=";
# package = libAndDev libunibreak; # nixpkgs version is incompatible
};
libwebp = {
source.url = "https://github.com/webmproject/libwebp.git";
source.rev = "v1.3.2";
source.hash = "sha256-gfwUlJ44biO1lB/3SKfMkM/YBiYcz6RqeMOw+0o6Z/Q=";
package = libAndDev libwebp;
};
libzmq = {
source.url = "https://github.com/zeromq/libzmq";
source.rev = "883e95b22e0bffffa72312ea1fec76199afbe458";
source.hash = "sha256-R76EREtHsqcoKxKrgT8gfEf9pIWdLTBXvF9cDvjEf3E=";
# package = zeromq4; # despite the name, it's libzmq.so.5 instead of libzmq.so.4
};
# libpng = {
# source.url = "https://github.com/glennrp/libpng.git";
# source.rev = "v1.6.40";
# source.hash = "sha256-Rad7Y5Z9PUCipBTQcB7LEP8fIVTG3JsnMeknUkZ/rRg=";
# # package = libAndDev libpng; # "/build/koreader/base/thirdparty/libpng/build/aarch64-unknown-linux-gnu/libpng-prefix/src/libpng-build/.libs/libpng16.so.16"
# };
# libunibreak = {
# source.url = "https://github.com/adah1972/libunibreak.git";
# source.rev = "tags/libunibreak_5_1";
# source.hash = "sha256-hjgT5DCQ6KFXKlxk9LLzxGHz6B71X/3Ot7ipK3KY85A=";
# # package = libAndDev libunibreak; # nixpkgs version is incompatible (kpvcrlib/crengine #includes libunibreak and then fails, calling into undefined functions)
# };
# libwebp = {
# source.url = "https://github.com/webmproject/libwebp.git";
# source.rev = "v1.3.2";
# source.hash = "sha256-gfwUlJ44biO1lB/3SKfMkM/YBiYcz6RqeMOw+0o6Z/Q=";
# package = libAndDev libwebp;
# };
# libzmq = {
# source.url = "https://github.com/zeromq/libzmq";
# source.rev = "883e95b22e0bffffa72312ea1fec76199afbe458";
# source.hash = "sha256-R76EREtHsqcoKxKrgT8gfEf9pIWdLTBXvF9cDvjEf3E=";
# # package = zeromq4; # despite the name, it's libzmq.so.5 instead of libzmq.so.4
# };
lj-wpaclient = {
source.url = "https://github.com/koreader/lj-wpaclient.git";
source.rev = "2f93beb3071e6ebb57c783bd5b92f83aa5ebb757";
@@ -186,12 +186,12 @@ in
source.hash = "sha256-aSTLSfqz/MIDFVRwtBlDNBUhPb7KqOl32/Y62Hdec1s=";
# package: not in nixpkgs
};
luajit = {
source.url = "https://github.com/LuaJIT/LuaJIT";
source.rev = "29b0b282f59ac533313199f4f7be79490b7eee51";
source.hash = "sha256-S57/NR+0hF1KTdn+cbVkJh3MTfklSwtZua1CYKduVlk=";
# package = luajit; #< could be fixed; follows a different install structure
};
# luajit = {
# source.url = "https://github.com/LuaJIT/LuaJIT";
# source.rev = "29b0b282f59ac533313199f4f7be79490b7eee51";
# source.hash = "sha256-S57/NR+0hF1KTdn+cbVkJh3MTfklSwtZua1CYKduVlk=";
# # package = luajit; #< could be fixed; follows a different install structure
# };
lua-rapidjson = {
source.url = "https://github.com/xpol/lua-rapidjson";
source.rev = "242b40c8eaceb0cc43bcab88309736461cac1234";
@@ -247,32 +247,32 @@ in
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";
source.hash = "sha256-yjIpSbe5pt9sEV2MZYGztxejg/aBFfKO8ieRvoLN2KA=";
package = openssh;
};
openssl = {
source.url = "https://github.com/openssl/openssl.git";
source.rev = "OpenSSL_1_1_1u";
source.hash = "sha256-JOcUj4ovA6621+1k2HUsvhGX1B9BjvaMbCaSx680nSs=";
# TODO: i think we can use nixpkgs openssl, just lift lib/* up to the root of the package directory
# package = lib.getLib openssl_1_1; # N.B.: requires building with `NIXPKGS_ALLOW_INSECURE=1 nix build --impure ...`
};
# openssh = {
# source.url = "https://github.com/openssh/openssh-portable.git";
# source.rev = "V_8_6_P1";
# source.hash = "sha256-yjIpSbe5pt9sEV2MZYGztxejg/aBFfKO8ieRvoLN2KA=";
# package = openssh;
# };
# openssl = {
# source.url = "https://github.com/openssl/openssl.git";
# source.rev = "OpenSSL_1_1_1u";
# source.hash = "sha256-JOcUj4ovA6621+1k2HUsvhGX1B9BjvaMbCaSx680nSs=";
# # TODO: i think we can use nixpkgs openssl, just lift lib/* up to the root of the package directory
# # package = lib.getLib openssl_1_1; # N.B.: requires building with `NIXPKGS_ALLOW_INSECURE=1 nix build --impure ...`
# };
popen-noshell = {
source.url = "https://github.com/famzah/popen-noshell.git";
source.rev = "e715396a4951ee91c40a98d2824a130f158268bb";
source.hash = "sha256-JeBZMsg6ZUGSnyZ4eds4w63gM/L73EsAnLaHOPpL6iM=";
# package: not in nixpkgs
};
sdcv = {
# upstream is (temporarily?) acquiring this via `download_project` machinery
source.url = "https://github.com/Dushistov/sdcv.git";
source.rev = "v0.5.5";
source.hash = "sha256-EyvljVXhOsdxIYOGTzD+T16nvW7/RNx3DuQ2OdhjXJ4=";
package = sdcv;
};
# sdcv = {
# # upstream is (temporarily?) acquiring this via `download_project` machinery
# source.url = "https://github.com/Dushistov/sdcv.git";
# source.rev = "v0.5.5";
# source.hash = "sha256-EyvljVXhOsdxIYOGTzD+T16nvW7/RNx3DuQ2OdhjXJ4=";
# package = sdcv;
# };
tesseract = {
source.url = "https://github.com/tesseract-ocr/tesseract.git";
source.rev = "60176fc5ae5e7f6bdef60c926a4b5ea03de2bfa7";
@@ -285,64 +285,64 @@ in
source.hash = "sha256-vBRkFdc5a0FIt15HBz3TnqMZ+GGsqjEefnfJEpuVTBs=";
# package = turbo; # nixpkgs' turbo is a totally different thing
};
utf8proc = {
source.url = "https://github.com/JuliaStrings/utf8proc.git";
source.rev = "v2.9.0";
source.hash = "sha256-Sgh8vTbclUV+lFZdR29PtNUy8F+9L/OAXk647B+l2mg=";
# package = libAndDev utf8proc; # nixpkgs is v3, not v2; incompatible .so name. /build/koreader/base/thirdparty/utf8proc/build/aarch64-unknown-linux-gnu/utf8proc-prefix/src/utf8proc/libutf8proc.so.2
};
zstd = {
source.url = "https://github.com/facebook/zstd.git";
source.rev = "tags/v1.5.5";
source.hash = "sha256-tHHHIsQU7vJySrVhJuMKUSq11MzkmC+Pcsj00uFJdnQ=";
package = libAndDev zstd;
};
zsync2 = {
source.url = "https://github.com/NiLuJe/zsync2.git";
source.rev = "e618d18f6a7cbf350cededa17ddfe8f76bdf0b5c";
source.hash = "sha256-S0vxCON1l6S+NWlnRPfm7R07DVkvkG+6QW5LNvXBlA8=";
package = zsync; # possibly a different thing than koreader's
};
# utf8proc = {
# source.url = "https://github.com/JuliaStrings/utf8proc.git";
# source.rev = "v2.9.0";
# source.hash = "sha256-Sgh8vTbclUV+lFZdR29PtNUy8F+9L/OAXk647B+l2mg=";
# # package = libAndDev utf8proc; # nixpkgs is v3, not v2; incompatible .so name. /build/koreader/base/thirdparty/utf8proc/build/aarch64-unknown-linux-gnu/utf8proc-prefix/src/utf8proc/libutf8proc.so.2
# };
# zstd = {
# source.url = "https://github.com/facebook/zstd.git";
# source.rev = "tags/v1.5.5";
# source.hash = "sha256-tHHHIsQU7vJySrVhJuMKUSq11MzkmC+Pcsj00uFJdnQ=";
# package = libAndDev zstd;
# };
# zsync2 = {
# source.url = "https://github.com/NiLuJe/zsync2.git";
# source.rev = "e618d18f6a7cbf350cededa17ddfe8f76bdf0b5c";
# source.hash = "sha256-S0vxCON1l6S+NWlnRPfm7R07DVkvkG+6QW5LNvXBlA8=";
# package = zsync; # possibly a different thing than koreader's
# };
};
externalProjects = {
dropbear = {
url = "http://deb.debian.org/debian/pool/main/d/dropbear/dropbear_2018.76.orig.tar.bz2";
hash = "sha256-8vuRZ+yoz5NFal/B1Pr3CZAqOrcN1E41LzrLw//a6mU=";
};
gettext = {
url = "http://ftpmirror.gnu.org/gettext/gettext-0.21.tar.gz";
hash = "sha256-x30NoxAq7JwH9DZx5gYR6/+JqZbvFZSXzo5Z0HV4axI=";
};
libiconv = {
url = "http://ftpmirror.gnu.org/libiconv/libiconv-1.15.tar.gz";
hash = "sha256-zPU2YgpFRY0muoOIepg7loJwAekqE4R7ReSSXMiRMXg=";
};
# dropbear = {
# url = "http://deb.debian.org/debian/pool/main/d/dropbear/dropbear_2018.76.orig.tar.bz2";
# hash = "sha256-8vuRZ+yoz5NFal/B1Pr3CZAqOrcN1E41LzrLw//a6mU=";
# };
# gettext = {
# url = "http://ftpmirror.gnu.org/gettext/gettext-0.21.tar.gz";
# hash = "sha256-x30NoxAq7JwH9DZx5gYR6/+JqZbvFZSXzo5Z0HV4axI=";
# };
# libiconv = {
# url = "http://ftpmirror.gnu.org/libiconv/libiconv-1.15.tar.gz";
# hash = "sha256-zPU2YgpFRY0muoOIepg7loJwAekqE4R7ReSSXMiRMXg=";
# };
lpeg = {
url = "http://distcache.FreeBSD.org/ports-distfiles/lpeg-1.0.2.tar.gz";
hash = "sha256-SNZldgUbbHg4j6rQm3BJMJMmRYj80PJY3aqxzdShX/4=";
};
sdcv = {
# TODO: if this form of substitution works, i could optionally patch in *all* deps
# using the `file://@foo@` ExternalProject_Add syntax
url = "https://github.com/Dushistov/sdcv/archive/v0.5.5.tar.gz";
hash = "sha256-TSUZ6PhHm5MB3JHpzaPh7v7xmXDs4OjAXwx7et5dyUs=";
};
# sdcv = {
# # TODO: if this form of substitution works, i could optionally patch in *all* deps
# # using the `file://@foo@` ExternalProject_Add syntax
# url = "https://github.com/Dushistov/sdcv/archive/v0.5.5.tar.gz";
# hash = "sha256-TSUZ6PhHm5MB3JHpzaPh7v7xmXDs4OjAXwx7et5dyUs=";
# };
sdl2 = {
url = "https://github.com/libsdl-org/SDL/releases/download/release-2.28.1/SDL2-2.28.1.tar.gz";
hash = "sha256-SXfOulwAVNvmwvEUZBrO1DzjvytB6mS2o3LWuhKcsV0=";
};
sqlite = {
url = "https://www.sqlite.org/2023/sqlite-autoconf-3440200.tar.gz";
hash = "sha256-HGcZoUi8Qc8PK7vjkm184/XKCdh48SRvzCB2exdbtAc=";
};
tar = {
url = "http://ftpmirror.gnu.org/tar/tar-1.34.tar.gz";
hash = "sha256-A9kIz1doz+a3rViMkhxu0hrKv7K3m3iNEzBFNQdkeu0=";
};
zlib = {
url = "https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.xz";
hash = "sha256-0Uw44xOvw1qah2Da3yYEL1HqD10VSwYwox2gVAEH+5g=";
};
# sqlite = {
# url = "https://www.sqlite.org/2023/sqlite-autoconf-3440200.tar.gz";
# hash = "sha256-HGcZoUi8Qc8PK7vjkm184/XKCdh48SRvzCB2exdbtAc=";
# };
# tar = {
# url = "http://ftpmirror.gnu.org/tar/tar-1.34.tar.gz";
# hash = "sha256-A9kIz1doz+a3rViMkhxu0hrKv7K3m3iNEzBFNQdkeu0=";
# };
# zlib = {
# url = "https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.xz";
# hash = "sha256-0Uw44xOvw1qah2Da3yYEL1HqD10VSwYwox2gVAEH+5g=";
# };
};
}