{ 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; }