Extra msmtp settings to module

This commit is contained in:
Sandro - 2023-12-20 23:14:15 +01:00
parent 9e2296a05a
commit d788c3718e
Signed by: sandro
GPG Key ID: 3AF5A43A3EECC2E5
4 changed files with 64 additions and 51 deletions

View File

@ -304,15 +304,5 @@
time.timeZone = lib.mkDefault "Europe/Berlin"; time.timeZone = lib.mkDefault "Europe/Berlin";
users = { users.motdFile = ./motd;
motdFile = ./motd;
users = let
adminKeys = with builtins; lib.lists.flatten (attrValues cfg.sshKeys);
in {
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/profiles/installation-device.nix#L23
nixos = lib.mkIf (config.system.nixos.variant_id == "installer") { openssh.authorizedKeys.keys = adminKeys; };
root.openssh.authorizedKeys.keys = adminKeys;
};
};
} }

View File

@ -1,7 +1,10 @@
{ config, pkgs, lib, libC, ... }: { config, pkgs, lib, libC, ... }:
{ {
c3d2.deployment.server = "server10"; c3d2 = {
deployment.server = "server10";
hq.sendmail = true;
};
microvm.mem = 4 * 1024; microvm.mem = 4 * 1024;
@ -146,18 +149,5 @@
}; };
}; };
programs.msmtp = {
enable = true;
accounts.default = {
host = "mail.c3d2.de";
port = 587;
tls = true;
tls_starttls = true;
auth = false;
domain = "gitea.c3d2.de";
from = "mail@c3d2.de";
};
};
system.stateVersion = "21.11"; system.stateVersion = "21.11";
} }

View File

@ -1,7 +1,10 @@
{ pkgs, ... }: { config, pkgs, ... }:
{ {
c3d2.deployment.server = "server10"; c3d2 = {
deployment.server = "server10";
hq.sendmail = true;
};
# microvm.mem = 2 * 1024; # microvm.mem = 2 * 1024;

View File

@ -58,6 +58,14 @@ in
# broken :( # broken :(
default = false; default = false;
}; };
sendmail = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Wether to configure sendmail via msmtp.
'';
};
}; };
nncp = { nncp = {
@ -82,27 +90,29 @@ in
}; };
config = { config = {
programs.nncp.settings = lib.optionalAttrs cfg.nncp.mergeSettings cfg.nncp; networking.interfaces = lib.mkIf (cfg.hq.interface != null) {
"${cfg.hq.interface}".ipv6.addresses = [{
address = toHqPrivateAddress config.networking.hostName;
prefixLength = 64;
}];
};
users = programs = {
let nncp.settings = lib.optionalAttrs cfg.nncp.mergeSettings cfg.nncp;
adminKeys = with builtins; lib.lists.flatten (attrValues cfg.sshKeys);
in msmtp = lib.mkIf cfg.hq.sendmail {
{ enable = true;
users.k-ot = lib.mkIf cfg.k-ot.enable { accounts.default = {
createHome = true; host = "mail.c3d2.de";
isNormalUser = true; port = 587;
uid = 1000; tls = true;
extraGroups = [ tls_starttls = true;
"audio" auth = false;
"video" domain = "gitea.c3d2.de";
"wheel" from = "mail@c3d2.de";
];
# get by running mkpasswd logged in as the user
hashedPassword = "$y$j9T$AoK/PRviZS4BDJ6jX/Qt6/$FDM/JfANEU7H0RAIuN0DL2hjYujVAVDdI0jgN5wGwB5";
openssh.authorizedKeys.keys = adminKeys;
}; };
}; };
};
services.vector = lib.mkIf config.c3d2.hq.journalToMqtt { services.vector = lib.mkIf config.c3d2.hq.journalToMqtt {
enable = true; enable = true;
@ -174,11 +184,31 @@ in
}]; }];
}; };
networking.interfaces = lib.mkIf (cfg.hq.interface != null) { users =
"${cfg.hq.interface}".ipv6.addresses = [{ let
address = toHqPrivateAddress config.networking.hostName; adminKeys = with builtins; lib.lists.flatten (attrValues cfg.sshKeys);
prefixLength = 64; in
}]; {
}; users = {
k-ot = lib.mkIf cfg.k-ot.enable {
createHome = true;
isNormalUser = true;
uid = 1000;
extraGroups = [
"audio"
"video"
"wheel"
];
# get by running mkpasswd logged in as the user
hashedPassword = "$y$j9T$AoK/PRviZS4BDJ6jX/Qt6/$FDM/JfANEU7H0RAIuN0DL2hjYujVAVDdI0jgN5wGwB5";
openssh.authorizedKeys.keys = adminKeys;
};
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/profiles/installation-device.nix#L23
nixos = lib.mkIf (config.system.nixos.variant_id == "installer") { openssh.authorizedKeys.keys = adminKeys; };
root.openssh.authorizedKeys.keys = adminKeys;
};
};
}; };
} }