home: mail: use make_mbsync_channels func

This commit is contained in:
Antoine Martin 2022-05-09 01:51:11 +02:00
parent fb09f2a6cd
commit d2e2cfeb8f

View file

@ -10,6 +10,10 @@
mkEnableOption mkEnableOption
mkIf mkIf
; ;
inherit
(builtins)
typeOf
;
myName = "Antoine Martin"; myName = "Antoine Martin";
email_perso = "antoine@alarsyo.net"; email_perso = "antoine@alarsyo.net";
@ -18,16 +22,25 @@
cfg = config.my.home.mail; cfg = config.my.home.mail;
make_mbsync_channel = patterns: { make_mbsync_channel = patterns:
farPattern = patterns.far; (
nearPattern = patterns.near; if (typeOf patterns) == "list"
extraConfig = { then {
Create = "Both"; inherit patterns;
Expunge = "Both"; }
Remove = "None"; else {
SyncState = "*"; farPattern = patterns.far;
nearPattern = patterns.near;
}
)
// {
extraConfig = {
Create = "Both";
Expunge = "Both";
Remove = "None";
SyncState = "*";
};
}; };
};
make_mbsync_channels = mapAttrs (_: value: make_mbsync_channel value); make_mbsync_channels = mapAttrs (_: value: make_mbsync_channel value);
gmail_far_near_patterns = { gmail_far_near_patterns = {
@ -77,23 +90,11 @@ in {
create = "both"; create = "both";
expunge = "both"; expunge = "both";
groups = { groups = {
alarsyo-main.channels.alarsyo-main = { alarsyo-main.channels = make_mbsync_channels {
patterns = ["INBOX" "Sent" "Drafts" "Junk" "Trash"]; main = ["INBOX" "Sent" "Drafts" "Junk" "Trash"];
extraConfig = {
Create = "Both";
Expunge = "Both";
Remove = "None";
SyncState = "*";
};
}; };
alarsyo-full.channels.alarsyo-full = { alarsyo-full.channels = make_mbsync_channels {
patterns = ["*" "!INBOX" "!Sent" "!Drafts" "!Junk" "!Trash"]; full = ["*" "!INBOX" "!Sent" "!Drafts" "!Junk" "!Trash"];
extraConfig = {
Create = "Both";
Expunge = "Both";
Remove = "None";
SyncState = "*";
};
}; };
}; };
}; };
@ -156,26 +157,12 @@ in {
expunge = "both"; expunge = "both";
groups = { groups = {
prologin-main.channels = prologin-main.channels =
{ (make_mbsync_channels {
main = { main = ["INBOX" "membres@"];
patterns = ["INBOX" "membres@"]; })
extraConfig = {
Create = "Both";
Expunge = "Both";
Remove = "None";
SyncState = "*";
};
};
}
// gmail_mbsync_channels; // gmail_mbsync_channels;
prologin-info.channels.prologin-info = { prologin-info.channels = make_mbsync_channels {
patterns = ["info@" "info@gcc"]; info = ["info@" "info@gcc"];
extraConfig = {
Create = "Both";
Expunge = "Both";
Remove = "None";
SyncState = "*";
};
}; };
}; };
}; };