From be128f6c3abcfff47f1f843d3c9eebda50737b38 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Sun, 28 Jul 2024 14:29:54 +0200 Subject: [PATCH] feat(kadenios): Fix build of static files and restore cas.eleves.ens.fr for authens --- .../web02/kadenios/01-authens-cas-url.patch | 11 --- machines/web02/kadenios/default.nix | 67 +++++++++++-------- 2 files changed, 38 insertions(+), 40 deletions(-) delete mode 100644 machines/web02/kadenios/01-authens-cas-url.patch diff --git a/machines/web02/kadenios/01-authens-cas-url.patch b/machines/web02/kadenios/01-authens-cas-url.patch deleted file mode 100644 index 4917c63..0000000 --- a/machines/web02/kadenios/01-authens-cas-url.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff --git a/src/authens/utils.py b/src/authens/utils.py -index 7306506..36063b6 100644 ---- a/src/authens/utils.py -+++ b/src/authens/utils.py -@@ -16,7 +16,7 @@ def get_cas_client(request): - service_url=urlunparse( - (request.scheme, request.get_host(), request.path, "", "", "") - ), -- server_url="https://cas.eleves.ens.fr/", -+ server_url="https://cas-eleves.dgnum.eu/", - ) diff --git a/machines/web02/kadenios/default.nix b/machines/web02/kadenios/default.nix index a25ec1e..a20f22c 100644 --- a/machines/web02/kadenios/default.nix +++ b/machines/web02/kadenios/default.nix @@ -7,7 +7,7 @@ }: let - inherit (lib) mapAttrsToList; + inherit (lib) mapAttrsToList optionals; port = 9888; @@ -18,45 +18,56 @@ let pkgs.python3.override { packageOverrides = _: _: { inherit (nix-pkgs) + authens django-background-tasks + django-browser-reload django-bulma-forms django-translated-fields loadcredential ; - - authens = nix-pkgs.authens.overridePythonAttrs (_: { - patches = [ ./01-authens-cas-url.patch ]; - }); }; }; - pythonEnv = python3.withPackages (ps: [ - ps.django + pythonEnv = + { + debug ? false, + }: + python3.withPackages ( + ps: + [ + ps.django - ps.gunicorn + ps.gunicorn - ps.markdown - ps.numpy - ps.networkx - ps.psycopg + ps.markdown + ps.numpy + ps.networkx + ps.psycopg - ps.authens - ps.django-background-tasks - ps.django-bulma-forms - ps.django-translated-fields - ps.loadcredential - ]); + ps.authens + ps.django-background-tasks + ps.django-bulma-forms + ps.django-translated-fields + ps.loadcredential + ] + ++ (optionals debug [ + ps.django-browser-reload + ps.django-debug-toolbar + ]) + ); manage = pkgs.writeShellApplication { name = "kadenios-manage"; - runtimeInputs = [ pythonEnv ]; + runtimeInputs = path ++ [ + config.systemd.package + pkgs.util-linux + ]; text = '' - MainPID=0 - eval "$(${lib.getExe' config.systemd.package "systemctl"} show -pMainPID django-kadenios.service)" + MainPID=$(systemctl show -p MainPID --value django-kadenios.service) - ${lib.getExe' pkgs.util-linux "nsenter"} -e -a -t "$MainPID" -G follow -S follow python ${sources.kadenios}/manage.py "$@" + nsenter -e -a -t "$MainPID" -G follow -S follow python ${sources.kadenios}/manage.py "$@" ''; }; @@ -65,7 +76,7 @@ let src = sources.kadenios; - nativeBuildInputs = [ pythonEnv ]; + nativeBuildInputs = [ (pythonEnv { debug = true; }) ]; configurePhase = '' export KADENIOS_STATIC_ROOT=$out/static @@ -95,6 +106,8 @@ let KADENIOS_FROM_EMAIL = "Kadenios "; KADENIOS_SERVER_EMAIL = "kadenios@infra.dgnum.eu"; }; + + path = [ (pythonEnv { }) ]; in { @@ -118,9 +131,7 @@ in User = "kadenios"; }; - inherit environment; - - path = [ pythonEnv ]; + inherit environment path; script = '' python3 ${sources.kadenios}/manage.py migrate @@ -149,9 +160,7 @@ in WorkingDirectory = sources.kadenios; }; - inherit environment; - - path = [ pythonEnv ]; + inherit environment path; script = '' python3 manage.py process_tasks