Skip to content

Commit

Permalink
powerdns-admin: fix build
Browse files Browse the repository at this point in the history
Fix build with updated flask.
  • Loading branch information
Flakebi committed Dec 2, 2023
1 parent c20ddec commit ec9f89a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkgs/applications/networking/powerdns-admin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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 = ''
Expand Down

0 comments on commit ec9f89a

Please sign in to comment.