Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions modules/zathura/module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
config,
lib,
wlib,
...
}:
let
formatLine =
n: v:
let
formatValue = v: if lib.isBool v then (if v then "true" else "false") else toString v;
in
''set ${n} "${formatValue v}"'';

formatMapLine = n: v: "map ${n} ${toString v}";
in
{
_class = "wrapper";
options = {
options = lib.mkOption {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
options = lib.mkOption {
settings = lib.mkOption {

as per RFC42 and consistency with the other modules

type = lib.types.attrsOf (
lib.types.oneOf [
lib.types.str
lib.types.bool
lib.types.int
lib.types.float
]
);
default = { };
description = ''
Add {option}`:set` command options to zathura and make
them permanent. See
{manpage}`zathurarc(5)`
for the full list of options.
'';
example = {
default-bg = "#000000";
default-fg = "#FFFFFF";
};
};
mappings = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
default = { };
description = ''
Add {option}`:map` mappings to zathura and make
them permanent. See
{manpage}`zathurarc(5)`
for the full list of possible mappings.

You can create a mode-specific mapping by specifying the mode before the key:
`"[normal] <C-b>" = "scroll left";`
'';
example = {
D = "toggle_page_mode";
"<Right>" = "navigate next";
"[fullscreen] <C-i>" = "zoom in";
};
};
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
Additional commands for zathura that will be added to the
{file}`zathurarc` file.
'';
};
"zathurarc" = lib.mkOption {
type = wlib.types.file config.pkgs;
description = "zathura config file";
default.content =
lib.concatStringsSep "\n" (
lib.optional (config.extraConfig != "") config.extraConfig
++ lib.mapAttrsToList formatLine config.options
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
++ lib.mapAttrsToList formatLine config.options
++ lib.mapAttrsToList formatLine config.settings

++ lib.mapAttrsToList formatMapLine config.mappings
)
+ "\n";
};
extraFiles = lib.mkOption {
type = lib.types.listOf (
lib.types.submodule {
options = {
name = lib.mkOption {
type = lib.types.nonEmptyStr;
description = "File name in the config directory";
};
file = lib.mkOption {
type = wlib.types.file config.pkgs;
description = "File or path to add into the config directory";
};
};
}
);
default = [ ];
description = "Additional files to be placed in the config directory";
};
};
config = {
flags = {
"--config-dir" = toString (
config.pkgs.linkFarm "zathura-merged-config" (
let
entry = name: path: { inherit name path; };
in
[ (entry "zathurarc" config."zathurarc".path) ]
++ (map (f: {
inherit (f) name;
path = f.file.path;
}) config.extraFiles)
)
);
};
package = config.pkgs.zathura;
meta = {
maintainers = [
{
name = "holly";
github = "hollymlem";
githubId = 35699052;
}
];
};
};
}
Loading