118 lines
3.8 KiB
Nix
118 lines
3.8 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
globox-id = "b446944a47d39ae969ebe27f81cf2d8963df7a04dd40e31e61c7c2ecc1ac7437";
|
|
archiver = pkgs.writers.writePython3 "mail-archiver" {
|
|
libraries = with pkgs.python3Packages; [ imap-tools ];
|
|
} (builtins.readFile ./archiver.py);
|
|
|
|
in
|
|
{
|
|
home-manager.users.mysaa.accounts.email.accounts = {
|
|
"hadoly".thunderbird.enable = true;
|
|
"personal".thunderbird.enable = true;
|
|
"ens".thunderbird.enable = true;
|
|
"junk".thunderbird.enable = true;
|
|
"google".thunderbird.enable = true;
|
|
"bernard".thunderbird.enable = true;
|
|
"dmesures".thunderbird.enable = true;
|
|
"ecloud".thunderbird.enable = true;
|
|
};
|
|
home-manager.users.mysaa.programs.thunderbird = {
|
|
enable = true;
|
|
package = pkgs.thunderbird.override {
|
|
extraPolicies.ExtensionSettings = {
|
|
"localfolder@philoux.eu" = {
|
|
install_url = "https://addons.thunderbird.net/user-media/addons/_attachments/90003/localfolders-4.2.2-tb.xpi?filehash=sha256%3A71d499b55b360769447e9f08536ee557b0419e84d5914e79c18558d86a21fbd9";
|
|
installation_mode = "force_installed";
|
|
};
|
|
};
|
|
};
|
|
profiles.default = {
|
|
isDefault = true;
|
|
accountsOrder = [
|
|
"hadoly"
|
|
"dmesures"
|
|
"bernard"
|
|
"ens"
|
|
"account_${globox-id}"
|
|
"personal"
|
|
"junk"
|
|
"ecloud"
|
|
"google"
|
|
];
|
|
settings = {
|
|
"mail.account.account_${globox-id}.server" = "server_${globox-id}";
|
|
"mail.server.server_${globox-id}.directory" = "/home/mysaa/Globox";
|
|
#user_pref("mail.server.server1.directory-rel", "[ProfD]../../../Globox");
|
|
"mail.server.server_${globox-id}.hostname" = "globox";
|
|
"mail.server.server_${globox-id}.name" = "globox";
|
|
"mail.server.server_${globox-id}.storeContractID" = "@mozilla.org/msgstore/maildirstore;1";
|
|
"mail.server.server_${globox-id}.type" = "none";
|
|
"mail.server.server_${globox-id}.userName" = "nobody";
|
|
|
|
}
|
|
// lib.attrsets.concatMapAttrs (
|
|
_: account:
|
|
lib.optionalAttrs (account.passwordCommand != null) (
|
|
let
|
|
id = builtins.hashString "sha256" account.name;
|
|
command = lib.concatStringsSep " " account.passwordCommand;
|
|
passwordScript = pkgs.writeShellScript "get-password.sh" ''
|
|
echo "Got command $1" >> /tmp/thunderpasswordget
|
|
${command} | ${pkgs.netcat}/bin/nc -w 0 -U $1
|
|
'';
|
|
in
|
|
lib.optionalAttrs (account.smtp != null) {
|
|
"mail.smtpserver.smtp_${id}.passwordCommand" = toString passwordScript;
|
|
}
|
|
// lib.optionalAttrs (account.imap != null) {
|
|
"mail.server.server_${id}.passwordCommand" = toString passwordScript;
|
|
}
|
|
)
|
|
) config.home-manager.users.mysaa.accounts.email.accounts;
|
|
};
|
|
};
|
|
|
|
# home-manager.users.mysaa.nixpkgs.overlays = [
|
|
# (final: prev: {
|
|
# thunderbird-unwrapped = prev.thunderbird-unwrapped.overrideAttrs {
|
|
# patches = (prev.thunderbird-unwrapped.patches or [ ]) ++ [
|
|
# ../../packages/add_passwordcommand_smtp.patch
|
|
# ../../packages/add_passwordcommand_imap.patch
|
|
# ];
|
|
# };
|
|
# })
|
|
# ];
|
|
|
|
home-manager.users.mysaa.systemd.user = {
|
|
services.mail-archiver = {
|
|
Unit = {
|
|
Description = "Archives emails from Hadoly account to Globox";
|
|
};
|
|
Service = {
|
|
Type = "oneshot";
|
|
ExecStart = "${archiver} $(cat /run/secrets/pass/hadoly_password)";
|
|
};
|
|
};
|
|
timers.mail-archiver = {
|
|
Unit = {
|
|
Description = "Weekly archiving of emails";
|
|
};
|
|
Timer = {
|
|
OnCalendar = "Tue *-*-* 13:00:00";
|
|
Persistent = "true";
|
|
Unit = "mail-archiver.service";
|
|
};
|
|
Install = {
|
|
WantedBy = [ "timers.target" ];
|
|
};
|
|
};
|
|
};
|
|
|
|
}
|