diff --git a/modules/programs/aerc-accounts.nix b/modules/programs/aerc-accounts.nix index 04f0165a0..8ebfef0bb 100644 --- a/modules/programs/aerc-accounts.nix +++ b/modules/programs/aerc-accounts.nix @@ -134,8 +134,9 @@ in { oauthParams = { auth, params }: if useOauth auth && params != null && params != { } then - "?" + builtins.concatStringsSep "&" lib.attrsets.mapAttrsToList - (k: v: k + "=" + lib.strings.escapeURL v) params + "?" + builtins.concatStringsSep "&" + (lib.attrsets.mapAttrsToList (k: v: k + "=" + lib.strings.escapeURL v) + (lib.attrsets.filterAttrs (k: v: v != null) params)) else ""; diff --git a/tests/modules/programs/aerc/default.nix b/tests/modules/programs/aerc/default.nix index 9417a2197..80b7e9efc 100644 --- a/tests/modules/programs/aerc/default.nix +++ b/tests/modules/programs/aerc/default.nix @@ -2,4 +2,5 @@ aerc-noSettings = ./noSettings.nix; aerc-settings = ./settings.nix; aerc-assertion = ./assertion.nix; + aerc-oauth = ./oauth.nix; } diff --git a/tests/modules/programs/aerc/oauth.expected b/tests/modules/programs/aerc/oauth.expected new file mode 100644 index 000000000..6824d1fed --- /dev/null +++ b/tests/modules/programs/aerc/oauth.expected @@ -0,0 +1,9 @@ +# Generated by Home Manager. + +[basic] +copy-to = Sent +default = Inbox +from = Annie X. Hacker +outgoing = smtp+xoauth2://anniex@smtp.office365.com:587?client_id=9e5f94bc-e8a4-4e73-b8be-63364c29d753&token_endpoint=https%3A%2F%2Flogin.microsoftonline.com%2Fcommon%2Foauth2%2Fv2.0%2Ftoken +postpone = Drafts +source = imaps+xoauth2://anniex@outlook.office365.com:993?client_id=9e5f94bc-e8a4-4e73-b8be-63364c29d753&token_endpoint=https%3A%2F%2Flogin.microsoftonline.com%2Fcommon%2Foauth2%2Fv2.0%2Ftoken diff --git a/tests/modules/programs/aerc/oauth.nix b/tests/modules/programs/aerc/oauth.nix new file mode 100644 index 000000000..e91d25203 --- /dev/null +++ b/tests/modules/programs/aerc/oauth.nix @@ -0,0 +1,39 @@ +{ config, pkgs, ... }: { + config = { + nmt.script = let + dir = if (pkgs.stdenv.isDarwin && !config.xdg.enable) then + "home-files/Library/Preferences/aerc" + else + "home-files/.config/aerc"; + in '' + assertFileContent ${dir}/accounts.conf ${./oauth.expected} + ''; + programs.aerc = { + enable = true; + extraConfig.general.unsafe-accounts-conf = true; + }; + + accounts.email.accounts = { + basic = { + realName = "Annie X. Hacker"; + userName = "anniex"; + address = "anniex@mail.invalid"; + primary = true; + flavor = "outlook.office365.com"; + + aerc = rec { + enable = true; + imapAuth = "xoauth2"; + smtpAuth = imapAuth; + imapOauth2Params = { + client_id = "9e5f94bc-e8a4-4e73-b8be-63364c29d753"; + token_endpoint = + "https://login.microsoftonline.com/common/oauth2/v2.0/token"; + }; + smtpOauth2Params = imapOauth2Params; + }; + }; + }; + }; +} +