infrastructure/machines/nixos/web03/django-apps/gestiocof.nix

157 lines
4 KiB
Nix
Raw Normal View History

# SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
#
# SPDX-License-Identifier: EUPL-1.2
{ config, lib, ... }:
let
inherit (lib) listToAttrs nameValuePair;
in
{
services.django-apps.sites.gestiocof = {
source = "https://git.dgnum.eu/DGNum/gestioCOF";
branch = "cof-prod";
2025-02-24 15:33:42 +01:00
domain = "cof.ens.fr";
nginx = {
enableACME = true;
forceSSL = true;
locations =
{
"/ws/" = {
proxyPass = "http://unix:/run/django-apps/gestiocof/socket";
proxyWebsockets = true;
};
}
// (listToAttrs (
builtins.map (folder: nameValuePair "~ ^/${folder}/" { root = "/users/guests/cof/www/"; }) [
"arcanoid"
"cirque"
"pompom"
"trouveres"
]
));
extraConfig = ''
rewrite ^/$ /news;
'';
};
webHookSecret = config.age.secrets."webhook-gestiocof_token".path;
2025-01-11 19:05:48 +01:00
overlays = {
kat-pkgs = [
"django-djconfig"
"django-hCaptcha"
"wagtail-modeltranslation"
"wagtailmenus"
"django-cogwheels"
];
nix-pkgs = [
# Required packages
"authens"
"django-bootstrap-form"
"django-cas-ng"
"loadcredential"
2025-01-11 19:05:48 +01:00
# Dependencies
"python-cas"
];
};
dependencies = ps: [
ps.authens
ps.channels
ps.channels-redis
ps.configparser
ps.django
ps.django-autocomplete-light
ps.django-bootstrap-form
ps.django-cas-ng
ps.django-cors-headers
ps.django-djconfig
ps.django-hCaptcha
ps.django-js-reverse
ps.django-widget-tweaks
ps.icalendar
ps.loadcredential
ps.pillow
ps.python-dateutil
ps.redis
ps.statistics
ps.wagtail
ps.wagtail-modeltranslation
ps.wagtailmenus
];
application = {
module = "gestioasso";
type = "daphne";
settingsModule = "gestioasso.settings_cof";
};
credentials = {
SECRET_KEY = config.age.secrets."dj_gestiocof-secret_key_file".path;
HCAPTCHA_SECRET = config.age.secrets."dj_gestiocof-hcaptcha_secret_file".path;
HCAPTCHA_SITEKEY = config.age.secrets."dj_gestiocof-hcaptcha_sitekey_file".path;
KFETOPEN_TOKEN = config.age.secrets."dj_gestiocof-kfetopen_token_file".path;
2025-02-20 12:49:35 +01:00
SYMPA_PASSWORD = config.age.secrets."dj_gestiocof-sympa_password_file".path;
SYMPA_USERNAME = config.age.secrets."dj_gestiocof-sympa_username_file".path;
2025-02-24 18:15:33 +01:00
EMAIL_HOST = config.age.secrets."dj_gestiocof-email_host_file".path;
};
environment = {
GESTIOCOF_CHANNEL_LAYERS.default = {
BACKEND = "shared.channels.ChannelLayer";
CONFIG.hosts = [ "unix://${config.services.redis.servers.gestiocof.unixSocket}" ];
};
GESTIOCOF_CACHES.default = {
BACKEND = "django.core.cache.backends.redis.RedisCache";
LOCATION = "unix://${config.services.redis.servers.gestiocof.unixSocket}";
};
GESTIOCOF_CORS_ALLOWED_ORIGINS = [
"https://${config.services.django-apps.sites.gestiocof.domain}"
];
2025-02-24 18:15:33 +01:00
GESTIOCOF_SERVER_EMAIL = "gestion@cof.ens.fr";
};
extraServices.worker = {
script = "python3 manage.py runworker default";
serviceConfig = {
WorkingDirectory = "/var/lib/django-apps/gestiocof/source";
SupplementaryGroups = [ "redis-gestiocof" ];
};
};
2025-02-24 16:24:57 +01:00
timers = {
rappel-negatifs = {
script = ''
python3 manage.py sendrappelsnegatifs
'';
startAt = "*-*-* 1,13:17:19";
};
rappel-bda = {
script = ''
python3 manage.py sendrappels
'';
startAt = "*-*-* 2,14:17:19";
};
manage-reventes = {
script = ''
python3 manage.py manage_reventes
'';
startAt = "*-*-* *:01..56/5:29";
};
};
};
services.redis.servers.gestiocof = {
enable = true;
};
systemd.services.dj-gestiocof.serviceConfig.SupplementaryGroups = [ "redis-gestiocof" ];
}