{ config, pkgs, lib, ... }: with builtins // lib; let cfg = config.kobo; ini = pkgs.formats.ini {}; in { options.kobo = { enable = mkEnableOption "main configurations"; path = mkOption { type = types.str; readOnly = true; internal = true; default = ".kobo/Kobo"; }; devicePath = mkOption { type = types.str; readOnly = true; internal = true; default = "/mnt/onboard/${cfg.path}"; }; file = mkOption { default = {}; type = types.attrsOf (types.submodule (pkgs.callPackage ../lib/file-type.nix {})); apply = filterAttrs (_: v: v.enable); }; _allFiles = mkOption { type = types.package; readOnly = true; internal = true; default = pkgs.symlinkJoin { name = "kobo-files"; paths = mapAttrsToList (v: v._package) cfg.file; }; }; conf = mkOption { type = ini.type; default = {}; description = "https://wiki.mobileread.com/wiki/Kobo_Configuration_Options"; }; }; config = mkMerge [ { kobo = { conf = { FeatureSettings.ExcludeSyncFolders = ''(\.(?!kobo|adobe).+|([^.][^/]*/)+\..+)''; ApplicationPreferences = { SideloadedMode = true; QuickTourShown = true; }; }; file = mkIf (cfg.conf != {}) { "Kobo eReader.conf".text = generators.toINI {} cfg.conf; }; }; } (mkIf cfg.enable { koboroot.include = singleton (pkgs.linkFarm [{ name = cfg.devicePath; path = cfg._allFiles; }]); }) ]; }