aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Helgesson <robert@rycee.net>2020-05-01 22:33:05 +0200
committerRobert Helgesson <robert@rycee.net>2020-05-01 22:33:05 +0200
commit70f7c9f35510ac9482db5276e34a628ead8372ca (patch)
treec4f46e05c95e8fc9b3b0f576f616dc4c534470ea
parent10673bff4c62ea3cb627007fc7bb4ab9ea521685 (diff)
alot: apply nixfmt
-rwxr-xr-xformat1
-rw-r--r--modules/programs/alot.nix175
2 files changed, 75 insertions, 101 deletions
diff --git a/format b/format
index 5828f60d41e..2f4e297b311 100755
--- a/format
+++ b/format
@@ -33,7 +33,6 @@ find . -name '*.nix' \
! -path ./modules/misc/xdg.nix \
! -path ./modules/modules.nix \
! -path ./modules/programs/afew.nix \
- ! -path ./modules/programs/alot.nix \
! -path ./modules/programs/bash.nix \
! -path ./modules/programs/emacs.nix \
! -path ./modules/programs/firefox.nix \
diff --git a/modules/programs/alot.nix b/modules/programs/alot.nix
index 62d0720da70..638630e1c58 100644
--- a/modules/programs/alot.nix
+++ b/modules/programs/alot.nix
@@ -7,20 +7,16 @@ let
cfg = config.programs.alot;
- alotAccounts = filter (a: a.notmuch.enable)
- (attrValues config.accounts.email.accounts);
+ alotAccounts =
+ filter (a: a.notmuch.enable) (attrValues config.accounts.email.accounts);
boolStr = v: if v then "True" else "False";
mkKeyValue = key: value:
- let
- value' =
- if isBool value then boolStr value
- else toString value;
- in
- "${key} = ${value'}";
+ let value' = if isBool value then boolStr value else toString value;
+ in "${key} = ${value'}";
- mk2ndLevelSectionName = name: "[" + name + "]";
+ mk2ndLevelSectionName = name: "[" + name + "]";
tagSubmodule = types.submodule {
options = {
@@ -58,84 +54,66 @@ let
default = null;
description = "How to display the tag when focused.";
};
+ };
};
- };
-
- accountStr = account: with account;
- concatStringsSep "\n" (
- [ "[[${name}]]" ]
- ++ mapAttrsToList (n: v: n + "=" + v) (
- {
- address = address;
- realname = realName;
- sendmail_command =
- optionalString (alot.sendMailCommand != null) alot.sendMailCommand;
- sent_box = "maildir" + "://" + maildir.absPath + "/" + folders.sent;
- draft_box = "maildir" + "://"+ maildir.absPath + "/" + folders.drafts;
- }
- // optionalAttrs (aliases != []) {
- aliases = concatStringsSep "," aliases;
- }
- // optionalAttrs (gpg != null) {
- gpg_key = gpg.key;
- encrypt_by_default = if gpg.encryptByDefault then "all" else "none";
- sign_by_default = boolStr gpg.signByDefault;
- }
- // optionalAttrs (signature.showSignature != "none") {
- signature = pkgs.writeText "signature.txt" signature.text;
- signature_as_attachment =
- boolStr (signature.showSignature == "attach");
- }
- )
- ++ [ alot.extraConfig ]
- ++ [ "[[[abook]]]" ]
- ++ mapAttrsToList (n: v: n + "=" + v) alot.contactCompletion
- );
-
- configFile =
- let
- bindingsToStr = attrSet:
- concatStringsSep "\n" (mapAttrsToList (n: v: "${n} = ${v}") attrSet);
- in
- ''
- # Generated by Home Manager.
- # See http://alot.readthedocs.io/en/latest/configuration/config_options.html
-
- ${generators.toKeyValue { inherit mkKeyValue; } cfg.settings}
- ${cfg.extraConfig}
- [tags]
- ''
- + (
- let
- submoduleToAttrs = m:
- filterAttrs (name: v: name != "_module" && v != null) m;
- in
- generators.toINI { mkSectionName = mk2ndLevelSectionName; }
- (mapAttrs (name: x: submoduleToAttrs x) cfg.tags)
- )
- + ''
- [bindings]
- ${bindingsToStr cfg.bindings.global}
-
- [[bufferlist]]
- ${bindingsToStr cfg.bindings.bufferlist}
- [[search]]
- ${bindingsToStr cfg.bindings.search}
- [[envelope]]
- ${bindingsToStr cfg.bindings.envelope}
- [[taglist]]
- ${bindingsToStr cfg.bindings.taglist}
- [[thread]]
- ${bindingsToStr cfg.bindings.thread}
-
- [accounts]
-
- ${concatStringsSep "\n\n" (map accountStr alotAccounts)}
- '';
-
-in
-{
+ accountStr = account:
+ with account;
+ concatStringsSep "\n" ([ "[[${name}]]" ]
+ ++ mapAttrsToList (n: v: n + "=" + v) ({
+ address = address;
+ realname = realName;
+ sendmail_command =
+ optionalString (alot.sendMailCommand != null) alot.sendMailCommand;
+ sent_box = "maildir" + "://" + maildir.absPath + "/" + folders.sent;
+ draft_box = "maildir" + "://" + maildir.absPath + "/" + folders.drafts;
+ } // optionalAttrs (aliases != [ ]) {
+ aliases = concatStringsSep "," aliases;
+ } // optionalAttrs (gpg != null) {
+ gpg_key = gpg.key;
+ encrypt_by_default = if gpg.encryptByDefault then "all" else "none";
+ sign_by_default = boolStr gpg.signByDefault;
+ } // optionalAttrs (signature.showSignature != "none") {
+ signature = pkgs.writeText "signature.txt" signature.text;
+ signature_as_attachment = boolStr (signature.showSignature == "attach");
+ }) ++ [ alot.extraConfig ] ++ [ "[[[abook]]]" ]
+ ++ mapAttrsToList (n: v: n + "=" + v) alot.contactCompletion);
+
+ configFile = let
+ bindingsToStr = attrSet:
+ concatStringsSep "\n" (mapAttrsToList (n: v: "${n} = ${v}") attrSet);
+ in ''
+ # Generated by Home Manager.
+ # See http://alot.readthedocs.io/en/latest/configuration/config_options.html
+
+ ${generators.toKeyValue { inherit mkKeyValue; } cfg.settings}
+ ${cfg.extraConfig}
+ [tags]
+ '' + (let
+ submoduleToAttrs = m:
+ filterAttrs (name: v: name != "_module" && v != null) m;
+ in generators.toINI { mkSectionName = mk2ndLevelSectionName; }
+ (mapAttrs (name: x: submoduleToAttrs x) cfg.tags)) + ''
+ [bindings]
+ ${bindingsToStr cfg.bindings.global}
+
+ [[bufferlist]]
+ ${bindingsToStr cfg.bindings.bufferlist}
+ [[search]]
+ ${bindingsToStr cfg.bindings.search}
+ [[envelope]]
+ ${bindingsToStr cfg.bindings.envelope}
+ [[taglist]]
+ ${bindingsToStr cfg.bindings.taglist}
+ [[thread]]
+ ${bindingsToStr cfg.bindings.thread}
+
+ [accounts]
+
+ ${concatStringsSep "\n\n" (map accountStr alotAccounts)}
+ '';
+
+in {
options.programs.alot = {
enable = mkOption {
type = types.bool;
@@ -161,42 +139,42 @@ in
options = {
global = mkOption {
type = types.attrsOf types.str;
- default = {};
+ default = { };
description = "Global keybindings.";
};
bufferlist = mkOption {
type = types.attrsOf types.str;
- default = {};
+ default = { };
description = "Bufferlist mode keybindings.";
};
search = mkOption {
type = types.attrsOf types.str;
- default = {};
+ default = { };
description = "Search mode keybindings.";
};
envelope = mkOption {
type = types.attrsOf types.str;
- default = {};
+ default = { };
description = "Envelope mode keybindings.";
};
taglist = mkOption {
type = types.attrsOf types.str;
- default = {};
+ default = { };
description = "Taglist mode keybindings.";
};
thread = mkOption {
type = types.attrsOf types.str;
- default = {};
+ default = { };
description = "Thread mode keybindings.";
};
};
};
- default = {};
+ default = { };
description = ''
Keybindings.
'';
@@ -204,16 +182,14 @@ in
tags = mkOption {
type = types.attrsOf tagSubmodule;
- default = {};
+ default = { };
description = "How to display the tags.";
};
settings = mkOption {
type = with types;
- let
- primitive = either (either (either str int) bool) float;
- in
- attrsOf primitive;
+ let primitive = either (either (either str int) bool) float;
+ in attrsOf primitive;
default = {
initial_command = "search tag:inbox AND NOT tag:killed";
auto_remove_unread = true;
@@ -242,15 +218,14 @@ in
};
config = mkIf cfg.enable {
- home.packages = [ pkgs.alot ];
+ home.packages = [ pkgs.alot ];
xdg.configFile."alot/config".text = configFile;
xdg.configFile."alot/hooks.py" = mkIf (cfg.hooks != "") {
text = ''
# Generated by Home Manager.
- ''
- + cfg.hooks;
+ '' + cfg.hooks;
};
};
}