about summary refs log tree commit diff
path: root/pkgs/applications/networking/powerdns-admin
diff options
context:
space:
mode:
authorFlakebi <flakebi@t-online.de>2023-10-29 21:20:02 +0100
committerFlakebi <flakebi@t-online.de>2023-12-02 17:08:09 +0100
commitec9f89a840e82ae930af77333ede0d3098105019 (patch)
tree7338710e2469687fe4468fda99b9dc7b19378c1f /pkgs/applications/networking/powerdns-admin
parentc20ddec0fa8e1e80ebadb90e207119d2fa33550c (diff)
powerdns-admin: fix build
Fix build with updated flask.
Diffstat (limited to 'pkgs/applications/networking/powerdns-admin')
-rw-r--r--pkgs/applications/networking/powerdns-admin/default.nix16
1 files changed, 16 insertions, 0 deletions
diff --git a/pkgs/applications/networking/powerdns-admin/default.nix b/pkgs/applications/networking/powerdns-admin/default.nix
index 1e89c1b2cb46b..d029c90680237 100644
--- a/pkgs/applications/networking/powerdns-admin/default.nix
+++ b/pkgs/applications/networking/powerdns-admin/default.nix
@@ -19,6 +19,11 @@ let
     lima lxml passlib pyasn1 pytimeparse pyyaml jinja2 itsdangerous webcolors werkzeug zipp zxcvbn
   ];
 
+  all_post_patch = ''
+    # flask 2.3: 'Blueprint' object has no attribute 'before_app_first_request'
+    substituteInPlace powerdnsadmin/routes/index.py --replace '@index_bp.before_app_first_request' ""
+  '';
+
   assets = mkYarnPackage {
     inherit src version;
     packageJSON = ./package.json;
@@ -37,6 +42,7 @@ let
     nativeBuildInputs = pythonDeps;
     patchPhase = ''
       sed -i -r -e "s|'rcssmin',\s?'cssrewrite'|'rcssmin'|g" powerdnsadmin/assets.py
+      ${all_post_patch}
     '';
     buildPhase = ''
       # The build process expects the directory to be writable
@@ -95,6 +101,16 @@ in stdenv.mkDerivation {
     substituteInPlace powerdnsadmin/__init__.py --replace "sess = Session(app)" "app.config['SESSION_SQLALCHEMY'] = models.base.db; sess = Session(app)"
     # Routes creates session database tables, so it needs a context
     substituteInPlace powerdnsadmin/__init__.py --replace "routes.init_app(app)" "with app.app_context(): routes.init_app(app)"
+
+    # flask 2.3: 'Blueprint' object has no attribute 'before_app_first_request'
+    # Run code before app.run() instead
+    substituteInPlace run.py \
+      --replace 'from powerdnsadmin import create_app' 'from powerdnsadmin import create_app
+    from .powerdnsadmin.routes.index import register_modules' \
+      --replace 'app = create_app()' 'app = create_app()
+        with app.app_context():
+            register_modules()'
+    ${all_post_patch}
   '';
 
   installPhase = ''