feat: updated flake with the email config

This commit is contained in:
silver 2023-07-30 04:29:37 +01:00
parent 53409add42
commit f5b4431214

View file

@ -45,17 +45,22 @@
with lib;
let
cfg = config.services."${package_name}";
enviroment_config = {
# secret options are in the env file loaded separately
environment_config = {
# non secret ldap stuff
LDAP_HOST = cfg.ldap.host;
LDAP_ADMIN = cfg.ldap.admin;
# basic dserver stuff
HOME = cfg.home;
# basic server stuff
HOME = "${cfg.home}";
DATABASE = "database.db";
CSV = "wolves.csv";
HOST_PORT = cfg.host_port;
# Email stuff
EMAIL_SMTP = cfg.mail.host
EMAIL_USER = cfg.mail.user
# special categories of users
USERS_ADMIN = lib.strings.concatStringsSep "," cfg.users.admin;
USERS_COMMITTEE = lib.strings.concatStringsSep "," cfg.users.committee;
@ -84,6 +89,20 @@
};
};
mail = {
host = mkOption rec {
type = types.str;
default = "mail.skynet.ie";
description = "Email Host";
};
user = mkOption rec {
type = types.str;
default = "compsoc@skynet.ie";
description = "User for sending emails";
};
};
users = {
admin = mkOption rec {
type = types.listOf types.str;
@ -144,7 +163,7 @@
wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" ];
wants = [ ];
environment = enviroment_config;
environment = environment_config;
serviceConfig = {
# because we are storing data we need a home for it
@ -161,12 +180,12 @@
description = "${desc} Update groups";
wantedBy = [ ];
after = [ "network-online.target" ];
environment = enviroment_config;
environment = environment_config;
serviceConfig = {
Type = "oneshot";
DynamicUser = true;
ExecStart = "${self.defaultPackage."${system}"}/bin/${package_update}";
ExecStart = "${self.defaultPackage."${system}"}/bin/update_groups";
EnvironmentFile = "${cfg.envFile}";
};
};
@ -183,6 +202,32 @@
};
};
# for new users
systemd.services."${cfg.user}_new_users" = {
description = "${desc} Get new users";
wantedBy = [ ];
after = [ "network-online.target" ];
environment = environment_config;
serviceConfig = {
Type = "oneshot";
DynamicUser = true;
ExecStart = "${self.defaultPackage."${system}"}/bin/new_users";
EnvironmentFile = "${cfg.envFile}";
};
};
systemd.timers."${cfg.user}_new_users" = {
description = "Run the new users script for ${desc}";
wantedBy = [ "timers.target" ];
partOf = [ "${cfg.user}_new_users.service" ];
timerConfig = {
# every hour
OnCalendar = "*-*-* *:15:00";
Unit = "${cfg.user}_update.service";
};
};
};
};