Mempool: use postPatch to copy lock file for npmDeps fetcher

prefetch-npm-deps runs in the deps fetcher's buildPhase and checks for
package-lock.json at CWD (repo root). postPatch runs in both the
fetcher and the main build, so we copy the lock file there. The main
build then cds into the subdir in buildPhase.

npmDepsHash values remain placeholders (lib.fakeHash).
This commit is contained in:
Sovran Systems
2026-08-10 17:21:42 -05:00
parent 953cacc72c
commit 03fb7791eb
+13 -18
View File
@@ -80,11 +80,14 @@ in rec {
pname = "mempool-backend"; pname = "mempool-backend";
inherit version src; inherit version src;
# cd into the backend subdir during unpack so the npmDeps fetcher # postPatch runs in the npmDeps fetcher too. Copy the lock file to
# finds package-lock.json at its CWD. This hook runs in both the # the repo root so prefetch-npm-deps can find it, then apply patches
# deps fetcher and the main build. # in the main build.
preBuild = '' postPatch = ''
cp backend/package-lock.json .
cd backend cd backend
patch -p1 < ${./0001-allow-disabling-mining-pool-fetching.patch}
cd ..
''; '';
# Placeholder: build once, then replace with the hash from the # Placeholder: build once, then replace with the hash from the
@@ -96,22 +99,13 @@ in rec {
rsync rsync
]; ];
# Apply patches only in the main build, not in the npmDeps fetcher.
# prePatch runs before patchPhase in the main build only.
prePatch = ''
cd backend
'';
postPatch = ''
patch -p1 < ${./0001-allow-disabling-mining-pool-fetching.patch}
'';
dontNpmBuild = true; dontNpmBuild = true;
dontNpmInstall = true; dontNpmInstall = true;
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
cd backend
patchShebangs node_modules patchShebangs node_modules
${sync} ${mempool-rust-gbt}/ rust-gbt ${sync} ${mempool-rust-gbt}/ rust-gbt
@@ -154,10 +148,10 @@ in rec {
pname = "mempool-frontend"; pname = "mempool-frontend";
inherit version src; inherit version src;
# cd into the frontend subdir so the npmDeps fetcher finds # postPatch runs in the npmDeps fetcher too. Copy the lock file to
# package-lock.json at its CWD. # the repo root so prefetch-npm-deps can find it.
preBuild = '' postPatch = ''
cd frontend cp frontend/package-lock.json .
''; '';
# Placeholder: build once, then replace with the hash from the # Placeholder: build once, then replace with the hash from the
@@ -175,6 +169,7 @@ in rec {
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
cd frontend
patchShebangs node_modules patchShebangs node_modules
# sync-assets.js is called during `npm run build` and downloads assets from the # sync-assets.js is called during `npm run build` and downloads assets from the