/
pqiv.nix
76 lines (66 loc) · 1.85 KB
/
pqiv.nix
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.pqiv;
iniFormat = pkgs.formats.ini { };
in {
meta.maintainers = with lib.maintainers; [ donovanglover iynaix ];
options.programs.pqiv = {
enable = mkEnableOption "pqiv image viewer";
package = mkOption {
type = types.package;
default = pkgs.pqiv;
defaultText = literalExpression "pkgs.pqiv";
description = "The pqiv package to install.";
};
settings = mkOption {
type = iniFormat.type;
default = { };
description = ''
Configuration written to {file}`$XDG_CONFIG_HOME/pqivrc`. See
{manpage}`pqiv(1)` for a list of available options. To set a
boolean flag, set the value to 1.
'';
example = literalExpression ''
{
options = {
lazy-load = 1;
hide-info-box = 1;
background-pattern = "black";
thumbnail-size = "256x256";
command-1 = "thunar";
};
};
'';
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = ''
Extra lines to be added to {file}`$XDG_CONFIG_HOME/pqivrc`. See
{manpage}`pqiv(1)` for a list of available options.
'';
example = literalExpression ''
[actions]
set_cursor_auto_hide(1)
[keybindings]
t { montage_mode_enter() }
@MONTAGE {
t { montage_mode_return_cancel() }
}
'';
};
};
config = mkIf cfg.enable {
assertions =
[ (hm.assertions.assertPlatform "programs.pqiv" pkgs platforms.linux) ];
home.packages = [ cfg.package ];
xdg.configFile."pqivrc" =
mkIf (cfg.settings != { } && cfg.extraConfig != "") {
text = lib.concatLines [
(generators.toINI { } cfg.settings)
cfg.extraConfig
];
};
};
}