Compare commits

...

1 commit

Author SHA1 Message Date
Peter Hoeg ed71defae6 WIP 2020-05-18 19:41:56 +08:00

View file

@ -54,7 +54,7 @@ let
bindModule = types.submodule { bindModule = types.submodule {
options = { options = {
map = mkOption { map = mkOption {
type = types.enum [ type = types.listOf types.enum [
"alias" "alias"
"attach" "attach"
"browser" "browser"
@ -69,7 +69,7 @@ let
"query" "query"
"smime" "smime"
]; ];
default = "index"; default = [ "index" ];
description = "Select the menu to bind the command to."; description = "Select the menu to bind the command to.";
}; };
@ -87,8 +87,14 @@ let
}; };
}; };
attrToStr = attr:
if builtins.isBool attr
then yesno attr
else toString attr;
yesno = x: if x then "yes" else "no"; yesno = x: if x then "yes" else "no";
setOption = n: v: if v == null then "unset ${n}" else "set ${n}=${v}"; setOption = n: v: if v == null then "unset ${n}" else "set ${n}=${attrToStr v}";
escape = replaceStrings [ "%" ] [ "%25" ]; escape = replaceStrings [ "%" ] [ "%25" ];
accountFilename = account: config.xdg.configHome + "/neomutt/" + account.name; accountFilename = account: config.xdg.configHome + "/neomutt/" + account.name;
@ -144,13 +150,12 @@ let
optionsStr = attrs: concatStringsSep "\n" (mapAttrsToList setOption attrs); optionsStr = attrs: concatStringsSep "\n" (mapAttrsToList setOption attrs);
sidebarSection = '' sidebarSection = "# Sidebar\n" + optionsStr {
# Sidebar sidebar_visible = true;
set sidebar_visible = yes sidebar_short_path = cfg.sidebar.shortPath;
set sidebar_short_path = ${yesno cfg.sidebar.shortPath} sidebar_width = cfg.sidebar.width;
set sidebar_width = ${toString cfg.sidebar.width} sidebar_format = "'${cfg.sidebar.format}'";
set sidebar_format = '${cfg.sidebar.format}' };
'';
bindSection = concatMapStringsSep "\n" bindSection = concatMapStringsSep "\n"
(bind: ''bind ${bind.map} ${bind.key} "${bind.action}"'') cfg.binds; (bind: ''bind ${bind.map} ${bind.key} "${bind.action}"'') cfg.binds;
@ -158,10 +163,10 @@ let
macroSection = concatMapStringsSep "\n" macroSection = concatMapStringsSep "\n"
(bind: ''macro ${bind.map} ${bind.key} "${bind.action}"'') cfg.macros; (bind: ''macro ${bind.map} ${bind.key} "${bind.action}"'') cfg.macros;
mailCheckSection = '' mailCheckSection = optionsStr {
set mail_check_stats mail_check_stats = true;
set mail_check_stats_interval = ${toString cfg.checkStatsInterval} mail_check_stats_interval = cfg.checkStatsInterval;
''; };
notmuchSection = account: notmuchSection = account:
with account; '' with account; ''
@ -251,7 +256,7 @@ in {
}; };
settings = mkOption { settings = mkOption {
type = types.attrsOf types.str; type = types.attrs;
default = { }; default = { };
description = "Extra configuration appended to the end."; description = "Extra configuration appended to the end.";
}; };