powerdns-admin: init at 0.2.3

This commit is contained in:
Zhaofeng Li 2021-01-18 14:18:23 -08:00
parent 6bc385a122
commit 0aa2fcb9ff
5 changed files with 1602 additions and 0 deletions

View file

@ -0,0 +1,111 @@
{ lib, stdenv, fetchFromGitHub, mkYarnPackage, writeText, python3Packages }:
let
version = "0.2.3";
src = fetchFromGitHub {
owner = "ngoduykhanh";
repo = "PowerDNS-Admin";
rev = "v${version}";
sha256 = "16faz57d77mxkflkvwyi8gb9wvnq2vhw79b84v1fmqvxri1yaphw";
};
pythonDeps = with python3Packages; [
flask flask_assets flask_login flask_sqlalchemy flask_migrate flask-seasurf flask_mail flask-sslify
mysqlclient sqlalchemy
configobj bcrypt requests ldap pyotp qrcode dnspython_1
gunicorn python3-saml pyopenssl pytz cssmin jsmin authlib bravado-core
lima pytimeparse pyyaml
];
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;
nativeBuildInputs = [ python3Packages.wrapPython ];
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
'';
installPhase = ''
runHook preInstall
# Nasty hack: call wrapPythonPrograms to set program_PYTHONPATH (see tribler)
wrapPythonPrograms
mkdir -p $out/share $out/bin
cp -r powerdnsadmin $out/share/powerdnsadmin
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 \
--set PATH ${python3Packages.python}/bin \
--set PYTHONPATH $out/share:$program_PYTHONPATH
runHook postInstall
'';
meta = with lib; {
description = "A PowerDNS web interface with advanced features";
homepage = "https://github.com/ngoduykhanh/PowerDNS-Admin";
license = licenses.mit;
maintainers = with maintainers; [ zhaofengli ];
};
}

View file

@ -0,0 +1,16 @@
{
"dependencies": {
"admin-lte": "2.4.9",
"bootstrap": "^3.4.1",
"bootstrap-validator": "^0.11.9",
"datatables.net-plugins": "^1.10.19",
"icheck": "^1.0.2",
"jquery-slimscroll": "^1.3.8",
"jquery-ui-dist": "^1.12.1",
"jquery.quicksearch": "^2.4.0",
"jtimeout": "^3.1.0",
"multiselect": "^0.9.12"
},
"name": "powerdns-admin-assets",
"version": "0.2.3"
}

View file

@ -0,0 +1,20 @@
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=../../../.. -i bash -p wget yarn2nix-moretea.yarn2nix jq
# This script is based upon:
# pkgs/applications/networking/instant-messengers/riot/update-riot-desktop.sh
set -euo pipefail
if [[ $# -ne 1 || $1 == -* ]]; then
echo "Regenerates the Yarn dependency lock files for the powerdns-admin package."
echo "Usage: $0 <git release version>"
exit 1
fi
WEB_SRC="https://raw.githubusercontent.com/ngoduykhanh/PowerDNS-Admin/v$1"
wget "$WEB_SRC/package.json" -O - | jq ".name = \"powerdns-admin-assets\" | .version = \"$1\"" > package.json
wget "$WEB_SRC/yarn.lock" -O yarn.lock
yarn2nix --lockfile=yarn.lock > yarndeps.nix
rm yarn.lock

File diff suppressed because it is too large Load diff

View file

@ -20084,6 +20084,8 @@ in
powerdns = callPackage ../servers/dns/powerdns { };
powerdns-admin = callPackage ../applications/networking/powerdns-admin { };
dnsdist = callPackage ../servers/dns/dnsdist { };
pdns-recursor = callPackage ../servers/dns/pdns-recursor { };