Merge pull request #188575 from gador/pgadmin-6.13

This commit is contained in:
Sandro 2022-09-27 10:18:38 +02:00 committed by GitHub
commit 2e977bf954
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 113 additions and 24 deletions

View file

@ -37,27 +37,76 @@ in
}; };
initialEmail = mkOption { initialEmail = mkOption {
description = lib.mdDoc "Initial email for the pgAdmin account."; description = lib.mdDoc "Initial email for the pgAdmin account";
type = types.str; type = types.str;
}; };
initialPasswordFile = mkOption { initialPasswordFile = mkOption {
description = lib.mdDoc '' description = lib.mdDoc ''
Initial password file for the pgAdmin account. Initial password file for the pgAdmin account.
NOTE: Should be string not a store path, to prevent the password from being world readable. NOTE: Should be string not a store path, to prevent the password from being world readable
''; '';
type = types.path; type = types.path;
}; };
emailServer = {
enable = mkOption {
description = lib.mdDoc ''
Enable SMTP email server. This is necessary, if you want to use password recovery or change your own password
'';
type = types.bool;
default = false;
};
address = mkOption {
description = lib.mdDoc "SMTP server for email delivery";
type = types.str;
default = "localhost";
};
port = mkOption {
description = lib.mdDoc "SMTP server port for email delivery";
type = types.port;
default = 25;
};
useSSL = mkOption {
description = lib.mdDoc "SMTP server should use SSL";
type = types.bool;
default = false;
};
useTLS = mkOption {
description = lib.mdDoc "SMTP server should use TLS";
type = types.bool;
default = false;
};
username = mkOption {
description = lib.mdDoc "SMTP server username for email delivery";
type = types.nullOr types.str;
default = null;
};
sender = mkOption {
description = lib.mdDoc ''
SMTP server sender email for email delivery. Some servers require this to be a valid email address from that server
'';
type = types.str;
example = "noreply@example.com";
};
passwordFile = mkOption {
description = lib.mdDoc ''
Password for SMTP email account.
NOTE: Should be string not a store path, to prevent the password from being world readable
'';
type = types.path;
};
};
openFirewall = mkEnableOption (lib.mdDoc "firewall passthrough for pgadmin4"); openFirewall = mkEnableOption (lib.mdDoc "firewall passthrough for pgadmin4");
settings = mkOption { settings = mkOption {
description = lib.mdDoc '' description = lib.mdDoc ''
Settings for pgadmin4. Settings for pgadmin4.
[Documentation](https://www.pgadmin.org/docs/pgadmin4/development/config_py.html). [Documentation](https://www.pgadmin.org/docs/pgadmin4/development/config_py.html)
''; '';
type = pyType; type = pyType;
default= {}; default = { };
}; };
}; };
@ -69,6 +118,13 @@ in
SERVER_MODE = true; SERVER_MODE = true;
} // (optionalAttrs cfg.openFirewall { } // (optionalAttrs cfg.openFirewall {
DEFAULT_SERVER = mkDefault "::"; DEFAULT_SERVER = mkDefault "::";
}) // (optionalAttrs cfg.emailServer.enable {
MAIL_SERVER = cfg.emailServer.address;
MAIL_PORT = cfg.emailServer.port;
MAIL_USE_SSL = cfg.emailServer.useSSL;
MAIL_USE_TLS = cfg.emailServer.useTLS;
MAIL_USERNAME = cfg.emailServer.username;
SECURITY_EMAIL_SENDER = cfg.emailServer.sender;
}); });
systemd.services.pgadmin = { systemd.services.pgadmin = {
@ -115,10 +171,14 @@ in
group = "pgadmin"; group = "pgadmin";
}; };
users.groups.pgadmin = {}; users.groups.pgadmin = { };
environment.etc."pgadmin/config_system.py" = { environment.etc."pgadmin/config_system.py" = {
text = formatPy cfg.settings; text = lib.optionalString cfg.emailServer.enable ''
with open("${cfg.emailServer.passwordFile}") as f:
pw = f.read()
MAIL_PASSWORD = pw
'' + formatPy cfg.settings;
mode = "0600"; mode = "0600";
user = "pgadmin"; user = "pgadmin";
group = "pgadmin"; group = "pgadmin";

View file

@ -106,15 +106,15 @@ import ./make-test-python.nix ({ pkgs, lib, buildDeps ? [ ], pythonEnv ? [ ], ..
&& sed -i 's|driver_local.maximize_window()||' web/regression/runtests.py" && sed -i 's|driver_local.maximize_window()||' web/regression/runtests.py"
) )
# don't bother to test LDAP authentification # Don't bother to test LDAP or kerberos authentification
# exclude resql test due to recent postgres 14.4 update # For now deactivate change_password API test. Current bug report at https://redmine.postgresql.org/issues/7648
# see bugreport here https://redmine.postgresql.org/issues/7527 # Password change works from the UI, if email SMTP is configured.
with subtest("run browser test"): with subtest("run browser test"):
machine.succeed( machine.succeed(
'cd ${pgadmin4SrcDir}/pgadmin4-${pkgs.pgadmin4.version}/web \ 'cd ${pgadmin4SrcDir}/pgadmin4-${pkgs.pgadmin4.version}/web \
&& python regression/runtests.py \ && python regression/runtests.py \
--pkg browser \ --pkg browser \
--exclude browser.tests.test_ldap_login.LDAPLoginTestCase,browser.tests.test_ldap_login,resql' --exclude browser.tests.test_ldap_login.LDAPLoginTestCase,browser.tests.test_ldap_login,browser.tests.test_kerberos_with_mocking,browser.tests.test_change_password'
) )
# fontconfig is necessary for chromium to run # fontconfig is necessary for chromium to run
@ -126,11 +126,10 @@ import ./make-test-python.nix ({ pkgs, lib, buildDeps ? [ ], pythonEnv ? [ ], ..
&& python regression/runtests.py --pkg feature_tests' && python regression/runtests.py --pkg feature_tests'
) )
# reactivate this test again, when the postgres 14.4 test has been fixed with subtest("run resql test"):
# with subtest("run resql test"): machine.succeed(
# machine.succeed( 'cd ${pgadmin4SrcDir}/pgadmin4-${pkgs.pgadmin4.version}/web \
# 'cd ${pgadmin4SrcDir}/pgadmin4-${pkgs.pgadmin4.version}/web \ && python regression/runtests.py --pkg resql'
# && python regression/runtests.py --pkg resql' )
# )
''; '';
}) })

View file

@ -10,11 +10,11 @@
let let
pname = "pgadmin"; pname = "pgadmin";
version = "6.12"; version = "6.13";
src = fetchurl { src = fetchurl {
url = "https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v${version}/source/pgadmin4-${version}.tar.gz"; url = "https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v${version}/source/pgadmin4-${version}.tar.gz";
sha256 = "sha256-cO7GdZDfJ0pq1jpMyrVy0UM49WhrKOIJOmMJauSkbyo="; sha256 = "sha256-vLItmE76R1IzgMYEGEvIeOmbfQQac5WK12AkkZknTFU=";
}; };
yarnDeps = mkYarnModules { yarnDeps = mkYarnModules {
@ -72,13 +72,16 @@ let
azure-identity azure-identity
]; ];
# override necessary on pgadmin4 6.12 # keep the scope, as it is used throughout the derivation and tests
# this also makes potential future overrides easier
pythonPackages = python3.pkgs.overrideScope (final: prev: rec { pythonPackages = python3.pkgs.overrideScope (final: prev: rec {
werkzeug = prev.werkzeug.overridePythonAttrs (oldAttrs: rec { # flask 2.2 is incompatible with pgadmin 6.13
version = "2.0.3"; # https://redmine.postgresql.org/issues/7651
flask = prev.flask.overridePythonAttrs (oldAttrs: rec {
version = "2.1.3";
src = oldAttrs.src.override { src = oldAttrs.src.override {
inherit version; inherit version;
sha256 = "sha256-uGP4/wV8UiFktgZ8niiwQRYbS+W6TQ2s7qpQoWOCLTw="; sha256 = "sha256-FZcuUBffBXXD1sCQuhaLbbkCWeYgrI1+qBOjlrrVtss=";
}; };
}); });
}); });
@ -124,7 +127,7 @@ pythonPackages.buildPythonApplication rec {
# build the documentation # build the documentation
cd docs/en_US cd docs/en_US
${sphinx}/bin/sphinx-build -W -b html -d _build/doctrees . _build/html sphinx-build -W -b html -d _build/doctrees . _build/html
# Build the clean tree # Build the clean tree
cd ../../web cd ../../web
@ -156,7 +159,7 @@ pythonPackages.buildPythonApplication rec {
cp -v ../pkg/pip/setup_pip.py setup.py cp -v ../pkg/pip/setup_pip.py setup.py
''; '';
nativeBuildInputs = with pythonPackages; [ cython pip ]; nativeBuildInputs = with pythonPackages; [ cython pip sphinx ];
buildInputs = [ buildInputs = [
zlib zlib
pythonPackages.wheel pythonPackages.wheel

View file

@ -0,0 +1,27 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl wget jq yarn2nix yarn common-updater-scripts
set -eu -o pipefail
scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd)
nixpkgs=$(realpath "$scriptDir"/../../../..)
newest_version="$(curl -s https://www.pgadmin.org/versions.json | jq -r .pgadmin4.version)"
old_version=$(nix-instantiate --eval -E "(import \"$nixpkgs\" { config = {}; overlays = []; }).pgadmin4.version" | tr -d '"')
url="https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v${newest_version}/source/pgadmin4-${newest_version}.tar.gz"
if [[ $newest_version == $old_version ]]; then
echo "Already at latest version $newest_version"
exit 0
fi
echo "New version: $newest_version"
pushd $(mktemp -d --suffix=-pgadmin4-updater)
wget $url
tar -xzf "pgadmin4-$newest_version.tar.gz"
cd "pgadmin4-$newest_version/web"
yarn2nix > yarn.nix
cp yarn.nix yarn.lock package.json "$nixpkgs/pkgs/tools/admin/pgadmin/"
popd
update-source-version pgadmin4 "$newest_version" --print-changes