diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-02-03 18:00:19 +0100 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-02-03 18:00:19 +0100 |
commit | 13fea4b17f995a5338509027bbb9dad08ca9f73d (patch) | |
tree | d8e2ae13366020f336c252cea464c23636b959ad /modules/home.legacy/conf/mail/default.nix | |
parent | docs(modules/legacy/mbsync): Improve documentation of set options (diff) | |
download | nixos-config-13fea4b17f995a5338509027bbb9dad08ca9f73d.zip |
feat(modules/legacy/mail): Automatically set a git credential helper
Diffstat (limited to '')
-rw-r--r-- | modules/home.legacy/conf/mail/default.nix | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/home.legacy/conf/mail/default.nix b/modules/home.legacy/conf/mail/default.nix index 0ecbe40a..5e35c002 100644 --- a/modules/home.legacy/conf/mail/default.nix +++ b/modules/home.legacy/conf/mail/default.nix @@ -1,15 +1,47 @@ { config, pkgs, + lib, ... }: let benedikt = import ./accounts/benedikt.nix {inherit pkgs;}; soispha = import ./accounts/soispha.nix {inherit pkgs;}; accounts = {inherit soispha benedikt;}; + + mkHelper = { + userName, + passwordCommand, + ... + }: + builtins.toString (pkgs.writeShellScript "git-credential-keepassxc-libsecret" + # bash + '' + [ "$1" = "get" ] || { + exit 1 + } + if cat | grep "username=${userName}" -q; then + ${passwordCommand} + else + # Not our business. + exit 1 + fi + ''); + accountCredentials = + # TODO: This will result in only one of them being defined, as we duplicate the + # attribute key<2025-02-03> + lib.mapAttrs' (_: value: { + name = "credential"; + value = { + "smtp://${value.smtp.host}:${builtins.toString value.smtp.port}" = mkHelper value; + }; + }) + accounts; in { accounts.email = { maildirBasePath = "${config.xdg.dataHome}/maildir"; inherit accounts; }; + + programs.git.extraConfig = accountCredentials; } |