home: create 'modules/home' folder

Consolidating all modules under the same path, to clear out the
top-level directory.
This commit is contained in:
Bruno BELANYI 2023-11-09 13:43:55 +00:00
parent c856933803
commit 65a8f7c481
119 changed files with 2 additions and 2 deletions

View file

@ -0,0 +1,94 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.mail;
inherit (lib.my) mkMailAddress;
mkConfig = { domain, address, passName, aliases ? [ ], primary ? false }: {
realName = lib.mkDefault "Bruno BELANYI";
userName = lib.mkDefault (mkMailAddress address domain);
passwordCommand =
lib.mkDefault [ (lib.getExe pkgs.ambroisie.rbw-pass) "Mail" passName ];
address = mkMailAddress address domain;
aliases = builtins.map (lib.flip mkMailAddress domain) aliases;
inherit primary;
himalaya = {
enable = cfg.himalaya.enable;
# FIXME: try to actually configure it at some point
backend = "imap";
sender = "smtp";
};
msmtp = {
enable = cfg.msmtp.enable;
};
};
migaduConfig = {
imap = {
host = "imap.migadu.com";
port = 993;
tls = {
enable = true;
};
};
smtp = {
host = "smtp.migadu.com";
port = 465;
tls = {
enable = true;
};
};
};
gmailConfig = {
flavor = "gmail.com";
folders = {
drafts = "[Gmail]/Drafts";
sent = "[Gmail]/Sent Mail";
trash = "[Gmail]/Trash";
};
};
office365Config = {
flavor = "outlook.office365.com";
};
in
{
config.accounts.email.accounts = {
personal = lib.mkMerge [
# Common configuraton
(mkConfig {
domain = "belanyi.fr";
address = "bruno";
passName = "Migadu";
aliases = [ "admin" "postmaster" ];
primary = true; # This is my primary email
})
migaduConfig
];
gmail = lib.mkMerge [
# Common configuraton
(mkConfig {
domain = "gmail.com";
address = "brunobelanyi";
passName = "GMail";
})
gmailConfig
];
epita = lib.mkMerge [
# Common configuration
(mkConfig {
domain = "epita.fr";
address = "bruno.belanyi";
passName = "EPITA";
})
office365Config
];
};
}

View file

@ -0,0 +1,31 @@
{ config, lib, ... }:
let
cfg = config.my.home.mail;
mkRelatedOption = desc: lib.mkEnableOption desc // { default = cfg.enable; };
in
{
imports = [
./accounts
./himalaya
./msmtp
];
options.my.home.mail = with lib; {
enable = my.mkDisableOption "email configuration";
himalaya = {
enable = mkEnableOption "himalaya configuration";
};
msmtp = {
enable = mkRelatedOption "msmtp configuration";
};
};
config = {
accounts.email = {
maildirBasePath = "mail";
};
};
}

View file

@ -0,0 +1,23 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.mail.himalaya;
in
{
config.programs.himalaya = lib.mkIf cfg.enable {
enable = true;
settings = {
notify-cmd =
let
notify-send = lib.getExe pkgs.libnotify;
in
pkgs.writeScript "mail-notifier" ''
SENDER="$1"
SUBJECT="$2"
${notify-send} \
-c himalaya \
-- "$(printf 'Received email from %s\n\n%s' "$SENDER" "$SUBJECT")"
'';
};
};
}

View file

@ -0,0 +1,9 @@
{ config, lib, ... }:
let
cfg = config.my.home.mail.msmtp;
in
{
config.programs.msmtp = lib.mkIf cfg.enable {
enable = true;
};
}