Mempool: switch backend and frontend to buildNpmPackage with placeholder npmDepsHash
npm ci in buildPhase hangs because the Nix build sandbox has no network access. buildNpmPackage pre-fetches dependencies as a fixed-output derivation with network access, then the main build runs offline. npmDepsHash values are placeholders (lib.fakeHash) — the first builds will fail with hash mismatches that report the correct hashes.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
, stdenvNoCC
|
, stdenvNoCC
|
||||||
, nodejs_22
|
, nodejs_22
|
||||||
, nodejs-slim_22
|
, nodejs-slim_22
|
||||||
|
, buildNpmPackage
|
||||||
, fetchFromGitHub
|
, fetchFromGitHub
|
||||||
, runCommand
|
, runCommand
|
||||||
, makeWrapper
|
, makeWrapper
|
||||||
@@ -74,36 +75,30 @@ let
|
|||||||
|
|
||||||
sync = "${rsync}/bin/rsync -a --inplace";
|
sync = "${rsync}/bin/rsync -a --inplace";
|
||||||
|
|
||||||
mkDerivationMempool = args: stdenvNoCC.mkDerivation ({
|
in rec {
|
||||||
|
mempool-backend = buildNpmPackage {
|
||||||
|
pname = "mempool-backend";
|
||||||
inherit version src;
|
inherit version src;
|
||||||
|
|
||||||
nativeBuildInputs = [
|
sourceRoot = "source/backend";
|
||||||
makeWrapper
|
|
||||||
nodejs_22
|
|
||||||
rsync
|
|
||||||
];
|
|
||||||
|
|
||||||
phases = "unpackPhase patchPhase buildPhase installPhase";
|
# Placeholder: build once, then replace with the hash from the
|
||||||
|
# "hash mismatch" error output.
|
||||||
meta = with lib; {
|
npmDepsHash = lib.fakeHash;
|
||||||
description = "Bitcoin blockchain and mempool explorer";
|
|
||||||
homepage = "https://github.com/mempool/mempool/";
|
|
||||||
license = licenses.agpl3Plus;
|
|
||||||
maintainers = with maintainers; [ erikarvstedt ];
|
|
||||||
platforms = platforms.unix;
|
|
||||||
};
|
|
||||||
} // args);
|
|
||||||
|
|
||||||
in rec {
|
|
||||||
mempool-backend = mkDerivationMempool {
|
|
||||||
pname = "mempool-backend";
|
|
||||||
|
|
||||||
patches = [ ./0001-allow-disabling-mining-pool-fetching.patch ];
|
patches = [ ./0001-allow-disabling-mining-pool-fetching.patch ];
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
makeWrapper
|
||||||
|
rsync
|
||||||
|
];
|
||||||
|
|
||||||
|
dontNpmBuild = true;
|
||||||
|
dontNpmInstall = true;
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
cd backend
|
runHook preBuild
|
||||||
# Install dependencies using npm ci (requires package-lock.json)
|
|
||||||
npm ci --legacy-peer-deps --ignore-scripts
|
|
||||||
patchShebangs node_modules
|
patchShebangs node_modules
|
||||||
|
|
||||||
${sync} ${mempool-rust-gbt}/ rust-gbt
|
${sync} ${mempool-rust-gbt}/ rust-gbt
|
||||||
@@ -126,20 +121,43 @@ in rec {
|
|||||||
nodejs = nodejs_22;
|
nodejs = nodejs_22;
|
||||||
nodejsRuntime = nodejs-slim_22;
|
nodejsRuntime = nodejs-slim_22;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "Bitcoin blockchain and mempool explorer (backend)";
|
||||||
|
homepage = "https://github.com/mempool/mempool/";
|
||||||
|
license = licenses.agpl3Plus;
|
||||||
|
platforms = platforms.unix;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
mempool-frontend = mkFrontend {};
|
mempool-frontend = mkFrontend {};
|
||||||
|
|
||||||
# Argument `config` (type: attrset) defines the mempool frontend config.
|
# Argument `config` (type: attrset) defines the mempool frontend config.
|
||||||
# If `{}`, the default config is used.
|
# If `{}`, the default config is used.
|
||||||
mkFrontend = config: mkDerivationMempool {
|
# See here for available options:
|
||||||
|
# https://github.com/mempool/mempool/blob/master/frontend/src/app/services/state.service.ts
|
||||||
|
# (`interface Env` and `defaultEnv`)
|
||||||
|
mkFrontend = config: buildNpmPackage {
|
||||||
pname = "mempool-frontend";
|
pname = "mempool-frontend";
|
||||||
|
inherit version src;
|
||||||
|
|
||||||
|
sourceRoot = "source/frontend";
|
||||||
|
|
||||||
|
# Placeholder: build once, then replace with the hash from the
|
||||||
|
# "hash mismatch" error output.
|
||||||
|
npmDepsHash = lib.fakeHash;
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
makeWrapper
|
||||||
|
rsync
|
||||||
|
];
|
||||||
|
|
||||||
|
dontNpmBuild = true;
|
||||||
|
dontNpmInstall = true;
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
cd frontend
|
runHook preBuild
|
||||||
|
|
||||||
# Install dependencies using npm ci (requires package-lock.json)
|
|
||||||
npm ci --legacy-peer-deps --ignore-scripts
|
|
||||||
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
|
||||||
@@ -168,6 +186,13 @@ in rec {
|
|||||||
withConfig = mkFrontend;
|
withConfig = mkFrontend;
|
||||||
assets = frontendAssets;
|
assets = frontendAssets;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "Bitcoin blockchain and mempool explorer (frontend)";
|
||||||
|
homepage = "https://github.com/mempool/mempool/";
|
||||||
|
license = licenses.agpl3Plus;
|
||||||
|
platforms = platforms.unix;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
mempool-nginx-conf = runCommand "mempool-nginx-conf" {} ''
|
mempool-nginx-conf = runCommand "mempool-nginx-conf" {} ''
|
||||||
|
|||||||
Reference in New Issue
Block a user