mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
alot: apply nixfmt
This commit is contained in:
parent
10673bff4c
commit
70f7c9f355
2 changed files with 69 additions and 95 deletions
1
format
1
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 \
|
||||
|
|
|
@ -7,18 +7,14 @@ 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 + "]";
|
||||
|
||||
|
@ -61,59 +57,43 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
accountStr = account: with account;
|
||||
concatStringsSep "\n" (
|
||||
[ "[[${name}]]" ]
|
||||
++ mapAttrsToList (n: v: n + "=" + v) (
|
||||
{
|
||||
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 != []) {
|
||||
} // optionalAttrs (aliases != [ ]) {
|
||||
aliases = concatStringsSep "," aliases;
|
||||
}
|
||||
// optionalAttrs (gpg != null) {
|
||||
} // 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") {
|
||||
} // 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
|
||||
);
|
||||
signature_as_attachment = boolStr (signature.showSignature == "attach");
|
||||
}) ++ [ alot.extraConfig ] ++ [ "[[[abook]]]" ]
|
||||
++ mapAttrsToList (n: v: n + "=" + v) alot.contactCompletion);
|
||||
|
||||
configFile =
|
||||
let
|
||||
configFile = let
|
||||
bindingsToStr = attrSet:
|
||||
concatStringsSep "\n" (mapAttrsToList (n: v: "${n} = ${v}") attrSet);
|
||||
in
|
||||
''
|
||||
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
|
||||
'' + (let
|
||||
submoduleToAttrs = m:
|
||||
filterAttrs (name: v: name != "_module" && v != null) m;
|
||||
in
|
||||
generators.toINI { mkSectionName = mk2ndLevelSectionName; }
|
||||
(mapAttrs (name: x: submoduleToAttrs x) cfg.tags)
|
||||
)
|
||||
+ ''
|
||||
in generators.toINI { mkSectionName = mk2ndLevelSectionName; }
|
||||
(mapAttrs (name: x: submoduleToAttrs x) cfg.tags)) + ''
|
||||
[bindings]
|
||||
${bindingsToStr cfg.bindings.global}
|
||||
|
||||
|
@ -133,9 +113,7 @@ let
|
|||
${concatStringsSep "\n\n" (map accountStr alotAccounts)}
|
||||
'';
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
in {
|
||||
options.programs.alot = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
|
@ -210,10 +188,8 @@ in
|
|||
|
||||
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;
|
||||
|
@ -249,8 +225,7 @@ in
|
|||
xdg.configFile."alot/hooks.py" = mkIf (cfg.hooks != "") {
|
||||
text = ''
|
||||
# Generated by Home Manager.
|
||||
''
|
||||
+ cfg.hooks;
|
||||
'' + cfg.hooks;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue