diff --git a/machines/web02/cas-eleves/default.nix b/machines/web02/cas-eleves/default.nix index e656009..20aa87b 100644 --- a/machines/web02/cas-eleves/default.nix +++ b/machines/web02/cas-eleves/default.nix @@ -19,6 +19,8 @@ let ps.psycopg # Local packages + (ps.callPackage ./packages/django-browser-reload { }) + (ps.callPackage ./packages/django-bulma-forms { }) (ps.callPackage ./packages/django-cas-server { }) (ps.callPackage ./packages/loadcredential { }) ]); @@ -48,10 +50,13 @@ in { systemd.services = { - "django-cas-eleves" = { + django-cas-eleves = { description = "ENS CAS server"; wantedBy = [ "multi-user.target" ]; - after = [ "network.target" ]; + after = [ + "network.target" + "postgresql.service" + ]; serviceConfig = { DynamicUser = true; @@ -78,6 +83,31 @@ in gunicorn app.wsgi --pythonpath ${sources.cas-eleves} -b 127.0.0.1:${builtins.toString port} --workers=2 --threads=4 ''; }; + + cas-eleves-cleanup = { + description = "Periodic cleanup of cas_server database"; + + startAt = "daily"; + + serviceConfig = { + Type = "oneshot"; + + LoadCredential = mapAttrsToList (name: value: "${name}:${value}") { + SECRET_KEY = config.age.secrets."cas_eleves-secret_key_file".path; + }; + StateDirectory = "django-cas-eleves"; + User = "cas_server"; + WorkingDirectory = sources.cas-eleves; + }; + + path = [ pythonEnv ]; + + script = '' + python3 manage.py clearsessions + python3 manage.py cas_clean_sessions + python3 manage.py cas_clean_tickets + ''; + }; }; services = { diff --git a/machines/web02/cas-eleves/packages/django-browser-reload/default.nix b/machines/web02/cas-eleves/packages/django-browser-reload/default.nix new file mode 100644 index 0000000..96d243f --- /dev/null +++ b/machines/web02/cas-eleves/packages/django-browser-reload/default.nix @@ -0,0 +1,42 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + setuptools, + wheel, + asgiref, + django, +}: + +buildPythonPackage rec { + pname = "django-browser-reload"; + version = "1.12.1"; + pyproject = true; + + src = fetchFromGitHub { + owner = "adamchainz"; + repo = "django-browser-reload"; + rev = version; + hash = "sha256-IDIkAl6YYI3isDvpzCtAu4fLSr2gbjEvVW+K1WBDPbo="; + }; + + nativeBuildInputs = [ + setuptools + wheel + ]; + + propagatedBuildInputs = [ + asgiref + django + ]; + + pythonImportsCheck = [ "django_browser_reload" ]; + + meta = with lib; { + description = "Automatically reload your browser in development"; + homepage = "https://github.com/adamchainz/django-browser-reload"; + changelog = "https://github.com/adamchainz/django-browser-reload/blob/${src.rev}/CHANGELOG.rst"; + license = licenses.mit; + maintainers = [ ]; # with maintainers; [ thubrecht ]; + }; +} diff --git a/machines/web02/cas-eleves/packages/django-bulma-forms/default.nix b/machines/web02/cas-eleves/packages/django-bulma-forms/default.nix new file mode 100644 index 0000000..58403f3 --- /dev/null +++ b/machines/web02/cas-eleves/packages/django-bulma-forms/default.nix @@ -0,0 +1,36 @@ +{ + lib, + buildPythonPackage, + fetchgit, + setuptools, + setuptools-scm, + wheel, + django, +}: + +buildPythonPackage rec { + pname = "django-bulma-forms"; + version = "0.1.4"; + pyproject = true; + + src = fetchgit { + url = "https://git.hubrecht.ovh/hubrecht/django-bulma-forms"; + rev = "v${version}"; + hash = "sha256-4KTMXx3YxDxB4/YH14pJnNYtpOGXeDmD+gcbrUHwD/w="; + }; + + nativeBuildInputs = [ + setuptools + setuptools-scm + wheel + ]; + + propagatedBuildInputs = [ django ]; + + meta = with lib; { + description = ""; + homepage = "https://git.hubrecht.ovh/hubrecht/django-bulma-forms"; + license = licenses.eupl12; + maintainers = [ ]; # with maintainers; [ thubrecht ]; + }; +} diff --git a/npins/sources.json b/npins/sources.json index 22d961b..c276858 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -9,7 +9,6 @@ }, "pre_releases": false, "version_upper_bound": null, - "release_prefix": null, "version": "0.15.0", "revision": "564595d0ad4be7277e07fa63b5a991b3c645655d", "url": "https://api.github.com/repos/ryantm/agenix/tarball/0.15.0", @@ -46,9 +45,9 @@ "url": "https://git.dgnum.eu/DGNum/cas-eleves.git" }, "branch": "main", - "revision": "b47165f64cffcccac7e8c5b24f8993176d16db64", + "revision": "f31ca3f45a86432055a9eb0f2b8e430acf118839", "url": null, - "hash": "00f4n6mpc7sn4rlbn22bzbd7l0mn35s0llf3ad5ff5ln626iscbz" + "hash": "0ql2snp9y37ilkdm3lbb8cwg76npmxcn8vbf195p95m9mcj6hdry" }, "disko": { "type": "GitRelease", @@ -59,7 +58,6 @@ }, "pre_releases": false, "version_upper_bound": null, - "release_prefix": null, "version": "v1.6.0", "revision": "5eaf747af38dd272e1ab28a8ec4bd972424b07cf", "url": "https://api.github.com/repos/nix-community/disko/tarball/v1.6.0", @@ -73,7 +71,6 @@ }, "pre_releases": false, "version_upper_bound": null, - "release_prefix": null, "version": "v1.2.1", "revision": "66979725afe2164491be38ffff78460cc9b0ffd7", "url": null, @@ -122,7 +119,6 @@ }, "pre_releases": false, "version_upper_bound": null, - "release_prefix": null, "version": "0.1.6", "revision": "ffb3dfa4c146d48300bd4fa625acfe48e091a734", "url": null, @@ -147,7 +143,6 @@ }, "pre_releases": false, "version_upper_bound": null, - "release_prefix": null, "version": "v0.5.0", "revision": "e11ba20945f4a867f09d84343c37328288f274b4", "url": null,