about summary refs log tree commit diff stats
path: root/modules/home.legacy/conf/mail
diff options
context:
space:
mode:
Diffstat (limited to 'modules/home.legacy/conf/mail')
-rw-r--r--modules/home.legacy/conf/mail/accounts/benedikt.nix4
-rw-r--r--modules/home.legacy/conf/mail/accounts/soispha.nix4
-rw-r--r--modules/home.legacy/conf/mail/default.nix32
3 files changed, 36 insertions, 4 deletions
diff --git a/modules/home.legacy/conf/mail/accounts/benedikt.nix b/modules/home.legacy/conf/mail/accounts/benedikt.nix
index 87ede61b..2fe72fca 100644
--- a/modules/home.legacy/conf/mail/accounts/benedikt.nix
+++ b/modules/home.legacy/conf/mail/accounts/benedikt.nix
@@ -32,11 +32,11 @@
   #   };
   # };
   smtp = {
-    host = "server1.vhack.eu";
+    host = "mail.foss-syndicate.org";
     port = 465;
   };
   imap = {
-    host = "server1.vhack.eu";
+    host = "mail.foss-syndicate.org";
     port = 993;
   };
   jmap = {
diff --git a/modules/home.legacy/conf/mail/accounts/soispha.nix b/modules/home.legacy/conf/mail/accounts/soispha.nix
index 012e84d6..6e3e6228 100644
--- a/modules/home.legacy/conf/mail/accounts/soispha.nix
+++ b/modules/home.legacy/conf/mail/accounts/soispha.nix
@@ -33,11 +33,11 @@
   #   };
   # };
   smtp = {
-    host = "server1.vhack.eu";
+    host = "mail.foss-syndicate.org";
     port = 465;
   };
   imap = {
-    host = "server1.vhack.eu";
+    host = "mail.foss-syndicate.org";
     port = 993;
   };
   jmap = {
diff --git a/modules/home.legacy/conf/mail/default.nix b/modules/home.legacy/conf/mail/default.nix
index 0ecbe40a..9c2554ee 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.smtp://${value.smtp.host}:${builtins.toString value.smtp.port}";
+      value = {
+        "helper" = mkHelper value;
+      };
+    })
+    accounts;
 in {
   accounts.email = {
     maildirBasePath = "${config.xdg.dataHome}/maildir";
     inherit accounts;
   };
+
+  programs.git.extraConfig = accountCredentials;
 }