My Customized KOReader package
this whole patch isn't used since i wasted my time trying to upstream this and someone else's solution
was accepted without conversation about it. i use instead a version which just includes my wallabag fix:
{ pkgs ? import <nixpkgs> {},
stdenv ? pkgs.stdenv,
lib ? pkgs.lib,
unpatched ? pkgs.koreader,
luajit ? pkgs.luajit }:
(old: {
unpatched.overrideAttrs patches = (old.patches or []) ++ [ /home/rrix/org/cce/data/20/220111T131644.714641/0001-fix-highlight-exporter-to-handle-wallabag-files.patch ];
})
This is including in rixpkgs
overlay and can thus be treated as "the" pkgs.koreader
package in Arroyo Systems.
A previous version of it patched luajit
to support the single lua 5.2 feature that upstream wants to have access
to. It's not used any more since the nixos superfriend hivemind decided
to ship this
without comparison with my patch.
{ pkgs ? import <nixpkgs> {},
stdenv ? pkgs.stdenv,
lib ? pkgs.lib,
unpatched ? pkgs.koreader,
luajit ? pkgs.luajit }:
let
patchedLuajit = luajit.overrideAttrs (old: {
patches = (old.patches or []) ++ [
# /home/rrix/org/cce/data/20/220111T131644.714641/koreader-luajit-enable-table_pack.patch
(builtins.fetchurl {
url = "https://raw.githubusercontent.com/koreader/koreader-base/4216c40d662660c9bbc48e79893b437e97518254/thirdparty/luajit/koreader-luajit-enable-table_pack.patch";
sha256 = "00wr4q4w5s4k5na7sganvzwmkx7vgbmavi3k54v6y780pyqqm9j8";
})
];
});
koreader' = unpatched.overrideAttrs (old: {
patches = (old.patches or []) ++ [ /home/rrix/org/cce/data/20/220111T131644.714641/0001-fix-highlight-exporter-to-handle-wallabag-files.patch ];
installPhase = old.installPhase + ''
ln -s "${pkgs.noto-fonts}/share/fonts/noto/NotoSans[wdth,wght].ttf" $out/lib/koreader/fonts/NotoSans-Regular.ttf
ln -s "${pkgs.noto-fonts}/share/fonts/noto/NotoSans[wdth,wght].ttf" $out/lib/koreader/fonts/NotoSans-Bold.ttf
ln -s "${pkgs.noto-fonts}/share/fonts/noto/NotoSans[wdth,wght].ttf" $out/lib/koreader/fonts/NotoSans-Italic.ttf
'';
});
koreader'' = koreader'.override { luajit = patchedLuajit; };
in
'' koreader
There are two changes:
luajit
is built with a patch to enable
some lua 5.2 features without taking everything; this is taken from
upstream. An alternative would be to replace the calls to table.pack
with {...}
.
diff --git a/src/lib_table.c b/src/lib_table.c
index a723326a..28af227f 100644--- a/src/lib_table.c
+++ b/src/lib_table.c
@@ -267,7 +267,6 @@ LJLIB_CF(table_sort)
return 0;
}
-#if LJ_52
LJLIB_PUSH("n")
LJLIB_CF(table_pack)
{@@ -283,7 +282,6 @@ LJLIB_CF(table_pack)
lj_gc_check(L);
return 1;
}-#endif
LJLIB_NOREG LJLIB_CF(table_new) LJLIB_REC(.)
{@@ -316,10 +314,8 @@ static int luaopen_table_clear(lua_State *L)
LUALIB_API int luaopen_table(lua_State *L)
{
LJ_LIB_REG(L, LUA_TABLIBNAME, table);-#if LJ_52
lua_getglobal(L, "unpack");
lua_setfield(L, -2, "unpack");-#endif
lj_lib_prereg(L, LUA_TABLIBNAME ".new", luaopen_table_new, tabV(L->top-1));
lj_lib_prereg(L, LUA_TABLIBNAME ".clear", luaopen_table_clear, tabV(L->top-1)); return 1;
this patch for fixing support for notes export from wallabag files in KOReader was made from koreader.git and then had the paths modified since the nixpkg explodes the debian packge…
diff --git a/plugins/exporter.koplugin/clip.lua b/plugins/exporter.koplugin/clip.lua
index 2d40c127..e7aaaeb9 100644--- a/usr/lib/koreader/plugins/exporter.koplugin/clip.lua
+++ b/usr/lib/koreader/plugins/exporter.koplugin/clip.lua
@@ -108,6 +108,10 @@ function MyClipping:getTitle(line)
elseif extensions[line:sub(-5):lower()] then
line = line:sub(1, -6)
end+ if util.stringStartsWith(line, "[w-id_") then
+ wallabag_id, title = string.match(line, "%[w%-id_(%d+)%] ([^.]+)")
+ return title, ""
+ end
local _, _, title, author = line:find("(.-)%s*%((.*)%)")
if not author then _, _, title, author = line:find("(.-)%s*-%s*(.*)")
Koreader on My NixOS configuration with the storage directory fudged
Trying with "regular" bind mount … This is done so that file:~/.config/koreader/history.lua
is able to stay in sync between my Onyx
Boox or another Android tablet running koreader
:
{ pkgs, ... }:
{
fileSystems."/storage/emulated/0/reMarkable" = {
device = "/home/rrix/ebooks";
options = [ "bind" ];
};
environment.systemPackages = [
# (pkgs.callPackage ../pkgs/koreader.nix {})
pkgs.koreader];
}
I could have put this in home-manager, and perhaps I should for future usecases, but I think I am kind of nervous to have an easy to use KOReader package in places where I will have Syncthing but not this bind mount to keep the configuration well-structured. Pardon me, future me, you surely understand.
CANCELLED KOReader on My NixOS configuration via container
I'll try to use nixos-container
for
this so that i can do some bind-mount fuckery to make history.lua
work without having to edit it.
, #+ARROYONIXOSMODULE: nixos/koreader-container.nix , #+AUTOTANGLE: t
I was having KOReader crash, but my patched version + with the metadata fixed I think it'll work, actually. Fine having it in my system packages.
{ pkgs, ... }:
{
networking.nat.enable = true;
networking.nat.internalInterfaces = ["ve-koreader"];
networking.nat.externalInterface = "wlp170s0";
containers.koreader = {
privateNetwork = true;
hostAddress = "192.168.7.10";
localAddress = "192.168.7.11";
config = { config, pkgs, ... }:
{
environment.systemPackages = [ pkgs.koreader ];
services.openssh = {
enable = true;
forwardX11 = true;
};
users.users.koreader = {
openssh.authorizedKeys.keys = pkgs.lib.publicKeys.rrix;
password = "koreader-system";
isNormalUser = true;
};
};
bindMounts = {
"/storage/emulated/0/reMarkable" = {
hostPath = "/home/rrix/mobile-library";
isReadOnly = true;
};
"/home/koreader/.config/koreader" = {
hostPath = "/home/rrix/koreader";
isReadOnly = true;
};
};
};
}
this doesn't seem to work even if it should:
[nix-shell:~/org/cce]$ ssh -X koreader@192.168.7.11 koreader
---------------------------------------------
launching...
_ _____ ____ _
| |/ / _ \| _ \ ___ __ _ __| | ___ _ __
| ' / | | | |_) / _ \/ _` |/ _` |/ _ \ '__|
| . \ |_| | _ < __/ (_| | (_| | __/ |
|_|\_\___/|_| \_\___|\__,_|\__,_|\___|_|
It's a scroll... It's a codex... It's KOReader!
[*] Current time: 01/11/22-12:21:59
[*] Version: v2021.11
Xlib: extension "RANDR" missing on display "localhost:10.0".
ffi.load: blitbuffer
ffi.load: SDL2
ffi.load: SDL2
Starting SDL in /nix/store/4lh7l75w0di9mq51a5wmjqnz2d3fhvks-luajit-2.1.0-2021-10-27/bin/
SDL: no gamecontrollers connected
ffi.load: libs/liblodepng.so
01/11/22-12:21:59 INFO initializing for device Linux
01/11/22-12:21:59 INFO framebuffer resolution: {
["w"] = 1030,
["h"] = 1082,
}
ffi.load: libs/libmupdf.so
ffi.load: libs/libwrap-mupdf.so
01/11/22-12:21:59 INFO Performing one-time migration for 20210925
ffi.load: libs/libfreetype.so.6
ffi.load: libs/libharfbuzz.so.0
ffi.load: libs/libzstd.so.1
01/11/22-12:21:59 INFO /home/koreader/.config/koreader/cache/fontlist/fontinfo.dat [string "/home/koreader/.config/koreader/cache/fontlis..."]:1: unexpected symbol near '/' initializing it
/nix/store/4lh7l75w0di9mq51a5wmjqnz2d3fhvks-luajit-2.1.0-2021-10-27/bin/luajit: frontend/apps/filemanager/filemanagerhistory.lua:20: attempt to index field 'ui' (a nil value)
stack traceback:
frontend/apps/filemanager/filemanagerhistory.lua:20: in function 'init'
frontend/ui/widget/widget.lua:48: in function 'new'
./reader.lua:304: in function 'action'
frontend/ui/uimanager.lua:1201: in function '_checkTasks'
frontend/ui/uimanager.lua:1622: in function 'handleInput'
frontend/ui/uimanager.lua:1730: in function 'run'
./reader.lua:323: in main chunk
[C]: at 0x00406310
ffi.load: libs/libutf8proc.so.2