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
|
|
|
|
, fixup_yarn_lock
|
|
|
|
, nodejs
|
2023-02-09 11:40:11 +00:00
|
|
|
, server-mode ? true
|
2022-03-05 16:20:37 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pname = "pgadmin";
|
2023-08-04 22:07:22 +00:00
|
|
|
version = "7.5";
|
2023-07-15 17:15:38 +00:00
|
|
|
yarnSha256 = "sha256-rEKMUZksmR2jPwtXy6drNwAJktK/3Dee6EZVFHPngWs=";
|
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}";
|
2023-08-04 22:07:22 +00:00
|
|
|
hash = "sha256-o8jPqp4jLF/lZ0frCzPDCSxCy51Nt0mbdeNB44ZwNHI=";
|
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
|
2023-05-24 13:37:59 +00:00
|
|
|
pythonPackages = python3.pkgs.overrideScope (final: prev: rec { });
|
|
|
|
|
|
|
|
offlineCache = fetchYarnDeps {
|
2023-07-15 17:15:38 +00:00
|
|
|
yarnLock = ./yarn.lock;
|
|
|
|
hash = yarnSha256;
|
2023-05-24 13:37:59 +00:00
|
|
|
};
|
2022-04-27 09:35:20 +00:00
|
|
|
|
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 \
|
|
|
|
--replace 'LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 $(MAKE) -C docs/en_US -f Makefile.sphinx html' "true"
|
|
|
|
|
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 \
|
|
|
|
--replace "code_snippets" ""
|
2022-03-05 16:20:37 +00:00
|
|
|
patchShebangs .
|
2022-06-16 17:23:12 +00:00
|
|
|
|
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-08-04 22:07:22 +00:00
|
|
|
#TODO: Can be removed once boto3>=1.28.0 and cryptography>=41 has been merged to master
|
2023-04-29 16:46:19 +00:00
|
|
|
substituteInPlace requirements.txt \
|
2023-08-04 22:07:22 +00:00
|
|
|
--replace "boto3>=1.28.*" "boto3>=1.26.*"
|
|
|
|
substituteInPlace requirements.txt \
|
|
|
|
--replace "botocore>=1.31.*" "botocore>=1.29.*"
|
|
|
|
substituteInPlace requirements.txt \
|
|
|
|
--replace "cryptography>=41.0.*" "cryptography>=40.0.*"
|
2023-03-15 16:39:30 +00:00
|
|
|
# fix extra_require error with "*" in match
|
|
|
|
sed 's|*|0|g' -i requirements.txt
|
2022-03-05 16:20:37 +00:00
|
|
|
substituteInPlace pkg/pip/setup_pip.py \
|
2023-04-29 16:46:19 +00:00
|
|
|
--replace "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 \
|
|
|
|
--replace "SERVER_MODE = True" "SERVER_MODE = False"
|
|
|
|
''}
|
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
|
2023-05-24 13:37:59 +00:00
|
|
|
fixup_yarn_lock yarn.lock
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2023-05-24 13:37: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
|
|
|
|
flask_mail
|
|
|
|
flask_migrate
|
|
|
|
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-babelex
|
|
|
|
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
|
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
|
|
|
|
substituteInPlace regression/test_config.json --replace "localhost" "$PGHOST"
|
|
|
|
substituteInPlace regression/runtests.py --replace "builtins.SERVER_MODE = None" "builtins.SERVER_MODE = False"
|
|
|
|
|
|
|
|
## Browser test ##
|
|
|
|
|
|
|
|
# don't bother to test kerberos authentication
|
|
|
|
python regression/runtests.py --pkg browser --exclude browser.tests.test_kerberos_with_mocking
|
|
|
|
|
|
|
|
## 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
|
|
|
|
for single-user deployment or where access to `/var/lib/pgadmin` cannot be granted or the NixOS module cannot be used.
|
|
|
|
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";
|
2022-03-05 16:20:37 +00:00
|
|
|
};
|
|
|
|
}
|