Merge pull request #188575 from gador/pgadmin-6.13

authored by Sandro and committed by GitHub 2e977bf9 54197947

+113 -24
+66 -6
nixos/modules/services/admin/pgadmin.nix
··· 37 37 }; 38 38 39 39 initialEmail = mkOption { 40 - description = lib.mdDoc "Initial email for the pgAdmin account."; 40 + description = lib.mdDoc "Initial email for the pgAdmin account"; 41 41 type = types.str; 42 42 }; 43 43 44 44 initialPasswordFile = mkOption { 45 45 description = lib.mdDoc '' 46 46 Initial password file for the pgAdmin account. 47 - NOTE: Should be string not a store path, to prevent the password from being world readable. 47 + NOTE: Should be string not a store path, to prevent the password from being world readable 48 48 ''; 49 49 type = types.path; 50 50 }; 51 51 52 + emailServer = { 53 + enable = mkOption { 54 + description = lib.mdDoc '' 55 + Enable SMTP email server. This is necessary, if you want to use password recovery or change your own password 56 + ''; 57 + type = types.bool; 58 + default = false; 59 + }; 60 + address = mkOption { 61 + description = lib.mdDoc "SMTP server for email delivery"; 62 + type = types.str; 63 + default = "localhost"; 64 + }; 65 + port = mkOption { 66 + description = lib.mdDoc "SMTP server port for email delivery"; 67 + type = types.port; 68 + default = 25; 69 + }; 70 + useSSL = mkOption { 71 + description = lib.mdDoc "SMTP server should use SSL"; 72 + type = types.bool; 73 + default = false; 74 + }; 75 + useTLS = mkOption { 76 + description = lib.mdDoc "SMTP server should use TLS"; 77 + type = types.bool; 78 + default = false; 79 + }; 80 + username = mkOption { 81 + description = lib.mdDoc "SMTP server username for email delivery"; 82 + type = types.nullOr types.str; 83 + default = null; 84 + }; 85 + sender = mkOption { 86 + description = lib.mdDoc '' 87 + SMTP server sender email for email delivery. Some servers require this to be a valid email address from that server 88 + ''; 89 + type = types.str; 90 + example = "noreply@example.com"; 91 + }; 92 + passwordFile = mkOption { 93 + description = lib.mdDoc '' 94 + Password for SMTP email account. 95 + NOTE: Should be string not a store path, to prevent the password from being world readable 96 + ''; 97 + type = types.path; 98 + }; 99 + }; 100 + 52 101 openFirewall = mkEnableOption (lib.mdDoc "firewall passthrough for pgadmin4"); 53 102 54 103 settings = mkOption { 55 104 description = lib.mdDoc '' 56 105 Settings for pgadmin4. 57 - [Documentation](https://www.pgadmin.org/docs/pgadmin4/development/config_py.html). 106 + [Documentation](https://www.pgadmin.org/docs/pgadmin4/development/config_py.html) 58 107 ''; 59 108 type = pyType; 60 - default= {}; 109 + default = { }; 61 110 }; 62 111 }; 63 112 ··· 69 118 SERVER_MODE = true; 70 119 } // (optionalAttrs cfg.openFirewall { 71 120 DEFAULT_SERVER = mkDefault "::"; 121 + }) // (optionalAttrs cfg.emailServer.enable { 122 + MAIL_SERVER = cfg.emailServer.address; 123 + MAIL_PORT = cfg.emailServer.port; 124 + MAIL_USE_SSL = cfg.emailServer.useSSL; 125 + MAIL_USE_TLS = cfg.emailServer.useTLS; 126 + MAIL_USERNAME = cfg.emailServer.username; 127 + SECURITY_EMAIL_SENDER = cfg.emailServer.sender; 72 128 }); 73 129 74 130 systemd.services.pgadmin = { ··· 115 171 group = "pgadmin"; 116 172 }; 117 173 118 - users.groups.pgadmin = {}; 174 + users.groups.pgadmin = { }; 119 175 120 176 environment.etc."pgadmin/config_system.py" = { 121 - text = formatPy cfg.settings; 177 + text = lib.optionalString cfg.emailServer.enable '' 178 + with open("${cfg.emailServer.passwordFile}") as f: 179 + pw = f.read() 180 + MAIL_PASSWORD = pw 181 + '' + formatPy cfg.settings; 122 182 mode = "0600"; 123 183 user = "pgadmin"; 124 184 group = "pgadmin";
+9 -10
nixos/tests/pgadmin4.nix
··· 106 106 && sed -i 's|driver_local.maximize_window()||' web/regression/runtests.py" 107 107 ) 108 108 109 - # don't bother to test LDAP authentification 110 - # exclude resql test due to recent postgres 14.4 update 111 - # see bugreport here https://redmine.postgresql.org/issues/7527 109 + # Don't bother to test LDAP or kerberos authentification 110 + # For now deactivate change_password API test. Current bug report at https://redmine.postgresql.org/issues/7648 111 + # Password change works from the UI, if email SMTP is configured. 112 112 with subtest("run browser test"): 113 113 machine.succeed( 114 114 'cd ${pgadmin4SrcDir}/pgadmin4-${pkgs.pgadmin4.version}/web \ 115 115 && python regression/runtests.py \ 116 116 --pkg browser \ 117 - --exclude browser.tests.test_ldap_login.LDAPLoginTestCase,browser.tests.test_ldap_login,resql' 117 + --exclude browser.tests.test_ldap_login.LDAPLoginTestCase,browser.tests.test_ldap_login,browser.tests.test_kerberos_with_mocking,browser.tests.test_change_password' 118 118 ) 119 119 120 120 # fontconfig is necessary for chromium to run ··· 126 126 && python regression/runtests.py --pkg feature_tests' 127 127 ) 128 128 129 - # reactivate this test again, when the postgres 14.4 test has been fixed 130 - # with subtest("run resql test"): 131 - # machine.succeed( 132 - # 'cd ${pgadmin4SrcDir}/pgadmin4-${pkgs.pgadmin4.version}/web \ 133 - # && python regression/runtests.py --pkg resql' 134 - # ) 129 + with subtest("run resql test"): 130 + machine.succeed( 131 + 'cd ${pgadmin4SrcDir}/pgadmin4-${pkgs.pgadmin4.version}/web \ 132 + && python regression/runtests.py --pkg resql' 133 + ) 135 134 ''; 136 135 })
+11 -8
pkgs/tools/admin/pgadmin/default.nix
··· 10 10 11 11 let 12 12 pname = "pgadmin"; 13 - version = "6.12"; 13 + version = "6.13"; 14 14 15 15 src = fetchurl { 16 16 url = "https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v${version}/source/pgadmin4-${version}.tar.gz"; 17 - sha256 = "sha256-cO7GdZDfJ0pq1jpMyrVy0UM49WhrKOIJOmMJauSkbyo="; 17 + sha256 = "sha256-vLItmE76R1IzgMYEGEvIeOmbfQQac5WK12AkkZknTFU="; 18 18 }; 19 19 20 20 yarnDeps = mkYarnModules { ··· 72 72 azure-identity 73 73 ]; 74 74 75 - # override necessary on pgadmin4 6.12 75 + # keep the scope, as it is used throughout the derivation and tests 76 + # this also makes potential future overrides easier 76 77 pythonPackages = python3.pkgs.overrideScope (final: prev: rec { 77 - werkzeug = prev.werkzeug.overridePythonAttrs (oldAttrs: rec { 78 - version = "2.0.3"; 78 + # flask 2.2 is incompatible with pgadmin 6.13 79 + # https://redmine.postgresql.org/issues/7651 80 + flask = prev.flask.overridePythonAttrs (oldAttrs: rec { 81 + version = "2.1.3"; 79 82 src = oldAttrs.src.override { 80 83 inherit version; 81 - sha256 = "sha256-uGP4/wV8UiFktgZ8niiwQRYbS+W6TQ2s7qpQoWOCLTw="; 84 + sha256 = "sha256-FZcuUBffBXXD1sCQuhaLbbkCWeYgrI1+qBOjlrrVtss="; 82 85 }; 83 86 }); 84 87 }); ··· 124 127 125 128 # build the documentation 126 129 cd docs/en_US 127 - ${sphinx}/bin/sphinx-build -W -b html -d _build/doctrees . _build/html 130 + sphinx-build -W -b html -d _build/doctrees . _build/html 128 131 129 132 # Build the clean tree 130 133 cd ../../web ··· 156 159 cp -v ../pkg/pip/setup_pip.py setup.py 157 160 ''; 158 161 159 - nativeBuildInputs = with pythonPackages; [ cython pip ]; 162 + nativeBuildInputs = with pythonPackages; [ cython pip sphinx ]; 160 163 buildInputs = [ 161 164 zlib 162 165 pythonPackages.wheel
+27
pkgs/tools/admin/pgadmin/update.sh
··· 1 + #!/usr/bin/env nix-shell 2 + #!nix-shell -i bash -p curl wget jq yarn2nix yarn common-updater-scripts 3 + 4 + set -eu -o pipefail 5 + 6 + scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd) 7 + nixpkgs=$(realpath "$scriptDir"/../../../..) 8 + 9 + newest_version="$(curl -s https://www.pgadmin.org/versions.json | jq -r .pgadmin4.version)" 10 + old_version=$(nix-instantiate --eval -E "(import \"$nixpkgs\" { config = {}; overlays = []; }).pgadmin4.version" | tr -d '"') 11 + url="https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v${newest_version}/source/pgadmin4-${newest_version}.tar.gz" 12 + 13 + if [[ $newest_version == $old_version ]]; then 14 + echo "Already at latest version $newest_version" 15 + exit 0 16 + fi 17 + echo "New version: $newest_version" 18 + 19 + pushd $(mktemp -d --suffix=-pgadmin4-updater) 20 + wget $url 21 + tar -xzf "pgadmin4-$newest_version.tar.gz" 22 + cd "pgadmin4-$newest_version/web" 23 + yarn2nix > yarn.nix 24 + cp yarn.nix yarn.lock package.json "$nixpkgs/pkgs/tools/admin/pgadmin/" 25 + popd 26 + 27 + update-source-version pgadmin4 "$newest_version" --print-changes