{ 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}"; }; _createdFiles = mkOption { type = types.package; internal = true; readOnly = true; default = pkgs.buildEnv { name = "kobo-files-created"; paths = mapAttrsToList (_: v: v._package) cfg.file; extraPrefix = cfg.devicePath; }; }; finalPackage = mkOption { type = types.package; internal = true; readOnly = true; default = pkgs.mergePaths { name = "kobo-package"; paths = [ cfg._createdFiles ]; }; }; 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 = { "Kobo eReader.conf" = mkIf (cfg.conf != {}) { text = generators.toINI {} cfg.conf; }; }; }; } (mkIf cfg.enable { koboroot.include = singleton cfg.finalPackage; }) ]; }