aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/default.nix44
-rw-r--r--config/nickel.nix21
-rw-r--r--config/plato.nix44
-rw-r--r--config/screensaver.nix11
-rw-r--r--config/screensaver.pngbin0 -> 2718976 bytes
-rw-r--r--modules/builder.nix (renamed from modules/redux/builder.nix)0
-rw-r--r--modules/file.nix (renamed from modules/redux/file.nix)4
-rw-r--r--modules/installScript.nix75
-rw-r--r--modules/installer.nix7
-rw-r--r--modules/kfmon.nix29
-rw-r--r--modules/kobo.nix116
-rw-r--r--modules/koreader.nix41
-rw-r--r--modules/manifest.nix38
-rw-r--r--modules/nickel.nix143
-rw-r--r--modules/plato.nix366
-rw-r--r--modules/redux/kfmon.nix30
-rw-r--r--modules/redux/koreader.nix42
-rw-r--r--modules/redux/nickle.nix41
-rw-r--r--modules/redux/plato.nix179
19 files changed, 620 insertions, 611 deletions
diff --git a/config/default.nix b/config/default.nix
index 4c9688a..6da8197 100644
--- a/config/default.nix
+++ b/config/default.nix
@@ -1,41 +1,7 @@
-{ config, pkgs, lib, ... }:
-with builtins // lib;
{
- kfmon.enable = true;
- koreader.enable = true;
-
- plato = {
- enable = true;
-
- fonts.packages = [
- pkgs.hack-font
- ];
-
- dictionaries.packages = with pkgs.dictdDBs; [
- wordnet
- wiktionary
- ];
-
- settings = {
- keyboard-layout = "English";
- frontlight = true;
- wifi = false;
- sleep-cover = true;
- auto-share = true;
- auto-suspend = 15.0;
- auto-power-off = 4.0;
- time-format = "%I:%M%P";
- intermissions = {
- suspend = "cover:";
- power-off = "cover:";
- share = "logo:";
- };
- reader = {
- font-size = 10.0;
- };
- dictionary = {
- font-size = 10.0;
- };
- };
- };
+ imports = [
+ ./nickel.nix
+ ./plato.nix
+ ./screensaver.nix
+ ];
}
diff --git a/config/nickel.nix b/config/nickel.nix
new file mode 100644
index 0000000..5e62fc6
--- /dev/null
+++ b/config/nickel.nix
@@ -0,0 +1,21 @@
+{ config, pkgs, lib, ... }:
+with builtins // lib;
+{
+ nickel = {
+ enable = true;
+
+ menu.item = {
+ settings = [
+ {
+ location = "main";
+ label = "IP Address";
+ action = "cmd_output";
+ arg = [
+ "500"
+ "/sbin/ifconfg | /usr/bin/awk '/inet addr/{print substr($2,6)}'"
+ ];
+ }
+ ];
+ };
+ };
+}
diff --git a/config/plato.nix b/config/plato.nix
new file mode 100644
index 0000000..16531b3
--- /dev/null
+++ b/config/plato.nix
@@ -0,0 +1,44 @@
+{ config, pkgs, lib, ... }:
+with builtins // lib;
+{
+ # kfmon.enable = true;
+ # koreader.enable = true;
+
+ plato = {
+ enable = true;
+
+ fonts.packages = [
+ # pkgs.atkinson-hyperlegible
+ pkgs.fira-math
+ ];
+
+ dictionaries.packages = with pkgs.dictdDBs; [
+ wordnet
+ wiktionary
+ ];
+
+ settings = {
+ keyboard-layout = "English";
+ frontlight = true;
+ wifi = false;
+ sleep-cover = true;
+ auto-share = true;
+ auto-suspend = 15.0;
+ auto-power-off = 4.0;
+ time-format = "%I:%M%P";
+ # intermissions = {
+ # suspend = "cover:";
+ # power-off = "cover:";
+ # share = "logo:";
+ # };
+ reader = {
+ font-size = 10.0;
+ font-family = "Fira Math";
+ # font-family = "Atkinson Hyperlegible";
+ };
+ dictionary = {
+ font-size = 10.0;
+ };
+ };
+ };
+}
diff --git a/config/screensaver.nix b/config/screensaver.nix
new file mode 100644
index 0000000..2706202
--- /dev/null
+++ b/config/screensaver.nix
@@ -0,0 +1,11 @@
+{ config, pkgs, lib, ... }:
+with builtins // lib;
+{
+ file.".kobo/screensaver/main.png".source = ./screensaver.png;
+
+ plato.settings.intermissions = rec {
+ suspend = "cover:";
+ power-off = "/mnt/onboard/.kobo/screensaver/main.png";
+ share = power-off;
+ };
+}
diff --git a/config/screensaver.png b/config/screensaver.png
new file mode 100644
index 0000000..c26ab78
--- /dev/null
+++ b/config/screensaver.png
Binary files differ
diff --git a/modules/redux/builder.nix b/modules/builder.nix
index 5f74a1e..5f74a1e 100644
--- a/modules/redux/builder.nix
+++ b/modules/builder.nix
diff --git a/modules/redux/file.nix b/modules/file.nix
index e05318d..a52fb84 100644
--- a/modules/redux/file.nix
+++ b/modules/file.nix
@@ -19,7 +19,9 @@ in {
directory = mkOption {
type = types.bool;
default = false;
- description = "Enable this if the source file is a directory";
+ description = ''
+ Enable this if the source file is a directory. Note that directories are copied first when forming the source
+ '';
};
source = mkOption {
type = types.path;
diff --git a/modules/installScript.nix b/modules/installScript.nix
new file mode 100644
index 0000000..1e5e355
--- /dev/null
+++ b/modules/installScript.nix
@@ -0,0 +1,75 @@
+{ writeShellApplication
+, coreutils
+, util-linux
+, lib
+
+, koboInput
+, koboLabel ? "KOBOeReader"
+, koboManifest ? {}
+, ... }:
+with builtins // lib;
+let
+ manValues = attrValues koboManifest;
+ createMergeTool = local: remote: name: mergeTool: {
+ inherit name;
+ value = mergeTool "${local}/${name}" "${remote}/${name}";
+ };
+ collectMergeTools = local: remote: xs: listToAttrs (concatMap (v: map (name: createMergeTool local remote name v.mergeTool) v.targets) xs);
+ onDevManifest = local: remote: collectMergeTools local remote (filter (v: v.remoteOnly) manValues;
+ manifest = local: remote: collectMergeTools local remote (filter (v: ! v.remoteOnly) manValues);
+
+ execApp = writeShellApplication {
+ name = "kobo-exec";
+ runtimeInputs = [
+ coreutils
+ ];
+ text = ''
+ REMOTE_OR_LOCAL="''${1-}"
+ KOBO_DIR="''${2-}"
+ FILE="''${3-}"
+
+ if [[ "$REMOTE_OR_LOCAL" == "REMOTE" ]]; then
+ ${toShellVar "MANIFEST" (onDevManifest ${koboInput} "$KOBO_DIR")}
+ FILEBASE="''${FILE/#$KOBO_DIR}"
+ else
+ ${toShellVar "MANIFEST" (manifest ${koboInput} "$KOBO_DIR")}
+ FILEBASE="''${FILE/#${koboInput}}"
+ fi
+
+ ACTION="''${MANIFEST["$FILEBASE"]}"
+
+ if [[ -n "$ACTION" ]]; then
+ eval "$ACTION"
+ elif [[ "$REMOTE_OR_LOCAL" == "LOCAL" ]]; then
+ if [[ -d "$FILE" ]]; then
+ mkdir -p "$KOBO_DIR/$FILEBASE"
+ else
+ cp -v "$FILE" "$KOBO_DIR/$FILEBASE"
+ fi
+ fi
+ '';
+ };
+in writeShellApplication {
+ name = "KoboInstaller";
+ runtimeInputs = [
+ coreutils
+ util-linux
+ ];
+ text = ''
+ KOBO_MOUNTPOINT="$(findmnt -nlo TARGET LABEL="${koboLabel}")"
+ if [[ -z "$KOBO_MOUNTPOINT" ]]; then
+ echo "Couldn't find a Kobo eReader volume with label ${koboLabel}. Are you sure one is actually mounted?"
+ exit 255
+ fi
+
+ KOBO_DIR="$KOBO_MOUNTPOINT/.kobo"
+ if [[ ! -d "$KOBO_DIR" ]]; then
+ echo "It doesn't seem like $KOBO_MOUNTPOINT actually points to a Kobo eReader since it doesn't contain a .kobo directory . . . "
+ exit 255
+ fi
+
+ find "$KOBO_DIR/" -not -path "$KOBO_DIR/" -exec ${execApp}/bin/kobo-exec "REMOTE" "$KOBO_DIR" {} \;
+
+ find "${koboInput}/" -not -path "${koboInput}/" -exec ${execApp}/bin/kobo-exec "LOCAL" "$KOBO_DIR" {} \;
+ '';
+}
diff --git a/modules/installer.nix b/modules/installer.nix
index f5c93ba..2fcc546 100644
--- a/modules/installer.nix
+++ b/modules/installer.nix
@@ -8,9 +8,12 @@ in {
];
options.installer = {
- package = mkPackageOption pkgs [ "kobo" "install" ] // {
- apply = x: x.override {
+ package = mkOption {
+ type = types.package;
+ default = pkgs.callpackage ./installScript.nix {
+ koboInput = null;
koboLabel = cfg.koboLabel;
+ koboManifest = config.manifest;
};
};
diff --git a/modules/kfmon.nix b/modules/kfmon.nix
index f47433e..772a10b 100644
--- a/modules/kfmon.nix
+++ b/modules/kfmon.nix
@@ -1,21 +1,30 @@
-{ config, pkgs, lib, ... }:
+{ config, pkgs, lib, options, ... }:
with builtins // lib;
let
cfg = config.kfmon;
in {
options.kfmon = {
- enable = mkEnableOption "koreader";
-
- generate = mkOption {
- type = types.lines;
- default = "";
- description = "Script used to generate the KFMon config";
- };
+ enable = mkEnableOption "KFMon";
path = mkOption {
type = types.str;
- default = ".adds/koreader";
- description = "Releative path to KFMon within src";
+ default = ".adds/kfmon";
+ description = "Relative path to kfmon within src";
+ };
+
+ file = mkOption {
+ type = options.file.type;
+ default = {};
+ description = "Files relative to ${cfg.path}";
};
};
+
+ config = mkIf cfg.enable {
+ file = mapAttrs' (n: v: {
+ name = "kfmon-${n}";
+ value = v // {
+ target = "${cfg.path}/${v.target}";
+ };
+ }) cfg.file
+ };
}
diff --git a/modules/kobo.nix b/modules/kobo.nix
index d46da7e..21f7995 100644
--- a/modules/kobo.nix
+++ b/modules/kobo.nix
@@ -1,61 +1,85 @@
-{ config, pkgs, lib, ... }:
+{ config, pkgs, lib, options, ... }:
with builtins // lib;
let
cfg = config.kobo;
+ ini = pkgs.formats.ini {};
in {
- imports = [
- ./kfmon.nix
- ./koreader.nix
- ./plato.nix
- ];
-
options.kobo = {
- package = mkOption {
- type = types.package;
- description = "The resulting kobo configuration";
- default = if cfg.generate == "" then cfg.src else pkgs.stdenvNoCC.mkDerivation {
- inherit (cfg) src;
- name = "kobo-config";
-
- dontBuild = true;
- dontFixup = true;
- dontConfigure = true;
- dontPatch = true;
-
- installPhase = ''
- mkdir -p $out
- cp -rv . $out
-
- ${cfg.generate}
- '';
- };
+ enable = mkEnableOption "main configurations";
+
+ path = mkOption {
+ type = types.str;
+ default = ".kobo/Kobo";
+ description = "Relative path to main Kobo config";
+ };
+
+ file = mkOption {
+ type = options.file.type;
+ default = {};
+ description = "Files relative to ${cfg.path}";
};
- src = mkOption {
- type = types.package;
- description = "The base source files to use";
- default = with pkgs.kobo.src;
- if config.plato.enable && config.koreader.enable then KOReader-Plato
- else if config.plato.enable then Plato
- else if config.koreader.enable then KOReader
- else if config.kfmon.enable then KFMon
- else error "At least one of plato, koreader or kfmon must be enabled in order to use a default package";
+ manifest = mkOption {
+ type = options.manifest.type;
+ default = {};
+ description = "Manifest relative to ${cfg.path}";
};
- generate = mkOption {
- type = types.lines;
- default = "";
- description = "Script used to generate the kobo config";
+ config = mkOption {
+ type = ini.type;
+ default = {};
+ description = "https://wiki.mobileread.com/wiki/Kobo_Configuration_Options";
};
+
+ # src = mkOption {
+ # type = types.package;
+ # description = "The base source files to use";
+ # default = with pkgs.kobo.src;
+ # if config.plato.enable && config.koreader.enable then KOReader-Plato
+ # else if config.plato.enable then Plato
+ # else if config.koreader.enable then KOReader
+ # else if config.kfmon.enable then KFMon
+ # else error "At least one of plato, koreader or kfmon must be enabled in order to use a default package";
+ # };
+
};
config = {
+ file = mapAttrs' (n: v: {
+ name = "kobo-${n}";
+ value = v // {
+ target = "${cfg.path}/${v.target}";
+ };
+ }) cfg.file;
+
+ manifest = mapAttrs' (n: v: {
+ name = "kobo-${n}";
+ value = v // {
+ targets = map (x: "${cfg.path}/${x}") v.targets;
+ };
+ }) cfg.manifest;
+
kobo = {
- generate = mkBefore (concatStringsSep "\n" (
- optional config.kfmon.enable config.kfmon.generate ++
- optional config.plato.enable config.plato.generate ++
- optional config.koreader.enable config.koreader.generate
- ));
+ config = {
+ FeatureSettings = {
+ ExcludeSyncFolders = ''(\.(?!kobo|adobe).+|([^.][^/]*/)+\..+)'';
+ };
+ ApplicationPreferences = {
+ QuickTourShown = true;
+ };
+ };
+ file = mkMerge [
+ (mkIf (cfg.config != {}) {
+ "Kobo eReader.conf".text = generators.toINI {} cfg.config;
+ })
+ ];
+
+ manifest = {
+ "Kobo eReader.conf".mergeTool = local: remote: ''
+ ${getBin pkgs.crudini}/bin/crudini --merge "${remote}" < "${local}" > "${remote}"
+ '';
+ };
};
- };
-}
+
+
+ }
diff --git a/modules/koreader.nix b/modules/koreader.nix
index b4b6551..0a7300a 100644
--- a/modules/koreader.nix
+++ b/modules/koreader.nix
@@ -1,21 +1,44 @@
-{ config, pkgs, lib, ... }:
+{ config, pkgs, lib, options, ... }:
with builtins // lib;
let
cfg = config.koreader;
in {
options.koreader = {
- enable = mkEnableOption "koreader";
-
- generate = mkOption {
- type = types.lines;
- default = "";
- description = "Script used to generate the KOReader config";
- };
+ enable = mkEnableOption "KOReader";
path = mkOption {
type = types.str;
default = ".adds/koreader";
- description = "Releative path to KOReader within src";
+ description = "Relative path to KOReader within src";
+ };
+
+ nickelEntry = mkEnableOption "Launch KOReader directly via nickelMenu";
+
+ file = mkOption {
+ type = options.file.type;
+ default = {};
+ description = "Files relative to ${cfg.path}";
+ };
+ };
+
+ config = mkIf cfg.enable {
+ file = mapAttrs' (n: v: {
+ name = "koreader-${n}";
+ value = v // {
+ target = "${cfg.path}/${v.target}";
+ };
+ }) cfg.file
+
+ nickel.menu.items = mkIf cfg.nickelEntry {
+ koreader = singleton {
+ location = "main";
+ label = "KOReader";
+ action = "cmd_spawn";
+ arg = [
+ "quiet"
+ "exec /mnt/onboard/${cfg.path}/koreader.sh"
+ ];
+ };
};
};
}
diff --git a/modules/manifest.nix b/modules/manifest.nix
new file mode 100644
index 0000000..718ffb4
--- /dev/null
+++ b/modules/manifest.nix
@@ -0,0 +1,38 @@
+{ config, pkgs, lib, ... }:
+with builtins // lib;
+let
+ cfg = config.manifest;
+in {
+ options.manifest = mkOption {
+ default = {};
+ type = with types; attrsOf (submodule ({ name, config, ... }: {
+ options = {
+ enable = mkEnableOption name // { default = true; };
+ targets = mkOption {
+ type = with types; listOf str;
+ default = [ name ];
+ };
+ mergeTool = mkOption {
+ type = with types; functionTo (functionTo str);
+ description = ''
+ Sometimes we don't just want to overwrite the existing kobo file; instead we need to merge them.
+ This is the executable which does this.
+ The first argument is the local file and the second is the kobo file.
+ Note that the local file path and the kobo file path only disagree in their top-level directory and otherwise are the same path.
+ '';
+ example = ''
+ localFile: koboFile: "cp ''${localFile} ''${koboFile}"
+ '';
+ };
+ remoteOnly = mkOption {
+ type = types.bool
+ default = false;
+ description = ''
+ In general, the manifest only considers local files that match the target/pattern.
+ Setting this to true means that the kobo files will be scanned and the provided mergeTool will be run with the first argument set to null.
+ '';
+ };
+ };
+ }));
+ };
+}
diff --git a/modules/nickel.nix b/modules/nickel.nix
new file mode 100644
index 0000000..948dbaf
--- /dev/null
+++ b/modules/nickel.nix
@@ -0,0 +1,143 @@
+{ config, pkgs, lib, options, ... }:
+with builtins // lib;
+let
+ cfg = config.nickel;
+ action = mkOption {
+ type = types.enum [
+ "cmd_spawn"
+ "cmd_output"
+ "dbg_syslog"
+ "dbg_error"
+ "dbg_msg"
+ "dbg_toast"
+ "kfmon"
+ "nickel_setting"
+ "nickel_extras"
+ "nickel_browser"
+ "nickel_misc"
+ "nickel_open"
+ "nickel_wifi"
+ "nickel_orientation"
+ "power"
+ "skip"
+ ];
+ };
+ location = mkOption {
+ type = types.enum [
+ "main"
+ "reader"
+ "browser"
+ "library"
+ "selection"
+ ];
+ };
+
+ createChainItem = { when, action, arg, ... }: concatStringsSep " : " ([ "chain_${when}" action ] ++ arg);
+ createMenuItem = { location, label, action, arg, chain, ... }: concatStringsSep "\n" (
+ singleton (
+ concatStringsSep " : " ([ "menu_item" location label action ] ++ arg)
+ ) ++ (map createChainItem chain)
+ );
+
+ createExperimental = k: v: "experimental : ${k} : ${v}";
+
+ createGenerator = { location, generator }: concatStringsSep " : " (
+ [ "generator" ] ++
+ (if isInt generator then [ "_test" (toString generator) ]
+ else splitString " " generator)
+ );
+
+in {
+ options.nickel = {
+ enable = mkEnableOption "nickelMenu";
+
+ path = mkOption {
+ type = types.str;
+ default = ".adds/nm";
+ description = "Relative path to nickelMenu within src";
+ };
+
+ file = mkOption {
+ type = options.file.type;
+ default = {};
+ description = "Files relative to ${cfg.path}";
+ };
+
+ menu = {
+ item = mkOption {
+ default = {};
+ description = "https://github.com/pgaskin/NickelMenu/blob/v0.5.4/res/doc";
+ type = with types; attrsOf (listOf (submodule {
+ options = {
+ inherit action location;
+ label = mkOption {
+ type = types.str;
+ };
+ arg = mkOption {
+ type = with types; nonEmptyListOf str;
+ };
+ chain = mkOption {
+ default = [];
+ type = with types; listOf (submodule {
+ options = {
+ when = mkOption {
+ type = types.enum [ "success" "failure" "always" ];
+ };
+ inherit action;
+ arg = mkOption {
+ type = with types; nonEmptyListOf str;
+ };
+ };
+ });
+ };
+ };
+ }));
+ };
+
+ experimental = mkOption {
+ default = {};
+ description = "https://github.com/pgaskin/NickelMenu/blob/v0.5.4/res/doc";
+ type = with types; attrsOf (attrsOf str);
+ };
+
+ generator = mkOption {
+ default = {};
+ description = "https://github.com/pgaskin/NickelMenu/blob/v0.5.4/res/doc";
+ type = with types; attrsOf (listOf (submodule {
+ options = {
+ inherit location;
+ generator = mkOption {
+ type = with types; either (enum [ "kfmon" "kfmon all" "kfmon gui" ]) (ints.between 0 10);
+ default = "kfmon";
+ };
+ };
+ }));
+ };
+ };
+ };
+
+ config = mkIf cfg.enable {
+ nickel = {
+ file = mkMerge [
+ (mapAttrs (_: v: {
+ text = concatMapStringsSep "\n" createGenerator v;
+ }) cfg.menu.generator)
+
+ (mapAttrs (_: v: {
+ text = concatStringsSep "\n" (mapAttrsToList createExperimental v);
+ }) cfg.menu.experimental)
+
+ (mapAttrs (_: v: {
+ text = concatMapStringsSep "\n" createMenuItem v;
+ }) cfg.menu.item)
+ ];
+ };
+
+ file = mapAttrs' (n: v: {
+ name = "nm-${n}";
+ value = v // {
+ target = "${cfg.path}/${v.target}";
+ };
+ }) cfg.file
+ };
+}
diff --git a/modules/plato.nix b/modules/plato.nix
index afa7486..f274f00 100644
--- a/modules/plato.nix
+++ b/modules/plato.nix
@@ -1,36 +1,35 @@
-{ config, pkgs, lib, ... }:
+{ config, pkgs, lib, options, ... }:
with builtins // lib;
let
cfg = config.plato;
toml = pkgs.formats.toml {};
-
- bashList = concatMapStringsSep " " (x: ''"${toString x}"'');
-
in {
- options.plato = {
- enable = mkEnableOption "plato";
-
- # package = mkOption {
- # type = types.package;
- # readOnly = true;
- # default = pkgs.runCommand "generate-plato" cfg.generate;
- # };
-
- # src = mkPackageOption pkgs [ "kobo" "plato" ] {};
+ imports = [
+ ./nickel.nix
+ ];
- generate = mkOption {
- type = types.lines;
- default = "";
- description = "Script used to generate the Plato config";
- };
+ options.plato = {
+ enable = mkEnableOpiton "Plato";
path = mkOption {
- type = types.str;
+ type = types.srt;
default = ".adds/plato";
description = "Relative path to Plato within src";
};
- hyphenation = mkEnableOption "hyphenation" // { default = true; };
+ file = mkOption {
+ type = options.file.type;
+ default = {};
+ description = "Files relative to ${cfg.path}";
+ };
+
+ manifest = mkOption {
+ type = options.manifest.type;
+ default = {};
+ description = "Manifest relative to ${cfg.path}";
+ };
+
+ nickelEntry = mkEnableOption "Launch Plato directly from nickelMenu";
config = mkOption {
type = types.lines;
@@ -38,220 +37,163 @@ in {
description = "Plato config.sh";
};
+ hyphenation = mkEnableOption "hyphenation" // { default = true; };
+
+ convertDictionaries = mkEnableOption "convert StarDict" // { default = true; };
+
+ setFramebufferDepth = mkEnableOption "set framebuffer's depth" // { default = true; };
+
settings = mkOption {
type = toml.type;
default = {};
description = "Plato Settings.toml";
};
- dictionaries = {
- packages = mkOption {
- type = with types; listOf package;
- default = [];
- # default = with pkgs.dictdDBs; [
- # wordnet
- # wiktionary
- # ];
- description = "Dictionaries to install with plato";
- };
-
- sporadic = mkOption {
- type = with types; listOf str;
- default = [];
- description = "Extra paths to dictionary files";
- };
+ css = mkOption {
+ default = {};
+ type = with types; attrsOf lines;
+ description = ''
+ css style sheets.
+ Only use this for epub-user dictionary-user html-user
+ '';
+ };
- remove = mkOption {
- type = with types; listOf str;
- default = [];
- description = "Remote these dictionaries from plato";
- };
+ scripts = mkOption {
+ default = {};
+ type = with types; attrsOf lines;
+ description = ''
+ Only use this for wifi-post-up wifi-post-down wifi-pre-up wifi-pre-down.
+ '';
+ # apply = mapAttrs (_: text: ''
+ # #!/bin/sh
- generate = mkOption {
- type = types.lines;
- default = "";
- description = "Script used to setup dictionaries";
- };
+ # ${text}
+ # '')
};
- fonts = {
- packages = mkOption {
- type = with types; listOf package;
- default = [];
- description = "Fonts to install for plato";
- };
+ dictionaries = mkOption {
+ type = with types; listOf package;
+ default = [];
+ };
- sporadic = mkOption {
- type = with types; listOf str;
- default = [];
- description = "Extra paths to font files";
- };
+ allDictionaries = mkOption {
+ type = types.package;
+ readOnly = true;
+ internal = true;
+ default = pkgs.runCommand "PlatoDictionaries" {} (''
+ mkdir -p $out
+ '' + concatMapStringsSep "\n" (pkg: ''
+ find ${pkg}/share/dictd/ -type f -regex '.*\.\(dict\(\.dz\)?\|index\)' -exec cp -v {} $out/ \;
+ '') cfg.dictionaries
+ );
- remove = mkOption {
- type = with types; listOf str;
- default = [];
- description = "Remove these fonts from plato";
- };
+ };
- generate = mkOption {
- type = types.lines;
- default = "";
- description = "Script used to setup fonts";
- };
+ fonts = mkOption {
+ type = with types; listOf package;
+ default = [];
};
- css = {
- epub = mkOption {
- type = types.lines;
- default = "";
- description = "epub css";
- };
- html = mkOption {
- type = types.lines;
- default = "";
- description = "html css";
- };
- dictionary = mkOption {
- type = types.lines;
- default = "";
- description = "dictionary css";
- };
+ allFonts = mkOption {
+ type = types.package;
+ readOnly = true;
+ internal = true;
+ default = pkgs.runCommand "PlatoFonts" {} (''
+ mkdir -p $out
+ '' + concatMapStringsSep "\n" (pkg: ''
+ find ${pkg}/share/fonts/truetype/ -type f -regex '.*\.\(ttf\|otf\)' -exec cp -v {} $out/ \;
+ '') cfg.fonts
+ );
- generate = mkOption {
- type = types.lines;
- default = "";
- description = "Script used to setup css files";
- };
};
+ };
- wifi = {
- up = {
- pre = mkOption {
- type = types.lines;
- default = "";
- };
- post = mkOption {
- type = types.lines;
- default = "";
- };
+ config = mkIf cfg.enable {
+ plato = {
+ config = concatStringsSep "\n\n" (
+ optional (!cfg.convertDictionaries) ''
+ unset PLATO_CONVERT_DICTIONARIES
+ ''
+ ++
+ optional (!cfg.setFramebufferDepth) ''
+ unset PLATO_SET_FRAMEBUFFER_DEPTH
+ ''
+ ++
+ optional (!cfg.hyphenation) ''
+ [ -d hyphenation-patterns ] && rm -rf hyphenation-patterns
+ ''
+ );
+ file = mkMerge [
+ (mkIf (cfg.settings != {}) {
+ "Settings.toml".source = toml.generate "Settings.toml" cfg.settings;
+ })
+
+ (mkIf (cfg.config != "") {
+ "config.sh".text = cfg.config;
+ })
+
+ (mapAttrs' (n: text:
+ let
+ n1 = if hasPrefix "css/" n then n else "css/${n}";
+ name = if hasSuffix ".css" n1 then n1 else "{n1}.css";
+ in {
+ inherit name;
+ value = { inherit text; }
+ }) cfg.css)
+
+ (mapAttrs' (n: t:
+ let
+ n1 = if hasPrefix "scripts/" n then n else "scripts/${n}";
+ name = if hasSuffix ".sh" n1 then n1 else "${n1}.sh";
+ text = if hasPrefix "#!/" t then t else "#!/bin/sh\n\n${t}";
+ in {
+ inherit name;
+ value = { inherit text; };
+ }) cfg.scripts)
+
+ {
+ dictionaries = {
+ directory = true;
+ source = cfg.allDictionaries;
+ };
+ fonts = {
+ directory = true;
+ source = cfg.allFonts;
+ };
+ }
+ ];
+
+ manifest = {
+ "config-sample.sh".mergeTool = _: _: "echo 'not copying config-sample.sh'";
+ "Settings-sample.toml".mergeTool = _: _: "echo 'not copying Settings-sample.toml'";
};
- down = {
- pre = mkOption {
- type = types.lines;
- default = "";
- };
- post = mkOption {
- type = types.lines;
- default = "";
- };
+ };
+
+ file = mapAttrs' (n: v: {
+ name = "plato-${n}";
+ value = v // {
+ target = "${cfg.path}/${v.target}";
};
+ }) cfg.file;
- generate = mkOption {
- type = types.lines;
- default = "";
- description = "Script used to setup wifi scripts";
+ manifest = mapAttrs' (n: v: {
+ name = "plato-${n}";
+ value = v // {
+ targets = map (x: "${cfg.path}/${x}") v.targets;
+ };
+ }) cfg.manifest;
+
+ nickel.menu.item = mkIf cfg.nickelEntry {
+ plato = singleton {
+ location = "main";
+ label = "Plato";
+ action = "cmd_spawn";
+ arg = [
+ "quiet"
+ "exec /mnt/onboard/${cfg.path}/plato.sh"
+ ];
};
};
};
-
- config.plato = {
- config = optionalString (!cfg.hyphenation) ''
- [ -d hyphenation-patterns ] && rm -rf hyphenation-patterns
- '';
-
- dictionaries.generate = mkBefore ''
- mkdir -pv $out/${cfg.path}/dictionaries
-
- ${optionalString (cfg.dictionaries.packages != []) ''
- echo "Adding dictionaries from packages..."
- for d in ${bashList cfg.dictionaries.packages}; do
- find $d/share/dictd/ -type f -regex '.*\.\(dict\(\.dz\)?\|index\)' -exec cp -v {} $out/${cfg.path}/dictionaries/ \;
- done
- ''}
-
- ${optionalString (cfg.dictionaries.sporadic != []) ''
- echo "Adding sporadic dictionaries..."
- for p in ${bashList cfg.dictionaries.sporadic}; do
- cp -v "$p" $out/${cfg.path}/dictionaries/
- done
- ''}
-
- ${optionalString (cfg.dictionaries.remove != []) ''
- echo "Removing unwanted dictionaries..."
- for p in ${bashList cfg.dictionaries.remove}; do
- rm -f "$out/${cfg.path}/dictionaries/$p"
- done
- ''}
- '';
-
- fonts.generate = mkBefore ''
- mkdir -pv $out/${cfg.path}/fonts
-
- ${optionalString (cfg.fonts.packages != []) ''
- echo "Adding fonts from packages..."
- for d in ${concatMapStringsSep " " toString cfg.fonts.packages}; do
- find $d/share/fonts/truetype/ -type f -regex '.*\.\(ttf\|otf\)' -exec cp -v {} $out/${cfg.path}/fonts/ \;
- done
- ''}
-
- ${optionalString (cfg.fonts.sporadic != []) ''
- echo "Adding sporadic fonts"
- for p in ${concatMapStringsSep " " (x: ''"${x}"'') cfg.fonts.sporadic}; do
- cp -v "$p" $out/${cfg.path}/fonts/
- done
- ''}
-
- ${optionalString (cfg.fonts.remove != []) ''
- echo "Removing unwanted fonts..."
- for p in ${bashList cfg.fonts.remove}; do
- rm -f "$out/${cfg.path}/fonts/$p"
- done
- ''}
- '';
-
- css.generate = mkBefore ''
- ${optionalString (cfg.css.epub != "") ''
- cp -v ${writeText "epub-user.css" cfg.css.epub} $out/${cfg.path}/css/epub-user.css
- ''}
-
- ${optionalString (cfg.css.html != "") ''
- cp -v ${pkgs.writeText "html-user.css" cfg.css.html} $out/${cfg.path}/css/html-user.css
- ''}
-
- ${optionalString (cfg.css.dictionary != "") ''
- cp -v ${pkgs.writeText "dictionary-user.css" cfg.css.dictionary} $out/${cfg.path}/css/dictionary-user.css
- ''}
- '';
-
- wifi.generate =
- let
- mkWifi = t: p: optionalString (cfg.wifi.${t}.${p} != "") ''
- cp -v ${pkgs.writeScript "wifi-${p}-${t}.sh" "#!/bin/sh\n${cfg.wifi.${t}.${p}}"} $out/${cfg.path}/scripts/wifi-${p}-${t}.sh
- '';
- in mkBefore (
- concatMapStringsSep "\n" ({ t, p }: mkWifi t p) (cartesianProductOfSets { t = [ "up" "down" ]; p = [ "pre" "post" ]; })
- );
-
-
- generate = mkBefore ''
- mkdir -p $out/${cfg.path}
-
- ${cfg.dictionaries.generate}
-
- ${cfg.fonts.generate}
-
- ${cfg.css.generate}
-
- ${cfg.wifi.generate}
-
- ${optionalString (cfg.settings != {}) ''
- cp -v ${toml.generate "Settings.toml" cfg.settings} $out/${cfg.path}/Settings.toml
- ''}
-
- ${optionalString (cfg.config != "") ''
- cp -v ${pkgs.writeScript "config.sh" cfg.config} $out/${cfg.path}/config.sh
- ''}
- '';
- };
}
diff --git a/modules/redux/kfmon.nix b/modules/redux/kfmon.nix
deleted file mode 100644
index 772a10b..0000000
--- a/modules/redux/kfmon.nix
+++ /dev/null
@@ -1,30 +0,0 @@
-{ config, pkgs, lib, options, ... }:
-with builtins // lib;
-let
- cfg = config.kfmon;
-in {
- options.kfmon = {
- enable = mkEnableOption "KFMon";
-
- path = mkOption {
- type = types.str;
- default = ".adds/kfmon";
- description = "Relative path to kfmon within src";
- };
-
- file = mkOption {
- type = options.file.type;
- default = {};
- description = "Files relative to ${cfg.path}";
- };
- };
-
- config = mkIf cfg.enable {
- file = mapAttrs' (n: v: {
- name = "kfmon-${n}";
- value = v // {
- target = "${cfg.path}/${v.target}";
- };
- }) cfg.file
- };
-}
diff --git a/modules/redux/koreader.nix b/modules/redux/koreader.nix
deleted file mode 100644
index 1c885a8..0000000
--- a/modules/redux/koreader.nix
+++ /dev/null
@@ -1,42 +0,0 @@
-{ config, pkgs, lib, options, ... }:
-with builtins // lib;
-let
- cfg = config.koreader;
-in {
- options.koreader = {
- enable = mkEnableOption "KOReader";
-
- path = mkOption {
- type = types.str;
- default = ".adds/koreader";
- description = "Relative path to KOReader within src";
- };
-
- nickleEntry = mkEnableOption "Launch KOReader directly via NickleMenu";
-
- file = mkOption {
- type = options.file.type;
- default = {};
- description = "Files relative to ${cfg.path}";
- };
- };
-
- config = mkIf cfg.enable {
- file = mapAttrs' (n: v: {
- name = "koreader-${n}";
- value = v // {
- target = "${cfg.path}/${v.target}";
- };
- }) cfg.file
-
- nickle.menuItems = mkIf cfg.nickleEntry {
- "koreader" = [
- "main"
- "KOReader"
- "cmd_spawn"
- "quiet"
- "exec /mnt/onboard/${cfg.path}/koreader.sh"
- ];
- };
- };
-}
diff --git a/modules/redux/nickle.nix b/modules/redux/nickle.nix
deleted file mode 100644
index b08a6ec..0000000
--- a/modules/redux/nickle.nix
+++ /dev/null
@@ -1,41 +0,0 @@
-{ config, pkgs, lib, options, ... }:
-with builtins // lib;
-let
- cfg = config.nickle;
-in {
- options.nickle = {
- enable = mkEnableOption "NickleMenu";
-
- path = mkOption {
- type = types.str;
- default = ".adds/nm";
- description = "Relative path to NickleMenu within src";
- };
-
- file = mkOption {
- type = options.file.type;
- default = {};
- description = "Files relative to ${cfg.path}";
- };
-
- menuItems = mkOption {
- type = with types; attrsOf (listOf str);
- default = {};
- };
- };
-
- config = mkIf cfg.enable {
- nickle = {
- file = mapAttrs (_: v: {
- text = concatStringsSep " : " ([ "menu_item" ] ++ v)
- }) cfg.menuItems
- };
-
- file = mapAttrs' (n: v: {
- name = "nm-${n}";
- value = v // {
- target = "${cfg.path}/${v.target}";
- };
- }) cfg.file
- };
-}
diff --git a/modules/redux/plato.nix b/modules/redux/plato.nix
deleted file mode 100644
index 6735133..0000000
--- a/modules/redux/plato.nix
+++ /dev/null
@@ -1,179 +0,0 @@
-{ config, pkgs, lib, options, ... }:
-with builtins // lib;
-let
- cfg = config.plato;
- toml = pkgs.formats.toml {};
-in {
- imports = [
- ./nickle.nix
- ];
-
- options.plato = {
- enable = mkEnableOpiton "Plato";
-
- path = mkOption {
- type = types.srt;
- default = ".adds/plato";
- description = "Relative path to Plato within src";
- };
-
- file = mkOption {
- type = options.file.type;
- default = {};
- description = "Files relative to ${cfg.path}";
- };
-
- nickleEntry = mkEnableOption "Launch Plato directly from NickleMenu";
-
- config = mkOption {
- type = types.lines;
- default = "";
- description = "Plato config.sh";
- };
-
- hyphenation = mkEnableOption "hyphenation" // { default = true; };
-
- convertDictionaries = mkEnableOption "convert StarDict" // { default = true; };
-
- setFramebufferDepth = mkEnableOption "set framebuffer's depth" // { default = true; };
-
- settings = mkOption {
- type = toml.type;
- default = {};
- description = "Plato Settings.toml";
- };
-
- css = mkOption {
- default = {};
- type = with types; attrsOf lines;
- description = ''
- css style sheets.
- Only use this for epub-user dictionary-user html-user
- '';
- };
-
- scripts = mkOption {
- default = {};
- type = with types; attrsOf lines;
- description = ''
- Only use this for wifi-post-up wifi-post-down wifi-pre-up wifi-pre-down.
- '';
- # apply = mapAttrs (_: text: ''
- # #!/bin/sh
-
- # ${text}
- # '')
- };
-
- dictionaries = mkOption {
- type = with types; listOf package;
- default = [];
- };
-
- allDictionaries = mkOption {
- type = types.package;
- readOnly = true;
- internal = true;
- default = pkgs.runCommand "PlatoDictionaries" {} (''
- mkdir -p $out
- '' + concatMapStringsSep "\n" (pkg: ''
- find ${pkg}/share/dictd/ -type f -regex '.*\.\(dict\(\.dz\)?\|index\)' -exec cp -v {} $out/ \;
- '') cfg.dictionaries
- );
-
- };
-
- fonts = mkOption {
- type = with types; listOf package;
- default = [];
- };
-
- allFonts = mkOption {
- type = types.package;
- readOnly = true;
- internal = true;
- default = pkgs.runCommand "PlatoFonts" {} (''
- mkdir -p $out
- '' + concatMapStringsSep "\n" (pkg: ''
- find ${pkg}/share/fonts/truetype/ -type f -regex '.*\.\(ttf\|otf\)' -exec cp -v {} $out/ \;
- '') cfg.fonts
- );
-
- };
- };
-
- config = mkIf cfg.enable {
- plato = {
- config = concatStringsSep "\n\n" (
- optional (!cfg.convertDictionaries) ''
- unset PLATO_CONVERT_DICTIONARIES
- ''
- ++
- optional (!cfg.setFramebufferDepth) ''
- unset PLATO_SET_FRAMEBUFFER_DEPTH
- ''
- ++
- optional (!cfg.hyphenation) ''
- [ -d hyphenation-patterns ] && rm -rf hyphenation-patterns
- ''
- );
- file = mkMerge [
- (mkIf (cfg.settings != {}) {
- "Settings.toml".source = toml.generate "Settings.toml" cfg.settings;
- })
-
- (mkIf (cfg.config != "") {
- "config.sh".text = cfg.config;
- })
-
- (mapAttrs' (n: text:
- let
- n1 = if hasPrefix "css/" n then n else "css/${n}";
- name = if hasSuffix ".css" n1 then n1 else "{n1}.css";
- in {
- inherit name;
- value = { inherit text; }
- }) cfg.css)
-
- (mapAttrs' (n: t:
- let
- n1 = if hasPrefix "scripts/" n then n else "scripts/${n}";
- name = if hasSuffix ".sh" n1 then n1 else "${n1}.sh";
- text = if hasPrefix "#!/" t then t else "#!/bin/sh\n\n${t}";
- in {
- inherit name;
- value = { inherit text; };
- }) cfg.scripts)
-
- {
- dictionaries = {
- directory = true;
- source = cfg.allDictionaries;
- };
- fonts = {
- directory = true;
- source = cfg.allFonts;
- };
- }
- ];
- };
-
- file = mapAttrs' (n: v: {
- name = "plato-${n}";
- value = v // {
- target = "${cfg.path}/${v.target}";
- };
- }) cfg.file;
-
- nickle.menuItems = mkIf cfg.nickleEntry {
- "plato" = [
- "main"
- "Plato"
- "cmd_spawn"
- "quiet"
- "exec /mnt/onboard/${cfg.path}/plato.sh"
- ];
- }
-
- };
-}