2023-12-15 20:05:06 +00:00
|
|
|
# docs:
|
|
|
|
# - <https://koreader.rocks/user_guide/>
|
|
|
|
# - <https://github.com/koreader/koreader/wiki>
|
|
|
|
#
|
2023-12-12 20:56:13 +00:00
|
|
|
# post-installation setup:
|
2024-01-27 14:39:02 +00:00
|
|
|
# - add FTP server:
|
|
|
|
# - click near top of window
|
|
|
|
# - tools icon > Cloud storage
|
|
|
|
# - plus icon > FTP server
|
|
|
|
# - "Your FTP name": (anything, e.g. "servo books")
|
|
|
|
# - FTP address: ftp://servo-hn
|
|
|
|
# - FTP username: anonymous
|
|
|
|
# - FTP password: (leave empty)
|
|
|
|
# - base directory: /media/Books
|
2023-12-12 20:56:13 +00:00
|
|
|
# - download dictionaries:
|
|
|
|
# - search icon > settings > dictionary settings > download dictionaries
|
|
|
|
# - these are stored in `~/.config/koreader/data/dict`
|
2023-12-15 20:05:06 +00:00
|
|
|
# - configure defaults:
|
|
|
|
# - edit keys in ~/.config/koreader/settings.reader.lua
|
|
|
|
# - default font size: `["copt_font_size"] = 28,`
|
|
|
|
# - home dir: `["home_dir"] = "/home/colin/Books",`
|
2023-07-23 21:00:43 +00:00
|
|
|
{ config, lib, pkgs, sane-lib, ... }:
|
2023-06-19 09:21:30 +00:00
|
|
|
|
2023-06-20 19:58:02 +00:00
|
|
|
let
|
|
|
|
feeds = sane-lib.feeds;
|
|
|
|
allFeeds = config.sane.feeds;
|
2023-12-14 20:51:09 +00:00
|
|
|
wantedFeeds = feeds.filterByFormat [ "text" ] allFeeds;
|
2023-06-20 19:58:02 +00:00
|
|
|
koreaderRssEntries = builtins.map (feed:
|
|
|
|
# format:
|
|
|
|
# { "<rss/atom url>", limit = <int>, download_full_article=<bool>, include_images=<bool>, enable_filter=<bool>, filter_element = "<css selector>"},
|
|
|
|
# limit = 0 => download and keep *all* articles
|
|
|
|
# download_full_article = true => populate feed by downloading the webpage -- not just what's encoded in the RSS <article> tags
|
|
|
|
# - use this for articles where the RSS only encodes content previews
|
2023-07-22 08:55:05 +00:00
|
|
|
# - in practice, most articles don't work with download_full_article = false
|
2023-06-20 19:58:02 +00:00
|
|
|
# enable_filter = true => only render content that matches the filter_element css selector.
|
|
|
|
let fields = [
|
|
|
|
(lib.escapeShellArg feed.url)
|
2023-12-15 20:05:06 +00:00
|
|
|
"limit = 20"
|
2023-07-22 08:55:05 +00:00
|
|
|
"download_full_article = true"
|
2023-06-20 19:58:02 +00:00
|
|
|
"include_images = true"
|
|
|
|
"enable_filter = false"
|
|
|
|
"filter_element = \"\""
|
|
|
|
]; in "{ ${lib.concatStringsSep ", " fields } }"
|
|
|
|
) wantedFeeds;
|
|
|
|
in {
|
2023-06-19 09:21:30 +00:00
|
|
|
sane.programs.koreader = {
|
2024-01-20 11:11:12 +00:00
|
|
|
packageUnwrapped = pkgs.koreader-from-src;
|
2024-01-27 14:39:22 +00:00
|
|
|
sandbox.method = "bwrap"; # sandboxes fine under landlock too, except for FTP
|
2024-02-02 17:22:57 +00:00
|
|
|
sandbox.wrapperType = "wrappedDerivation";
|
2024-02-08 21:51:32 +00:00
|
|
|
sandbox.net = "clearnet";
|
2024-02-02 17:22:57 +00:00
|
|
|
sandbox.whitelistDri = true; # reduces startup time and subjective page flip time
|
2024-02-14 01:49:49 +00:00
|
|
|
sandbox.whitelistWayland = true;
|
2024-01-27 14:39:22 +00:00
|
|
|
sandbox.extraHomePaths = [
|
2024-02-27 21:36:18 +00:00
|
|
|
"Books/local"
|
2024-02-12 12:54:16 +00:00
|
|
|
"Books/servo"
|
2024-01-27 14:39:22 +00:00
|
|
|
];
|
2024-02-14 01:49:49 +00:00
|
|
|
|
2023-06-19 09:21:30 +00:00
|
|
|
# koreader applies these lua "patches" at boot:
|
|
|
|
# - <https://github.com/koreader/koreader/wiki/User-patches>
|
2023-12-15 20:52:47 +00:00
|
|
|
# the naming is IMPORTANT. these must start with a `2-` in order to be invoked during the right initialization phase
|
|
|
|
#
|
|
|
|
# 2023/10/29: koreader code hasn't changed, but somehow FTP browser seems usable even without the isConnected patch now.
|
2023-10-30 01:52:47 +00:00
|
|
|
# fs.".config/koreader/patches/2-colin-NetworkManager-isConnected.lua".symlink.target = "${./2-colin-NetworkManager-isConnected.lua}";
|
2023-06-19 09:21:30 +00:00
|
|
|
|
2023-12-15 20:52:47 +00:00
|
|
|
fs.".config/koreader/patches/2-02-colin-impl-clipboard-ops.lua".symlink.target = "${./2-02-colin-impl-clipboard-ops.lua}";
|
|
|
|
|
2023-06-20 19:58:02 +00:00
|
|
|
# koreader news plugin, enabled by default. file format described here:
|
|
|
|
# - <repo:koreader/koreader:plugins/newsdownloader.koplugin/feed_config.lua>
|
|
|
|
fs.".config/koreader/news/feed_config.lua".symlink.text = ''
|
|
|
|
return {--do NOT change this line
|
|
|
|
${lib.concatStringsSep ",\n " koreaderRssEntries}
|
|
|
|
}--do NOT change this line
|
|
|
|
'';
|
2023-10-28 01:49:16 +00:00
|
|
|
# easier to navigate via filebrowser than finding the news menu entry
|
|
|
|
fs."Books/rss-koreader".symlink.target = "../.config/koreader/news";
|
2023-06-20 19:58:02 +00:00
|
|
|
|
2023-06-19 09:21:30 +00:00
|
|
|
# koreader on aarch64 errors if there's no fonts directory (sandboxing thing, i guess)
|
|
|
|
fs.".local/share/fonts".dir = {};
|
|
|
|
|
|
|
|
# history, cache, dictionaries...
|
|
|
|
# could be more explicit if i symlinked the history.lua file to somewhere it can persist better.
|
2023-11-08 15:32:50 +00:00
|
|
|
persist.byStore.plaintext = [ ".config/koreader" ];
|
2023-06-19 09:21:30 +00:00
|
|
|
};
|
|
|
|
}
|