courses: phil: init as container #73

Merged
rouven0 merged 4 commits from philo-kurse into main 2023-09-27 16:43:12 +02:00
Showing only changes of commit 8908b3bbff - Show all commits

53
modules/courses-phil.nix Normal file
View file

@ -0,0 +1,53 @@
{ config, lib, ... }:
let
hostName = "phil.${config.networking.domain}";
in
{
containers."courses-phil".config = {
sops.secrets =
let inherit (config.services.course-management) user;
in
{
"course-management/secret-key".owner = user;
"course-management/adminpass".owner = user;
};
systemd.services.course-management.after = [ "postgresql.service" ];
services.course-management = {
inherit hostName;
enable = true;
settings = {
secretKeyFile = config.sops.secrets."course-management-phil/secret-key".path;
adminPassFile = config.sops.secrets."course-management-phil/adminpass".path;
admins = [{
name = "Root iFSR";
email = "root@${config.networking.domain}";
}];
database = {
ENGINE = "django.db.backends.postgresql";
NAME = "course-management";
};
email = lib.mkDefault {
fromEmail = "noreply@${config.networking.domain}";
serverEmail = "root@${config.networking.domain}";
};
};
};
services.postgresql = {
enable = true;
ensureUsers = [{
name = "course-management";
ensurePermissions = {
"DATABASE \"course-management\"" = "ALL PRIVILEGES";
};
}];
ensureDatabases = [ "course-management" ];
};
services.nginx.virtualHosts.${hostName} = {
enableACME = true;
forceSSL = true;
};
};
}