2022-04-27 09:35:20 +00:00
|
|
|
{ lib
|
2022-03-05 16:20:37 +00:00
|
|
|
, python3
|
2023-05-24 13:37:59 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchYarnDeps
|
2022-03-05 16:20:37 +00:00
|
|
|
, zlib
|
|
|
|
, nixosTests
|
2023-02-09 11:40:11 +00:00
|
|
|
, postgresqlTestHook
|
|
|
|
, postgresql
|
2023-05-24 13:37:59 +00:00
|
|
|
, yarn
|
2024-04-21 15:54:59 +00:00
|
|
|
, fixup-yarn-lock
|
2023-05-24 13:37:59 +00:00
|
|
|
, nodejs
|
2024-04-21 15:54:59 +00:00
|
|
|
, stdenv
|
2023-02-09 11:40:11 +00:00
|
|
|
, server-mode ? true
|
2022-03-05 16:20:37 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pname = "pgadmin";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "8.5";
|
|
|
|
yarnHash = "sha256-VLf8GRJ2IIcrfBqdgT2uZG3kOEt0pd7Cksm+tdrQogA=";
|
2022-03-05 16:20:37 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "pgadmin-org";
|
|
|
|
repo = "pgadmin4";
|
|
|
|
rev = "REL-${lib.versions.major version}_${lib.versions.minor version}";
|
2024-04-21 15:54:59 +00:00
|
|
|
hash = "sha256-D/8tiVL2DwxvDiSqHeOF1P/yRRniZY39TyUfibrfAOo=";
|
2022-03-05 16:20:37 +00:00
|
|
|
};
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
# keep the scope, as it is used throughout the derivation and tests
|
|
|
|
# this also makes potential future overrides easier
|
2024-04-21 15:54:59 +00:00
|
|
|
pythonPackages = python3.pkgs.overrideScope (final: prev: rec {
|
|
|
|
# Flask 5.4.3 introduces an CSRF error which makes it impossible to login
|
|
|
|
# So either we downgrade flask here or use "WTF_CSRF_ENABLED = false" in the
|
|
|
|
# module config to disable CSRF.
|
|
|
|
flask-security-too = prev.flask-security-too.overridePythonAttrs (oldAttrs: rec {
|
|
|
|
version = "5.4.1";
|
|
|
|
src = oldAttrs.src.override {
|
|
|
|
inherit version;
|
|
|
|
hash = "sha256-Ay7+gk+zuUlXtw0LDdsnvSa22z+yE6VR1guu9QmiFvw=";
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
offlineCache = fetchYarnDeps {
|
2023-07-15 17:15:38 +00:00
|
|
|
yarnLock = ./yarn.lock;
|
2023-11-16 04:20:00 +00:00
|
|
|
hash = yarnHash;
|
2023-05-24 13:37:59 +00:00
|
|
|
};
|
2022-04-27 09:35:20 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
# don't bother to test kerberos authentication
|
|
|
|
# skip tests on macOS which fail due to an error in keyring, see https://github.com/NixOS/nixpkgs/issues/281214
|
|
|
|
skippedTests = builtins.concatStringsSep "," (
|
|
|
|
[ "browser.tests.test_kerberos_with_mocking" ]
|
|
|
|
++ lib.optionals stdenv.isDarwin [
|
|
|
|
"browser.server_groups.servers.tests.test_all_server_get"
|
|
|
|
"browser.server_groups.servers.tests.test_check_connect"
|
|
|
|
"browser.server_groups.servers.tests.test_check_ssh_mock_connect"
|
|
|
|
"browser.server_groups.servers.tests.test_is_password_saved"
|
|
|
|
]
|
|
|
|
);
|
2022-03-05 16:20:37 +00:00
|
|
|
in
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
pythonPackages.buildPythonApplication rec {
|
2022-03-05 16:20:37 +00:00
|
|
|
inherit pname version src;
|
|
|
|
|
|
|
|
# from Dockerfile
|
|
|
|
CPPFLAGS = "-DPNG_ARM_NEON_OPT=0";
|
|
|
|
|
|
|
|
format = "setuptools";
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# Expose setup.py for later use
|
|
|
|
./expose-setup.py.patch
|
2023-02-09 11:40:11 +00:00
|
|
|
# check for permission of /etc/pgadmin/config_system and don't fail
|
|
|
|
./check-system-config-dir.patch
|
2022-03-05 16:20:37 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# patching Makefile, so it doesn't try to build sphinx documentation here
|
|
|
|
# (will do so later)
|
2022-06-16 17:23:12 +00:00
|
|
|
substituteInPlace Makefile \
|
2024-04-21 15:54:59 +00:00
|
|
|
--replace-fail 'LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 $(MAKE) -C docs/en_US -f Makefile.sphinx html' "true"
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
# fix document which refers a non-existing document and fails
|
2022-06-16 17:23:12 +00:00
|
|
|
substituteInPlace docs/en_US/contributions.rst \
|
2024-04-21 15:54:59 +00:00
|
|
|
--replace-fail "code_snippets" ""
|
2022-03-05 16:20:37 +00:00
|
|
|
# relax dependencies
|
2022-08-12 12:06:08 +00:00
|
|
|
sed 's|==|>=|g' -i requirements.txt
|
2023-03-15 16:39:30 +00:00
|
|
|
# fix extra_require error with "*" in match
|
|
|
|
sed 's|*|0|g' -i requirements.txt
|
2024-04-21 15:54:59 +00:00
|
|
|
# remove packageManager from package.json so we can work without corepack
|
|
|
|
substituteInPlace web/package.json \
|
|
|
|
--replace-fail "\"packageManager\": \"yarn@3.6.4\"" "\"\": \"\""
|
2022-03-05 16:20:37 +00:00
|
|
|
substituteInPlace pkg/pip/setup_pip.py \
|
2024-04-21 15:54:59 +00:00
|
|
|
--replace-fail "req = req.replace('psycopg[c]', 'psycopg[binary]')" "req = req"
|
2023-02-09 11:40:11 +00:00
|
|
|
${lib.optionalString (!server-mode) ''
|
|
|
|
substituteInPlace web/config.py \
|
2024-04-21 15:54:59 +00:00
|
|
|
--replace-fail "SERVER_MODE = True" "SERVER_MODE = False"
|
2023-02-09 11:40:11 +00:00
|
|
|
''}
|
2022-03-05 16:20:37 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
# Adapted from pkg/pip/build.sh
|
|
|
|
echo Creating required directories...
|
|
|
|
mkdir -p pip-build/pgadmin4/docs
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
echo Building the documentation
|
2022-03-05 16:20:37 +00:00
|
|
|
cd docs/en_US
|
2022-09-30 11:47:45 +00:00
|
|
|
sphinx-build -W -b html -d _build/doctrees . _build/html
|
2022-03-05 16:20:37 +00:00
|
|
|
|
|
|
|
# Build the clean tree
|
2023-05-24 13:37:59 +00:00
|
|
|
cd ..
|
2022-03-05 16:20:37 +00:00
|
|
|
cp -r * ../pip-build/pgadmin4/docs
|
|
|
|
for DIR in `ls -d ??_??/`
|
|
|
|
do
|
|
|
|
if [ -d ''${DIR}_build/html ]; then
|
|
|
|
mkdir -p ../pip-build/pgadmin4/docs/''${DIR}_build
|
2023-01-11 07:51:40 +00:00
|
|
|
cp -R ''${DIR}_build/html ../pip-build/pgadmin4/docs/''${DIR}_build
|
2022-03-05 16:20:37 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
cd ../
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
# mkYarnModules and mkYarnPackage have problems running the webpacker
|
|
|
|
echo Building the web frontend...
|
|
|
|
cd web
|
|
|
|
export HOME="$TMPDIR"
|
|
|
|
yarn config --offline set yarn-offline-mirror "${offlineCache}"
|
2023-07-15 17:15:38 +00:00
|
|
|
# replace with converted yarn.lock file
|
|
|
|
rm yarn.lock
|
|
|
|
cp ${./yarn.lock} yarn.lock
|
|
|
|
chmod +w yarn.lock
|
2024-01-02 11:29:13 +00:00
|
|
|
fixup-yarn-lock yarn.lock
|
2023-05-24 13:37:59 +00:00
|
|
|
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
|
|
|
|
patchShebangs node_modules/
|
|
|
|
yarn webpacker
|
|
|
|
cp -r * ../pip-build/pgadmin4
|
|
|
|
# save some disk space
|
|
|
|
rm -rf ../pip-build/pgadmin4/node_modules
|
|
|
|
|
|
|
|
cd ..
|
2022-03-05 16:20:37 +00:00
|
|
|
|
|
|
|
echo Creating distro config...
|
|
|
|
echo HELP_PATH = \'../../docs/en_US/_build/html/\' > pip-build/pgadmin4/config_distro.py
|
|
|
|
echo MINIFY_HTML = False >> pip-build/pgadmin4/config_distro.py
|
|
|
|
|
|
|
|
echo Creating manifest...
|
|
|
|
echo recursive-include pgadmin4 \* > pip-build/MANIFEST.in
|
|
|
|
|
|
|
|
echo Building wheel...
|
|
|
|
cd pip-build
|
|
|
|
# copy non-standard setup.py to local directory
|
|
|
|
# so setuptools-build-hook can call it
|
|
|
|
cp -v ../pkg/pip/setup_pip.py setup.py
|
|
|
|
'';
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
nativeBuildInputs = with pythonPackages; [ cython pip sphinx yarn fixup-yarn-lock nodejs ];
|
2022-03-05 16:20:37 +00:00
|
|
|
buildInputs = [
|
|
|
|
zlib
|
2022-04-27 09:35:20 +00:00
|
|
|
pythonPackages.wheel
|
2022-03-05 16:20:37 +00:00
|
|
|
];
|
|
|
|
|
2023-02-09 11:40:11 +00:00
|
|
|
propagatedBuildInputs = with pythonPackages; [
|
|
|
|
flask
|
|
|
|
flask-gravatar
|
|
|
|
flask-login
|
2023-10-09 19:29:22 +00:00
|
|
|
flask-mail
|
|
|
|
flask-migrate
|
2023-02-09 11:40:11 +00:00
|
|
|
flask-sqlalchemy
|
|
|
|
flask-wtf
|
|
|
|
flask-compress
|
|
|
|
passlib
|
|
|
|
pytz
|
|
|
|
simplejson
|
|
|
|
sqlparse
|
|
|
|
wtforms
|
|
|
|
flask-paranoid
|
|
|
|
psutil
|
2023-04-29 16:46:19 +00:00
|
|
|
psycopg
|
2023-02-09 11:40:11 +00:00
|
|
|
python-dateutil
|
|
|
|
sqlalchemy
|
|
|
|
itsdangerous
|
|
|
|
flask-security-too
|
|
|
|
bcrypt
|
|
|
|
cryptography
|
|
|
|
sshtunnel
|
|
|
|
ldap3
|
|
|
|
flask-babel
|
|
|
|
gssapi
|
|
|
|
flask-socketio
|
|
|
|
eventlet
|
|
|
|
httpagentparser
|
|
|
|
user-agents
|
|
|
|
wheel
|
|
|
|
authlib
|
|
|
|
qrcode
|
|
|
|
pillow
|
|
|
|
pyotp
|
|
|
|
botocore
|
|
|
|
boto3
|
|
|
|
azure-mgmt-subscription
|
|
|
|
azure-mgmt-rdbms
|
|
|
|
azure-mgmt-resource
|
|
|
|
azure-identity
|
|
|
|
sphinxcontrib-youtube
|
|
|
|
dnspython
|
|
|
|
greenlet
|
|
|
|
speaklater3
|
2023-04-29 16:46:19 +00:00
|
|
|
google-auth-oauthlib
|
|
|
|
google-api-python-client
|
2023-07-15 17:15:38 +00:00
|
|
|
keyring
|
2024-01-25 14:12:00 +00:00
|
|
|
typer
|
|
|
|
rich
|
2024-04-21 15:54:59 +00:00
|
|
|
jsonformatter
|
2023-02-09 11:40:11 +00:00
|
|
|
];
|
2022-03-05 16:20:37 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
passthru.tests = {
|
2023-02-09 11:40:11 +00:00
|
|
|
inherit (nixosTests) pgadmin4;
|
2022-03-05 16:20:37 +00:00
|
|
|
};
|
|
|
|
|
2023-02-09 11:40:11 +00:00
|
|
|
nativeCheckInputs = [
|
|
|
|
postgresqlTestHook
|
|
|
|
postgresql
|
|
|
|
pythonPackages.testscenarios
|
|
|
|
pythonPackages.selenium
|
|
|
|
];
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
## Setup ##
|
|
|
|
|
|
|
|
# pgadmin needs a home directory to save the configuration
|
|
|
|
export HOME=$TMPDIR
|
|
|
|
cd pgadmin4
|
|
|
|
|
|
|
|
# set configuration for postgresql test
|
|
|
|
# also ensure Server Mode is set to false. If not, the tests will fail, since pgadmin expects read/write permissions
|
|
|
|
# in /var/lib/pgadmin and /var/log/pgadmin
|
|
|
|
# see https://github.com/pgadmin-org/pgadmin4/blob/fd1c26408bbf154fa455a49ee5c12895933833a3/web/regression/runtests.py#L217-L226
|
|
|
|
cp -v regression/test_config.json.in regression/test_config.json
|
2024-04-21 15:54:59 +00:00
|
|
|
substituteInPlace regression/test_config.json --replace-fail "localhost" "$PGHOST"
|
|
|
|
substituteInPlace regression/runtests.py --replace-fail "builtins.SERVER_MODE = None" "builtins.SERVER_MODE = False"
|
2023-02-09 11:40:11 +00:00
|
|
|
|
|
|
|
## Browser test ##
|
2024-04-21 15:54:59 +00:00
|
|
|
python regression/runtests.py --pkg browser --exclude ${skippedTests}
|
2023-02-09 11:40:11 +00:00
|
|
|
|
|
|
|
## Reverse engineered SQL test ##
|
|
|
|
|
|
|
|
python regression/runtests.py --pkg resql
|
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
meta = with lib; {
|
2023-02-09 11:40:11 +00:00
|
|
|
description = "Administration and development platform for PostgreSQL${optionalString (!server-mode) ". Desktop Mode"}";
|
|
|
|
longDescription = ''
|
|
|
|
pgAdmin 4 is designed to meet the needs of both novice and experienced Postgres users alike,
|
|
|
|
providing a powerful graphical interface that simplifies the creation, maintenance and use of database objects.
|
|
|
|
${if server-mode then ''
|
|
|
|
This version is build with SERVER_MODE set to True (the default). It will require access to `/var/lib/pgadmin`
|
|
|
|
and `/var/log/pgadmin`. This is the default version for the NixOS module `services.pgadmin`.
|
|
|
|
This should NOT be used in combination with the `pgadmin4-desktopmode` package as they will interfere.
|
|
|
|
'' else ''
|
|
|
|
This version is build with SERVER_MODE set to False. It will require access to `~/.pgadmin/`. This version is suitable
|
2024-04-21 15:54:59 +00:00
|
|
|
for single-user deployment or where access to `/var/lib/pgadmin` cannot be granted or the NixOS module cannot be used (e.g. on MacOS).
|
2023-02-09 11:40:11 +00:00
|
|
|
This should NOT be used in combination with the NixOS module `pgadmin` as they will interfere.
|
|
|
|
''}
|
|
|
|
'';
|
2022-03-05 16:20:37 +00:00
|
|
|
homepage = "https://www.pgadmin.org/";
|
|
|
|
license = licenses.mit;
|
2022-04-27 09:35:20 +00:00
|
|
|
changelog = "https://www.pgadmin.org/docs/pgadmin4/latest/release_notes_${lib.versions.major version}_${lib.versions.minor version}.html";
|
2022-03-05 16:20:37 +00:00
|
|
|
maintainers = with maintainers; [ gador ];
|
2022-06-16 17:23:12 +00:00
|
|
|
mainProgram = "pgadmin4";
|
2024-04-21 15:54:59 +00:00
|
|
|
platforms = platforms.unix;
|
2022-03-05 16:20:37 +00:00
|
|
|
};
|
|
|
|
}
|