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.
This commit is contained in:
Geoffrey “Frogeye” Preud'homme 2024-12-14 22:14:40 +01:00
parent e0fa4d8cfe
commit 95ebb0ea4b
No known key found for this signature in database
GPG key ID: C72403E7F82E6AD8
2 changed files with 12 additions and 1 deletions

View file

@ -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";

View file

@ -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 =