2021-12-17 09:33:40 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, mkYarnPackage, nixosTests, writeText, python3 }:
|
2021-01-18 22:18:23 +00:00
|
|
|
|
|
|
|
let
|
2022-06-19 18:29:09 +00:00
|
|
|
version = "0.3.0";
|
2021-01-18 22:18:23 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ngoduykhanh";
|
|
|
|
repo = "PowerDNS-Admin";
|
|
|
|
rev = "v${version}";
|
2022-06-19 18:29:09 +00:00
|
|
|
hash = "sha256-e11u0jdJr+2TDXvBAPlDfnuuDwSfBq+JtvnDUTNKp/c=";
|
2021-01-18 22:18:23 +00:00
|
|
|
};
|
|
|
|
|
2021-06-22 21:35:46 +00:00
|
|
|
python = python3.override {
|
|
|
|
packageOverrides = self: super: {
|
2022-05-24 22:07:16 +00:00
|
|
|
# The bravado-core dependency is incompatible with jschonschema 4.0:
|
|
|
|
# https://github.com/Yelp/bravado-core/pull/385
|
2022-09-27 00:30:48 +00:00
|
|
|
jsonschema = super.jsonschema_3;
|
2021-06-22 21:35:46 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
pythonDeps = with python.pkgs; [
|
2022-10-17 18:39:24 +00:00
|
|
|
flask flask_assets flask-login flask-sqlalchemy flask_migrate flask-seasurf flask_mail flask-session flask-sslify
|
2021-12-17 09:33:40 +00:00
|
|
|
mysqlclient psycopg2 sqlalchemy
|
2022-09-15 23:54:14 +00:00
|
|
|
cffi configobj cryptography bcrypt requests python-ldap pyotp qrcode dnspython
|
2022-06-19 18:29:09 +00:00
|
|
|
gunicorn python3-saml pytz cssmin rjsmin authlib bravado-core
|
|
|
|
lima pytimeparse pyyaml jinja2 itsdangerous werkzeug
|
2021-01-18 22:18:23 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
assets = mkYarnPackage {
|
|
|
|
inherit src version;
|
|
|
|
packageJSON = ./package.json;
|
|
|
|
yarnNix = ./yarndeps.nix;
|
|
|
|
|
|
|
|
nativeBuildInputs = pythonDeps;
|
|
|
|
patchPhase = ''
|
|
|
|
sed -i -r -e "s|'cssmin',\s?'cssrewrite'|'cssmin'|g" powerdnsadmin/assets.py
|
|
|
|
'';
|
|
|
|
buildPhase = ''
|
|
|
|
# The build process expects the directory to be writable
|
|
|
|
# with node_modules at a specific path
|
|
|
|
# https://github.com/ngoduykhanh/PowerDNS-Admin/blob/master/.yarnrc
|
|
|
|
|
|
|
|
approot=deps/powerdns-admin-assets
|
|
|
|
|
|
|
|
ln -s $node_modules $approot/powerdnsadmin/static/node_modules
|
|
|
|
FLASK_APP=$approot/powerdnsadmin/__init__.py flask assets build
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
# https://github.com/ngoduykhanh/PowerDNS-Admin/blob/54b257768f600c5548a1c7e50eac49c40df49f92/docker/Dockerfile#L43
|
|
|
|
mkdir $out
|
|
|
|
cp -r $approot/powerdnsadmin/static/{generated,assets,img} $out
|
|
|
|
find $node_modules/icheck/skins/square -name '*.png' -exec cp {} $out/generated \;
|
|
|
|
|
|
|
|
mkdir $out/fonts
|
|
|
|
cp $node_modules/ionicons/dist/fonts/* $out/fonts
|
|
|
|
cp $node_modules/bootstrap/dist/fonts/* $out/fonts
|
|
|
|
cp $node_modules/font-awesome/fonts/* $out/fonts
|
|
|
|
'';
|
|
|
|
distPhase = "true";
|
|
|
|
};
|
|
|
|
|
|
|
|
assetsPy = writeText "assets.py" ''
|
|
|
|
from flask_assets import Environment
|
|
|
|
assets = Environment()
|
|
|
|
assets.register('js_login', 'generated/login.js')
|
|
|
|
assets.register('js_validation', 'generated/validation.js')
|
|
|
|
assets.register('css_login', 'generated/login.css')
|
|
|
|
assets.register('js_main', 'generated/main.js')
|
|
|
|
assets.register('css_main', 'generated/main.css')
|
|
|
|
'';
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
pname = "powerdns-admin";
|
|
|
|
|
|
|
|
inherit src version;
|
|
|
|
|
2021-06-22 21:35:46 +00:00
|
|
|
nativeBuildInputs = [ python.pkgs.wrapPython ];
|
2021-01-18 22:18:23 +00:00
|
|
|
|
|
|
|
pythonPath = pythonDeps;
|
|
|
|
|
|
|
|
gunicornScript = ''
|
|
|
|
#!/bin/sh
|
|
|
|
if [ ! -z $CONFIG ]; then
|
|
|
|
exec python -m gunicorn.app.wsgiapp "powerdnsadmin:create_app(config='$CONFIG')" "$@"
|
|
|
|
fi
|
|
|
|
|
|
|
|
exec python -m gunicorn.app.wsgiapp "powerdnsadmin:create_app()" "$@"
|
|
|
|
'';
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
rm -r powerdnsadmin/static powerdnsadmin/assets.py
|
2021-12-17 09:33:40 +00:00
|
|
|
sed -i "s/id:/'id':/" migrations/versions/787bdba9e147_init_db.py
|
2021-01-18 22:18:23 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
# Nasty hack: call wrapPythonPrograms to set program_PYTHONPATH (see tribler)
|
|
|
|
wrapPythonPrograms
|
|
|
|
|
|
|
|
mkdir -p $out/share $out/bin
|
2021-12-17 09:33:40 +00:00
|
|
|
cp -r migrations powerdnsadmin $out/share/
|
2021-01-18 22:18:23 +00:00
|
|
|
|
|
|
|
ln -s ${assets} $out/share/powerdnsadmin/static
|
|
|
|
ln -s ${assetsPy} $out/share/powerdnsadmin/assets.py
|
|
|
|
|
|
|
|
echo "$gunicornScript" > $out/bin/powerdns-admin
|
|
|
|
chmod +x $out/bin/powerdns-admin
|
|
|
|
wrapProgram $out/bin/powerdns-admin \
|
2021-06-22 21:35:46 +00:00
|
|
|
--set PATH ${python.pkgs.python}/bin \
|
2021-01-18 22:18:23 +00:00
|
|
|
--set PYTHONPATH $out/share:$program_PYTHONPATH
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2021-12-17 09:33:40 +00:00
|
|
|
passthru = {
|
|
|
|
# PYTHONPATH of all dependencies used by the package
|
|
|
|
pythonPath = python3.pkgs.makePythonPath pythonDeps;
|
|
|
|
tests = nixosTests.powerdns-admin;
|
|
|
|
};
|
|
|
|
|
2021-01-18 22:18:23 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "A PowerDNS web interface with advanced features";
|
|
|
|
homepage = "https://github.com/ngoduykhanh/PowerDNS-Admin";
|
|
|
|
license = licenses.mit;
|
2021-11-23 21:00:08 +00:00
|
|
|
maintainers = with maintainers; [ Flakebi zhaofengli ];
|
2021-01-18 22:18:23 +00:00
|
|
|
};
|
|
|
|
}
|