mempool: add frontend settings

This commit is contained in:
Erik Arvstedt 2025-06-01 23:03:33 +02:00
parent 81112a0553
commit 7822e2c9d3
No known key found for this signature in database
GPG key ID: 33312B944DD97846
3 changed files with 33 additions and 4 deletions

View file

@ -111,7 +111,10 @@ with lib;
];
services.mempool = {
enable = true;
frontend.address = "0.0.0.0";
frontend = {
address = "0.0.0.0";
settings.LIQUID_ENABLED = true;
};
};
nix-bitcoin.nodeinfo.enable = true;
};

View file

@ -50,9 +50,23 @@ let
default = 60845; # A random private port
description = "HTTP server port.";
};
settings = mkOption {
type = with types; attrsOf anything;
default = {};
example = {
TESTNET_ENABLED = true;
MEMPOOL_WEBSITE_URL = "mempool.mynode.org";
};
description = ''
Mempool frontend settings.
See here for available options:
https://github.com/mempool/mempool/blob/master/frontend/src/app/services/state.service.ts
(`interface Env` and `defaultEnv`)
'';
};
staticContentRoot = mkOption {
type = types.path;
default = nbPkgs.mempool-frontend;
default = nbPkgs.mempool-frontend.withConfig cfg.frontend.settings;
defaultText = "config.nix-bitcoin.pkgs.mempool-frontend";
description = "
Path of the static frontend content root.
@ -106,7 +120,7 @@ let
};
description = ''
Mempool backend settings.
See here for possible options:
See here for available options:
https://github.com/mempool/mempool/blob/master/backend/src/config.ts
'';
};

View file

@ -79,7 +79,14 @@ rec {
};
};
mempool-frontend = mkDerivationMempool {
mempool-frontend = mkFrontend {};
# Argument `config` (type: attrset) defines the mempool frontend config.
# If `{}`, the default config is used.
# 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: mkDerivationMempool {
pname = "mempool-frontend";
buildPhase = ''
@ -92,6 +99,10 @@ rec {
# internet. Disable this script and instead add the assets manually after building.
: > sync-assets.js
${lib.optionalString (config != {}) ''
ln -s ${builtins.toFile "mempool-frontend-config" (builtins.toJSON config)} mempool-frontend-config.json
''}
npm run build
# Add assets that would otherwise be downloaded by sync-assets.js
@ -107,6 +118,7 @@ rec {
'';
passthru = {
withConfig = mkFrontend;
assets = frontendAssets;
nodeModules = nodeModules.frontend;
};