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.nix13
-rw-r--r--modules/home.legacy/conf/mail/accounts/soispha.nix13
-rw-r--r--modules/home.legacy/conf/mail/default.nix47
3 files changed, 69 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..e75cb523 100644
--- a/modules/home.legacy/conf/mail/accounts/benedikt.nix
+++ b/modules/home.legacy/conf/mail/accounts/benedikt.nix
@@ -1,3 +1,12 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
 {pkgs}: {
   address = "benedikt.peetz@b-peetz.de";
   userName = "benedikt.peetz@b-peetz.de";
@@ -32,11 +41,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..6bcb0da6 100644
--- a/modules/home.legacy/conf/mail/accounts/soispha.nix
+++ b/modules/home.legacy/conf/mail/accounts/soispha.nix
@@ -1,3 +1,12 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
 {pkgs}: {
   address = "soispha@vhack.eu";
   userName = "soispha@vhack.eu";
@@ -33,11 +42,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..17957c82 100644
--- a/modules/home.legacy/conf/mail/default.nix
+++ b/modules/home.legacy/conf/mail/default.nix
@@ -1,15 +1,62 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
 {
   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
+        }
+        output="$(cat)"
+        if echo "$output" | grep "username=${userName}" -q; then
+          if password="$(${passwordCommand})"; then
+            printf "%s\npassword=%s\n\n" "$output" "$password"
+          else
+            # The password command failed (for whatever reason)
+            exit 1
+          fi
+        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;
 }