Skip to content

Commit d8d5cdf

Browse files
committed
[email] Move email config from user-specific to NixOS-specific
1 parent 25cdfed commit d8d5cdf

File tree

4 files changed

+42
-51
lines changed

4 files changed

+42
-51
lines changed

machines/nixos/default.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@
7878
defaultEditor = true;
7979
};
8080

81+
email = {
82+
enable = true;
83+
fromAddress = "[email protected]";
84+
toAddress = "[email protected]";
85+
smtpServer = "email-smtp.eu-west-1.amazonaws.com";
86+
smtpUsername = "AKIAYYXVLL34J7LSXFZF";
87+
smtpPasswordPath = config.age.secrets.smtpPassword.path;
88+
};
89+
8190
security = {
8291
doas.enable = lib.mkDefault false;
8392
sudo = {

modules/email/default.nix

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,53 @@
1-
{ config, pkgs, lib, builtins, ... }:
1+
{
2+
config,
3+
pkgs,
4+
lib,
5+
...
6+
}:
27
let
3-
inherit (lib) mkIf types mkDefault mkOption mkMerge strings;
4-
inherit (builtins) head toString map tail;
5-
in {
8+
cfg = config.email;
9+
in
10+
{
611
options.email = {
7-
fromAddress = mkOption {
12+
enable = lib.mkEnableOption "Email sending functionality";
13+
fromAddress = lib.mkOption {
814
description = "The 'from' address";
9-
type = types.str;
15+
type = lib.types.str;
1016
default = "[email protected]";
1117
};
12-
toAddress = mkOption {
18+
toAddress = lib.mkOption {
1319
description = "The 'to' address";
14-
type = types.str;
20+
type = lib.types.str;
1521
default = "[email protected]";
1622
};
17-
smtpServer = mkOption {
23+
smtpServer = lib.mkOption {
1824
description = "The SMTP server address";
19-
type = types.str;
25+
type = lib.types.str;
2026
default = "smtp.example.com";
2127
};
22-
smtpUsername = mkOption {
28+
smtpUsername = lib.mkOption {
2329
description = "The SMTP username";
24-
type = types.str;
30+
type = lib.types.str;
2531
default = "[email protected]";
2632
};
27-
smtpPasswordPath = mkOption {
33+
smtpPasswordPath = lib.mkOption {
2834
description = "Path to the secret containing SMTP password";
29-
type = types.path;
30-
};
35+
type = lib.types.path;
3136
};
37+
};
3238

33-
config.programs.msmtp = {
34-
enable = true;
35-
accounts.default = {
36-
auth = true;
37-
host = config.email.smtpServer;
38-
from = config.email.fromAddress;
39-
user = config.email.smtpUsername;
40-
tls = true;
41-
passwordeval = "${pkgs.coreutils}/bin/cat ${config.email.smtpPasswordPath}";
39+
config = lib.mkIf cfg.enable {
40+
programs.msmtp = {
41+
enable = true;
42+
accounts.default = {
43+
auth = true;
44+
host = config.email.smtpServer;
45+
from = config.email.fromAddress;
46+
user = config.email.smtpUsername;
47+
tls = true;
48+
passwordeval = "${pkgs.coreutils}/bin/cat ${config.email.smtpPasswordPath}";
49+
};
4250
};
4351
};
4452

45-
46-
}
53+
}

modules/podman/default.nix

Lines changed: 0 additions & 16 deletions
This file was deleted.

users/notthebee/default.nix

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
config,
33
inputs,
44
pkgs,
5-
lib,
65
...
76
}:
87
{
@@ -12,14 +11,6 @@
1211
file = "${inputs.secrets}/hashedUserPassword.age";
1312
};
1413

15-
email = {
16-
fromAddress = "[email protected]";
17-
toAddress = "[email protected]";
18-
smtpServer = "email-smtp.eu-west-1.amazonaws.com";
19-
smtpUsername = "AKIAYYXVLL34J7LSXFZF";
20-
smtpPasswordPath = config.age.secrets.smtpPassword.path;
21-
};
22-
2314
users = {
2415
users = {
2516
notthebee = {

0 commit comments

Comments
 (0)