parent
ccd7df836e
commit
0b491b460f
200 changed files with 2421 additions and 2817 deletions
|
|
@ -1,16 +1,13 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
with builtins;
|
||||
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
|
||||
cfg = config.programs.astroid;
|
||||
|
||||
jsonFormat = pkgs.formats.json { };
|
||||
|
||||
astroidAccounts =
|
||||
filterAttrs (n: v: v.astroid.enable) config.accounts.email.accounts;
|
||||
lib.filterAttrs (n: v: v.astroid.enable) config.accounts.email.accounts;
|
||||
|
||||
boolOpt = b: if b then "true" else "false";
|
||||
|
||||
|
|
@ -26,25 +23,25 @@ let
|
|||
save_sent = "true";
|
||||
save_sent_to = "${maildir.absPath}/${folders.sent}/cur/";
|
||||
select_query = "";
|
||||
} // optionalAttrs (signature.showSignature != "none") {
|
||||
} // lib.optionalAttrs (signature.showSignature != "none") {
|
||||
signature_attach = boolOpt (signature.showSignature == "attach");
|
||||
signature_default_on = boolOpt (signature.showSignature != "none");
|
||||
signature_file = pkgs.writeText "signature.txt" signature.text;
|
||||
signature_file_markdown = "false";
|
||||
signature_separate = "true"; # prepends '--\n' to the signature
|
||||
} // optionalAttrs (gpg != null) {
|
||||
} // lib.optionalAttrs (gpg != null) {
|
||||
always_gpg_sign = boolOpt gpg.signByDefault;
|
||||
gpgkey = gpg.key;
|
||||
} // astroid.extraConfig;
|
||||
|
||||
# See https://github.com/astroidmail/astroid/wiki/Configuration-Reference
|
||||
finalConfig = let
|
||||
template = fromJSON (readFile ./astroid-config-template.json);
|
||||
astroidConfig = foldl' recursiveUpdate template [
|
||||
template = lib.fromJSON (lib.readFile ./astroid-config-template.json);
|
||||
astroidConfig = lib.foldl' lib.recursiveUpdate template [
|
||||
{
|
||||
astroid.notmuch_config =
|
||||
"${config.xdg.configHome}/notmuch/default/config";
|
||||
accounts = mapAttrs (n: accountAttr) astroidAccounts;
|
||||
accounts = lib.mapAttrs (n: accountAttr) astroidAccounts;
|
||||
crypto.gpg.path = "${pkgs.gnupg}/bin/gpg";
|
||||
}
|
||||
cfg.extraConfig
|
||||
|
|
@ -55,7 +52,7 @@ let
|
|||
in {
|
||||
options = {
|
||||
programs.astroid = {
|
||||
enable = mkEnableOption "Astroid";
|
||||
enable = lib.mkEnableOption "Astroid";
|
||||
|
||||
pollScript = mkOption {
|
||||
type = types.str;
|
||||
|
|
@ -71,7 +68,7 @@ in {
|
|||
default = null;
|
||||
# Converts it into JSON that can be merged into the configuration.
|
||||
apply = cmd:
|
||||
optionalAttrs (cmd != null) {
|
||||
lib.optionalAttrs (cmd != null) {
|
||||
editor = {
|
||||
"external_editor" = "true";
|
||||
"cmd" = cmd;
|
||||
|
|
@ -99,7 +96,7 @@ in {
|
|||
extraConfig = mkOption {
|
||||
type = jsonFormat.type;
|
||||
default = { };
|
||||
example = literalExpression ''
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
poll.interval = 0;
|
||||
}
|
||||
|
|
@ -115,7 +112,7 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = [ pkgs.astroid ];
|
||||
|
||||
xdg.configFile."astroid/config".source =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue