aboutsummaryrefslogtreecommitdiff
path: root/modules/koreader.nix
blob: 5bcca42c044d03b622be1edca5149a42c6985130 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
{ config, pkgs, lib, options, ... }:
with builtins // lib;
let
  cfg = config.koreader;
  importOption = p: (import p { inherit pkgs lib; } cfg.path).option;
in {
  options.koreader = {
    enable = mkEnableOption "KOReader";

    path = mkOption {
      type = types.str;
      default = ".adds/koreader";
      description = "Relative path to KOReader within src";
    };

    devPath = mkOption {
      type = types.str;
      default = "/mnt/onboard/${cfg.path}";
      readOnly = true;
      internal = true;
    };

    nickelEntry = mkEnableOption "Launch KOReader directly via nickelMenu";

    file = importOption ./lib/file.nix;
    manifest = importOption ./lib/manifest.nix;

    # 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.item = mkIf cfg.nickelEntry {
      koreader = singleton {
        location = "main";
        label = "KOReader";
        action = "cmd_spawn";
        arg = [
          "quiet"
          "exec ${cfg.devPath}/koreader.sh"
        ];
      };
    };
  };
}