aboutsummaryrefslogtreecommitdiff
path: root/modules/koreader.nix
blob: 0a7300a406145fa5cd539531b8860d1ae58e4401 (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
{ 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";
    };

    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"
        ];
      };
    };
  };
}