1313 libtool ,
1414 libpng ,
1515 nasm ,
16+ cmake ,
1617 pkg-config ,
1718 stdenv ,
19+ srcOnly ,
1820 server-mode ? true ,
1921} :
2022
2123let
2224 pname = "pgadmin" ;
2325 version = "9.3" ;
24- yarnHash = "sha256-75FwwQ67j0aTHGvD4YwAaR8CWV4u4KsuMghidbkgVsw =" ;
26+ yarnHash = "sha256-T6RKWuAAoJgbzJKef4ioOoUDtoGM9s9BFqxFdy5EtyQ =" ;
2527
2628 src = fetchFromGitHub {
2729 owner = "pgadmin-org" ;
3032 hash = "sha256-4uupF1dw6OE/briAI5PWiQ7h6RPx1sUqf8PB8cJsNSU=" ;
3133 } ;
3234
35+ mozjpeg-bin = fetchFromGitHub {
36+ owner = "imagemin" ;
37+ repo = "mozjpeg-bin" ;
38+ rev = "c0587fbc00b21ed8cad8bae499a0827baeaf7ffa" ;
39+ hash = "sha256-D/pXQBlIIyk7KAgxJ1gKqxYxtlfBbLzUSmYZbH659cA=" ;
40+ } ;
41+
3342 # keep the scope, as it is used throughout the derivation and tests
3443 # this also makes potential future overrides easier
3544 pythonPackages = python3 . pkgs . overrideScope ( final : prev : { } ) ;
@@ -51,6 +60,14 @@ pythonPackages.buildPythonApplication rec {
5160 inherit pname version src ;
5261
5362 offlineCache = yarn-berry_3 . fetchYarnBerryDeps {
63+ # mozjpeg fails to build on darwin due to a hardocded path
64+ # this has been fixed upstream on master but no new version
65+ # has been released. We therefore point yarn to upstream
66+ # see https://github.com/imagemin/mozjpeg-bin/issues/64
67+ # and https://github.com/imagemin/mozjpeg-bin/issues/81
68+ patches = [
69+ ./mozjpeg.patch
70+ ] ;
5471 src = src + "/web" ;
5572 hash = yarnHash ;
5673 } ;
@@ -68,6 +85,11 @@ pythonPackages.buildPythonApplication rec {
6885 ] ;
6986
7087 postPatch = ''
88+ # the patch needs to be executed inside the /web subfolder
89+ # therefore it is included here and not in `patches`
90+ cd web
91+ patch -u yarn.lock ${ ./mozjpeg.patch }
92+ cd ..
7193 # patching Makefile, so it doesn't try to build sphinx documentation here
7294 # (will do so later)
7395 substituteInPlace Makefile \
@@ -89,6 +111,8 @@ pythonPackages.buildPythonApplication rec {
89111 '' ;
90112
91113 dontYarnBerryInstallDeps = true ;
114+ env . YARN_ENABLE_SCRIPTS = "0" ;
115+ dontUseCmakeConfigure = true ;
92116
93117 preBuild = ''
94118 # Adapted from pkg/pip/build.sh
@@ -117,6 +141,25 @@ pythonPackages.buildPythonApplication rec {
117141 export LD=$CC # https://github.com/imagemin/optipng-bin/issues/108
118142 yarnBerryConfigHook
119143 )
144+ # mozjpeg vendored source isn't included in the checkout for yarn. If we copy it before the
145+ # yarnConfigHook it will just get overwritten. So we first run the configHook without build,
146+ # then copy the vendored source and then build the dependencies
147+ # This has the disadvantage of repeating some of the yarnConfigHooks logic here
148+ mkdir -p node_modules/mozjpeg/vendor/source
149+ cp ${ mozjpeg-bin } /vendor/source/mozjpeg.tar.gz node_modules/mozjpeg/vendor/source/
150+ (
151+ # https://github.com/mozilla/mozjpeg/issues/438
152+ substituteInPlace node_modules/mozjpeg/lib/install.js --replace-fail "cmake -DCMAKE" "cmake -DENABLE_STATIC=FALSE -DCMAKE"
153+ substituteInPlace node_modules/mozjpeg/lib/install.js --replace-fail "cp cjpeg-static" "cp cjpeg"
154+ export LD=$CC
155+ export HOME=$(mktemp -d)
156+ export YARN_ENABLE_SCRIPTS=1
157+ YARN_IGNORE_PATH=1 ${ yarn-berry_3 . yarn-berry-offline } /bin/yarn config set enableTelemetry false
158+ YARN_IGNORE_PATH=1 ${ yarn-berry_3 . yarn-berry-offline } /bin/yarn config set enableGlobalCache false
159+ export npm_config_nodedir="${ srcOnly nodejs } "
160+ export npm_config_node_gyp="${ nodejs } /lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js"
161+ YARN_IGNORE_PATH=1 ${ yarn-berry_3 . yarn-berry-offline } /bin/yarn install --inline-builds
162+ )
120163 yarn webpacker
121164 cp -r * ../pip-build/pgadmin4
122165 # save some disk space
@@ -147,6 +190,7 @@ pythonPackages.buildPythonApplication rec {
147190 nodejs
148191
149192 # for building mozjpeg2
193+ cmake
150194 autoconf
151195 automake
152196 libtool
0 commit comments