Set real mail accounts and tie presence check to the yubikey toggle
Mirrors the azos-core change: features/mail/default.nix now just sets accounts.email.accounts (the three real addresses, with the existing default_account_params/default_gmail_params convenience merging kept here since it's personal boilerplate, not mechanism) and azos.mail.presenceCheckCommand, wired to azos-card-present only when azos.encryption.yubikey.enable is true.
This commit is contained in:
+1
-1
Submodule azos-core updated: 3b4cb38990...2a011bbb35
@@ -27,54 +27,15 @@
|
||||
certificatesFile = "/etc/ssl/certs/ca-certificates.crt";
|
||||
};
|
||||
};
|
||||
# mbsync's PassCmd shells out to `pass`, which needs the GPG smartcard to
|
||||
# decrypt. On a timer, a missing card would otherwise surface as a
|
||||
# pinentry "please insert card" prompt every run. azos-card-present is a
|
||||
# silent presence check (see overlays/default.nix): skip the sync
|
||||
# entirely when the card isn't there, instead of letting mbsync hit that
|
||||
# prompt.
|
||||
#
|
||||
# New mail is detected by counting files under every account's Maildir
|
||||
# "new" subdirectory before and after the sync -- that's where messages
|
||||
# the server hasn't marked seen land, across all three accounts at once,
|
||||
# with no need to touch mu's index. A rise in that count means mail
|
||||
# actually arrived, so only then does it post a desktop notification via
|
||||
# notify-send -- intentionally separate from mu4e's own "mbsync -a" (its
|
||||
# mu4e-get-mail-command), which doesn't go through this script at all.
|
||||
mbsyncSafe = pkgs.writeShellScript "mbsync-safe" ''
|
||||
if ! ${pkgs.azos-card-present}/bin/azos-card-present; then
|
||||
exit 0
|
||||
fi
|
||||
before=$(find "$HOME/Maildir" -path '*/new/*' -type f 2>/dev/null | wc -l)
|
||||
${pkgs.isync}/bin/mbsync -a
|
||||
after=$(find "$HOME/Maildir" -path '*/new/*' -type f 2>/dev/null | wc -l)
|
||||
new=$((after - before))
|
||||
if [ "$new" -gt 0 ]; then
|
||||
label="new message"
|
||||
[ "$new" -ne 1 ] && label="new messages"
|
||||
${pkgs.libnotify}/bin/notify-send "Mail" "$new $label"
|
||||
fi
|
||||
'';
|
||||
in {
|
||||
options.azos.mail.enable = lib.mkOption {
|
||||
default = true;
|
||||
type = lib.types.bool;
|
||||
};
|
||||
config = lib.mkIf config.azos.mail.enable {
|
||||
programs = {
|
||||
mu.enable = true;
|
||||
mbsync.enable = true;
|
||||
msmtp.enable = true;
|
||||
};
|
||||
home.activation.muInit = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||||
if [ ! -d "$HOME/.cache/mu" ]; then
|
||||
$DRY_RUN_CMD ${pkgs.mu}/bin/mu init \
|
||||
--maildir="$HOME/Maildir" \
|
||||
--my-address=aner@zakobar.com \
|
||||
--my-address=anerisgreat@gmail.com \
|
||||
--my-address=anerz@post.bgu.ac.il
|
||||
fi
|
||||
'';
|
||||
config = {
|
||||
azos.mail.enable = true;
|
||||
|
||||
# mbsync's PassCmd shells out to `pass`, which needs the GPG smartcard to
|
||||
# decrypt -- only meaningful to gate on when the smartcard/YubiKey setup
|
||||
# is actually in play.
|
||||
azos.mail.presenceCheckCommand = lib.mkIf config.azos.encryption.yubikey.enable "${pkgs.azos-card-present}/bin/azos-card-present";
|
||||
|
||||
accounts.email.accounts = {
|
||||
gmail =
|
||||
default_gmail_params
|
||||
@@ -106,21 +67,6 @@
|
||||
passwordCommand = "pass privateemail.com | head -1";
|
||||
};
|
||||
};
|
||||
systemd.user.services.mbsync-timer = {
|
||||
Unit.Description = "Sync mail via mbsync (skips silently if smartcard is absent)";
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${mbsyncSafe}";
|
||||
};
|
||||
};
|
||||
systemd.user.timers.mbsync-timer = {
|
||||
Unit.Description = "Periodic mbsync mail sync";
|
||||
Timer = {
|
||||
OnStartupSec = "2m";
|
||||
OnUnitActiveSec = "5m";
|
||||
};
|
||||
Install.WantedBy = ["timers.target"];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user