2023-09-17 20:14:32 +02:00
|
|
|
{ config, lib, ... }:
|
2023-06-08 13:34:45 +02:00
|
|
|
let
|
2023-09-17 20:10:55 +02:00
|
|
|
hostName = "kurse.${config.networking.domain}";
|
2023-06-08 13:34:45 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
sops.secrets =
|
|
|
|
let inherit (config.services.course-management) user;
|
2023-07-19 15:46:49 +02:00
|
|
|
in
|
|
|
|
{
|
2023-06-08 13:34:45 +02:00
|
|
|
"course-management/secret-key".owner = user;
|
|
|
|
"course-management/adminpass".owner = user;
|
|
|
|
};
|
|
|
|
|
2023-08-21 12:10:44 +02:00
|
|
|
systemd.services.course-management.after = [ "postgresql.service" ];
|
2023-06-08 13:34:45 +02:00
|
|
|
services.course-management = {
|
|
|
|
inherit hostName;
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
secretKeyFile = config.sops.secrets."course-management/secret-key".path;
|
|
|
|
adminPassFile = config.sops.secrets."course-management/adminpass".path;
|
|
|
|
admins = [{
|
|
|
|
name = "Root iFSR";
|
2023-09-17 20:10:55 +02:00
|
|
|
email = "root@${config.networking.domain}";
|
2023-06-08 13:34:45 +02:00
|
|
|
}];
|
|
|
|
database = {
|
|
|
|
ENGINE = "django.db.backends.postgresql";
|
|
|
|
NAME = "course-management";
|
|
|
|
};
|
|
|
|
email = lib.mkDefault {
|
2023-09-17 20:10:55 +02:00
|
|
|
fromEmail = "noreply@${config.networking.domain}";
|
|
|
|
serverEmail = "root@${config.networking.domain}";
|
2023-06-08 13:34:45 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.postgresql = {
|
2023-07-19 15:46:49 +02:00
|
|
|
enable = lib.mkForce true; # upstream bacula config wants to disable it, so we need to force
|
2023-06-08 13:34:45 +02:00
|
|
|
ensureUsers = [{
|
|
|
|
name = "course-management";
|
|
|
|
ensurePermissions = {
|
|
|
|
"DATABASE \"course-management\"" = "ALL PRIVILEGES";
|
|
|
|
};
|
|
|
|
}];
|
|
|
|
ensureDatabases = [ "course-management" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx.virtualHosts.${hostName} = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
2023-09-28 13:34:58 +02:00
|
|
|
|
|
|
|
# phil redirects
|
|
|
|
locations =
|
|
|
|
let
|
|
|
|
philDomain = "https://kurse-phil.ifsr.de";
|
|
|
|
courses = [ "238" "239" "240" "241" "242" "243" ];
|
|
|
|
subjects = [
|
|
|
|
"ESE 2023 PHIL Campustour"
|
|
|
|
"ESE 2023 PHIL Bowlingabend"
|
|
|
|
"ESE 2023 PHIL Filmabend"
|
|
|
|
"ESE 2023 PHIL Wandern"
|
|
|
|
"ESE 2023 PHIL Spieleabend Pen and Paper"
|
|
|
|
];
|
|
|
|
in
|
|
|
|
{
|
|
|
|
"~ \"^/course/(${builtins.concatStringsSep "|" courses})/\"".return = "301 ${philDomain}/course/$1";
|
|
|
|
"~ \"^/subject/(${builtins.concatStringsSep "|" subjects})/\"".return = "301 ${philDomain}/subject/$1";
|
|
|
|
};
|
2023-06-08 13:34:45 +02:00
|
|
|
};
|
|
|
|
}
|