aboutsummaryrefslogtreecommitdiff
path: root/modules/redux/koreader.nix
blob: 1c885a89f02e47fee7c6287f22fd4a6b7521713e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{ 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"
      ];
    };
  };
}