fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
2.2 KiB80 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.programs.sioyek;
8
9  renderConfig = generators.toKeyValue {
10    mkKeyValue = key: value: "${key} ${value}";
11    listsAsDuplicateKeys = true;
12  };
13
14in {
15  options = {
16    programs.sioyek = {
17      enable = mkEnableOption
18        "Sioyek, a PDF viewer designed for reading research papers and technical books";
19
20      package = mkOption {
21        default = pkgs.sioyek;
22        defaultText = literalExpression "pkgs.sioyek";
23        type = types.package;
24        description = "Package providing the sioyek binary";
25      };
26
27      bindings = mkOption {
28        description = ''
29          Input configuration written to
30          {file}`$XDG_CONFIG_HOME/sioyek/keys_user.config`.
31          See <https://github.com/ahrm/sioyek/blob/main/pdf_viewer/keys.config>.
32
33          Each attribute could also accept a list of strings to set multiple
34          bindings of the same command.
35        '';
36        type = with types; attrsOf (either str (listOf str));
37        default = { };
38        example = literalExpression ''
39          {
40            "move_up" = "k";
41            "move_down" = "j";
42            "move_left" = "h";
43            "move_right" = "l";
44            "screen_down" = [ "d" "<C-d>" ];
45            "screen_up" = [ "u" "<C-u>" ];
46          }
47        '';
48      };
49
50      config = mkOption {
51        description = ''
52          Input configuration written to
53          {file}`$XDG_CONFIG_HOME/sioyek/prefs_user.config`.
54          See <https://github.com/ahrm/sioyek/blob/main/pdf_viewer/prefs.config>.
55        '';
56        type = types.attrsOf types.str;
57        default = { };
58        example = literalExpression ''
59          {
60            "background_color" = "1.0 1.0 1.0";
61            "text_highlight_color" = "1.0 0.0 0.0";
62          }
63        '';
64      };
65
66    };
67  };
68
69  config = mkIf cfg.enable (mkMerge [
70    { home.packages = [ cfg.package ]; }
71    (mkIf (cfg.config != { }) {
72      xdg.configFile."sioyek/prefs_user.config".text = renderConfig cfg.config;
73    })
74    (mkIf (cfg.bindings != { }) {
75      xdg.configFile."sioyek/keys_user.config".text = renderConfig cfg.bindings;
76    })
77  ]);
78
79  meta.maintainers = [ hm.maintainers.podocarp ];
80}