From 95ebb0ea4b8a87d36382ac88a2c060cd246388ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sat, 14 Dec 2024 22:14:40 +0100 Subject: [PATCH] nixos/powerdns-admin: adapt for newer flask-session It broke somewhere between NixOS 24.05 and 24.11 due to flask-session being upgraded. It now requires an explicit value and an empty string will no longer do. cachelib's SimpleCache was chosen as it doesn't require any other configuration, and keeps previous behaviour. --- nixos/modules/services/web-apps/powerdns-admin.nix | 9 ++++++++- nixos/tests/powerdns-admin.nix | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/web-apps/powerdns-admin.nix b/nixos/modules/services/web-apps/powerdns-admin.nix index 7c23cd10efad..e142711555ca 100644 --- a/nixos/modules/services/web-apps/powerdns-admin.nix +++ b/nixos/modules/services/web-apps/powerdns-admin.nix @@ -42,14 +42,21 @@ in type = types.str; default = ""; example = '' + import cachelib + BIND_ADDRESS = '127.0.0.1' PORT = 8000 SQLALCHEMY_DATABASE_URI = 'postgresql://powerdnsadmin@/powerdnsadmin?host=/run/postgresql' + SESSION_TYPE = 'cachelib' + SESSION_CACHELIB = cachelib.simple.SimpleCache() ''; description = '' Configuration python file. See [the example configuration](https://github.com/ngoduykhanh/PowerDNS-Admin/blob/v${pkgs.powerdns-admin.version}/configs/development.py) for options. + Also see [Flask Session configuration](https://flask-session.readthedocs.io/en/latest/config.html#SESSION_TYPE) + as the version shipped with NixOS is more recent than the one PowerDNS-Admin expects + and it requires explicit configuration. ''; }; @@ -85,7 +92,7 @@ in serviceConfig = { ExecStart = "${pkgs.powerdns-admin}/bin/powerdns-admin --pid /run/powerdns-admin/pid ${escapeShellArgs cfg.extraArgs}"; # Set environment variables only for starting flask database upgrade - ExecStartPre = "${pkgs.coreutils}/bin/env FLASK_APP=${pkgs.powerdns-admin}/share/powerdnsadmin/__init__.py SESSION_TYPE= ${pkgs.python3Packages.flask}/bin/flask db upgrade -d ${pkgs.powerdns-admin}/share/migrations"; + ExecStartPre = "${pkgs.coreutils}/bin/env FLASK_APP=${pkgs.powerdns-admin}/share/powerdnsadmin/__init__.py ${pkgs.python3Packages.flask}/bin/flask db upgrade -d ${pkgs.powerdns-admin}/share/migrations"; ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; ExecStop = "${pkgs.coreutils}/bin/kill -TERM $MAINPID"; PIDFile = "/run/powerdns-admin/pid"; diff --git a/nixos/tests/powerdns-admin.nix b/nixos/tests/powerdns-admin.nix index 1f9354927acd..0ed31f46607f 100644 --- a/nixos/tests/powerdns-admin.nix +++ b/nixos/tests/powerdns-admin.nix @@ -9,9 +9,13 @@ with import ../lib/testing-python.nix { inherit system pkgs; }; with pkgs.lib; let defaultConfig = '' + import cachelib + BIND_ADDRESS = '127.0.0.1' PORT = 8000 CAPTCHA_ENABLE = False + SESSION_TYPE = 'cachelib' + SESSION_CACHELIB = cachelib.simple.SimpleCache() ''; makeAppTest =