Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 22.05 202 lines 5.6 kB view raw
1{ lib 2, python3 3, fetchurl 4, zlib 5, mkYarnModules 6, sphinx 7, nixosTests 8, pkgs 9}: 10 11let 12 13 pname = "pgadmin"; 14 version = "6.8"; 15 16 src = fetchurl { 17 url = "https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v${version}/source/pgadmin4-${version}.tar.gz"; 18 sha256 = "sha256-kS9GV/j28zkXTJZkRrG2JDgas210rQqXOJrwwxzepbw="; 19 }; 20 21 yarnDeps = mkYarnModules { 22 pname = "${pname}-yarn-deps"; 23 inherit version; 24 packageJSON = ./package.json; 25 yarnLock = ./yarn.lock; 26 yarnNix = ./yarn.nix; 27 }; 28 29 # move buildDeps here to easily pass to test suite 30 buildDeps = with pythonPackages; [ 31 flask 32 flask-gravatar 33 flask_login 34 flask_mail 35 flask_migrate 36 flask_sqlalchemy 37 flask_wtf 38 flask-compress 39 passlib 40 pytz 41 simplejson 42 six 43 sqlparse 44 wtforms 45 flask-paranoid 46 psutil 47 psycopg2 48 python-dateutil 49 sqlalchemy 50 itsdangerous 51 flask-security-too 52 bcrypt 53 cryptography 54 sshtunnel 55 ldap3 56 flask-babelex 57 flask-babel 58 gssapi 59 flask-socketio 60 eventlet 61 httpagentparser 62 user-agents 63 wheel 64 authlib 65 qrcode 66 pillow 67 pyotp 68 botocore 69 boto3 70 ]; 71 72 # override necessary on pgadmin4 6.8 73 pythonPackages = python3.pkgs.overrideScope (final: prev: rec { 74 flask = prev.flask.overridePythonAttrs (oldAttrs: rec { 75 version = "2.0.3"; 76 src = oldAttrs.src.override { 77 inherit version; 78 sha256 = "sha256-4RIMIoyi9VO0cN9KX6knq2YlhGdSYGmYGz6wqRkCaH0="; 79 }; 80 disabledTests = (oldAttrs.disabledTests or [ ]) ++ [ 81 "test_aborting" 82 ]; 83 }); 84 flask-paranoid = prev.flask-paranoid.overridePythonAttrs (oldAttrs: rec { 85 # tests fail due to downgrades here 86 doCheck = false; 87 }); 88 werkzeug = prev.werkzeug.overridePythonAttrs (oldAttrs: rec { 89 version = "2.0.3"; 90 src = oldAttrs.src.override { 91 inherit version; 92 sha256 = "sha256-uGP4/wV8UiFktgZ8niiwQRYbS+W6TQ2s7qpQoWOCLTw="; 93 }; 94 }); 95 }); 96 97in 98 99pythonPackages.buildPythonApplication rec { 100 inherit pname version src; 101 102 # from Dockerfile 103 CPPFLAGS = "-DPNG_ARM_NEON_OPT=0"; 104 105 format = "setuptools"; 106 107 patches = [ 108 # Expose setup.py for later use 109 ./expose-setup.py.patch 110 ]; 111 112 postPatch = '' 113 # patching Makefile, so it doesn't try to build sphinx documentation here 114 # (will do so later) 115 substituteInPlace Makefile --replace 'LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 $(MAKE) -C docs/en_US -f Makefile.sphinx html' "true" 116 # fix document which refers a non-existing document and fails 117 substituteInPlace docs/en_US/contributions.rst --replace "code_snippets" "" 118 patchShebangs . 119 # relax dependencies 120 substituteInPlace requirements.txt \ 121 --replace "psycopg2==2.9.*" "psycopg2>=2.9" \ 122 --replace "cryptography==3.*" "cryptography>=3.0" \ 123 --replace "requests==2.25.*" "requests>=2.25.0" \ 124 --replace "boto3==1.20.*" "boto3>=1.20" \ 125 --replace "botocore==1.23.*" "botocore>=1.23" \ 126 --replace "pytz==2021.*" "pytz" \ 127 --replace "Werkzeug==2.0.3" "werkzeug>=2.*" 128 # don't use Server Mode (can be overridden later) 129 substituteInPlace pkg/pip/setup_pip.py \ 130 --replace "req = req.replace('psycopg2', 'psycopg2-binary')" "req = req" \ 131 --replace "builtins.SERVER_MODE = None" "builtins.SERVER_MODE = False" 132 ''; 133 134 preBuild = '' 135 # Adapted from pkg/pip/build.sh 136 echo Creating required directories... 137 mkdir -p pip-build/pgadmin4/docs 138 139 # build the documentation 140 cd docs/en_US 141 ${sphinx}/bin/sphinx-build -W -b html -d _build/doctrees . _build/html 142 143 # Build the clean tree 144 cd ../../web 145 cp -r * ../pip-build/pgadmin4 146 cd ../docs 147 cp -r * ../pip-build/pgadmin4/docs 148 for DIR in `ls -d ??_??/` 149 do 150 if [ -d ''${DIR}_build/html ]; then 151 mkdir -p ../pip-build/pgadmin4/docs/''${DIR}_build 152 cp -Rv ''${DIR}_build/html ../pip-build/pgadmin4/docs/''${DIR}_build 153 fi 154 done 155 cd ../ 156 157 cp -r ${yarnDeps}/* pip-build/pgadmin4 158 159 echo Creating distro config... 160 echo HELP_PATH = \'../../docs/en_US/_build/html/\' > pip-build/pgadmin4/config_distro.py 161 echo MINIFY_HTML = False >> pip-build/pgadmin4/config_distro.py 162 163 echo Creating manifest... 164 echo recursive-include pgadmin4 \* > pip-build/MANIFEST.in 165 166 echo Building wheel... 167 cd pip-build 168 # copy non-standard setup.py to local directory 169 # so setuptools-build-hook can call it 170 cp -v ../pkg/pip/setup_pip.py setup.py 171 ''; 172 173 nativeBuildInputs = with pythonPackages; [ cython pip ]; 174 buildInputs = [ 175 zlib 176 pythonPackages.wheel 177 ]; 178 179 # tests need an own data, log directory 180 # and a working and correctly setup postgres database 181 # checks will be run through nixos/tests 182 doCheck = false; 183 184 # speaklater3 is seperate because when passing buildDeps 185 # to the test, it fails there due to a collision with speaklater 186 propagatedBuildInputs = buildDeps ++ [ pythonPackages.speaklater3 ]; 187 188 passthru.tests = { 189 standalone = nixosTests.pgadmin4-standalone; 190 # regression and function tests of the package itself 191 package = (import ../../../../nixos/tests/pgadmin4.nix ({ inherit pkgs; buildDeps = buildDeps; pythonEnv = pythonPackages; })); 192 }; 193 194 meta = with lib; { 195 description = "Administration and development platform for PostgreSQL"; 196 homepage = "https://www.pgadmin.org/"; 197 license = licenses.mit; 198 changelog = "https://www.pgadmin.org/docs/pgadmin4/latest/release_notes_${lib.versions.major version}_${lib.versions.minor version}.html"; 199 maintainers = with maintainers; [ gador ]; 200 mainProgram = "pgadmin4"; 201 }; 202}