From 4b32f16747f5b21d4a512112d44cf60aa6ef2601 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 16 Aug 2018 21:37:42 +0200 Subject: [PATCH] Use submodules for program email accounts This reworks the way program specific email account options are specified. In particular, we no longer use the deprecated `options` field of `mkOption`. Instead submodules are used. --- modules/accounts/email.nix | 10 +++-- modules/programs/mbsync-accounts.nix | 57 ++++++++++++++++++++++++++ modules/programs/mbsync.nix | 58 --------------------------- modules/programs/notmuch-accounts.nix | 7 ++++ modules/programs/notmuch.nix | 10 ----- 5 files changed, 71 insertions(+), 71 deletions(-) create mode 100644 modules/programs/mbsync-accounts.nix create mode 100644 modules/programs/notmuch-accounts.nix diff --git a/modules/accounts/email.nix b/modules/accounts/email.nix index 6846cadb1..031b8baa2 100644 --- a/modules/accounts/email.nix +++ b/modules/accounts/email.nix @@ -123,7 +123,7 @@ let # gpgModule = types.submodule { # }; - mailAccount = types.submodule ({ name, config, ... }: { + mailAccountOpts = { name, config, ... }: { options = { name = mkOption { type = types.str; @@ -272,7 +272,7 @@ let }; }) ]; - }); + }; in @@ -294,7 +294,11 @@ in }; accounts = mkOption { - type = types.attrsOf mailAccount; + type = types.attrsOf (types.submodule [ + mailAccountOpts + (import ../programs/mbsync-accounts.nix) + (import ../programs/notmuch-accounts.nix) + ]); default = {}; description = "List of email accounts."; }; diff --git a/modules/programs/mbsync-accounts.nix b/modules/programs/mbsync-accounts.nix new file mode 100644 index 000000000..a983b7ff9 --- /dev/null +++ b/modules/programs/mbsync-accounts.nix @@ -0,0 +1,57 @@ +{ lib, ... }: + +with lib; + +{ + options.mbsync = { + enable = mkEnableOption "synchronization using mbsync"; + + flatten = mkOption { + type = types.nullOr types.str; + default = null; + example = "."; + description = '' + If set, flattens the hierarchy within the maildir by + substituting the canonical hierarchy delimiter + / with this value. + ''; + }; + + create = mkOption { + type = types.enum [ "none" "maildir" "imap" "both" ]; + default = "none"; + example = "maildir"; + description = '' + Automatically create missing mailboxes within the + given mail store. + ''; + }; + + remove = mkOption { + type = types.enum [ "none" "maildir" "imap" "both" ]; + default = "none"; + example = "imap"; + description = '' + Propagate mailbox deletions to the given mail store. + ''; + }; + + expunge = mkOption { + type = types.enum [ "none" "maildir" "imap" "both" ]; + default = "none"; + example = "both"; + description = '' + Permanently remove messages marked for deletion from + the given mail store. + ''; + }; + + patterns = mkOption { + type = types.listOf types.str; + default = [ "*" ]; + description = '' + Pattern of mailboxes to synchronize. + ''; + }; + }; +} diff --git a/modules/programs/mbsync.nix b/modules/programs/mbsync.nix index 87a783558..4abfc7b3f 100644 --- a/modules/programs/mbsync.nix +++ b/modules/programs/mbsync.nix @@ -132,64 +132,6 @@ in ''; }; }; - - accounts.email.accounts = mkOption { - options = [ - { - mbsync = { - enable = mkEnableOption "synchronization using mbsync"; - - flatten = mkOption { - type = types.nullOr types.str; - default = null; - example = "."; - description = '' - If set, flattens the hierarchy within the maildir by - substituting the canonical hierarchy delimiter - / with this value. - ''; - }; - - create = mkOption { - type = types.enum [ "none" "maildir" "imap" "both" ]; - default = "none"; - example = "maildir"; - description = '' - Automatically create missing mailboxes within the - given mail store. - ''; - }; - - remove = mkOption { - type = types.enum [ "none" "maildir" "imap" "both" ]; - default = "none"; - example = "imap"; - description = '' - Propagate mailbox deletions to the given mail store. - ''; - }; - - expunge = mkOption { - type = types.enum [ "none" "maildir" "imap" "both" ]; - default = "none"; - example = "both"; - description = '' - Permanently remove messages marked for deletion from - the given mail store. - ''; - }; - - patterns = mkOption { - type = types.listOf types.str; - default = [ "*" ]; - description = '' - Pattern of mailboxes to synchronize. - ''; - }; - }; - } - ]; - }; }; config = mkIf cfg.enable { diff --git a/modules/programs/notmuch-accounts.nix b/modules/programs/notmuch-accounts.nix new file mode 100644 index 000000000..7c9c93d3f --- /dev/null +++ b/modules/programs/notmuch-accounts.nix @@ -0,0 +1,7 @@ +{ lib, ... }: + +{ + options.notmuch = { + enable = lib.mkEnableOption "notmuch indexing"; + }; +} diff --git a/modules/programs/notmuch.nix b/modules/programs/notmuch.nix index 3d7a651f3..ef9f2ec4b 100644 --- a/modules/programs/notmuch.nix +++ b/modules/programs/notmuch.nix @@ -129,16 +129,6 @@ in }; }; }; - - accounts.email.accounts = mkOption { - options = [ - { - notmuch = { - enable = mkEnableOption "notmuch indexing"; - }; - } - ]; - }; }; config = mkIf cfg.enable {