refactor: collapse fakewallet/regtest wrappers into single dev CLI
Replaces the two parallel scripts (fakewallet.sh, regtest.sh) with one
modules/dev-env/scripts/dev.sh — `dev up [--fakewallet|--regtest]`,
plus `down|logs|shell`. Default mode is fakewallet (no docker, no
chains, instant), matching what the prior scaffold did with two scripts
but giving consumers one command and one verb-set to learn.
Drops the now-redundant `lnbits.backend` enum and `features.fakewallet`
option from core.nix. Backend selection is the dev CLI's runtime
concern; a NixOS-level option would be a second knob that can disagree
with the CLI flag at runtime. `lnbits.{host,port}` stay (bind addr,
useful to docs and any later service path). `features.regtest` stays
(gates docker engine installation — consumers who'll never use the
regtest mode shouldn't pay for the container engine).
Strips modules/lnbits.nix entirely. The dev CLI runs lnbits ad-hoc; if
a NixOS-managed lnbits service becomes a real ask later, re-add a
focused module then.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bbaa80d8a3
commit
94a7c5f97c
7 changed files with 66 additions and 157 deletions
|
|
@ -24,13 +24,10 @@
|
||||||
# Option schema (lnbits-sensei.*).
|
# Option schema (lnbits-sensei.*).
|
||||||
./modules/core.nix
|
./modules/core.nix
|
||||||
|
|
||||||
# LNbits service wrapper.
|
|
||||||
./modules/lnbits.nix
|
|
||||||
|
|
||||||
# Git remote topology — upstream / fork / extras.
|
# Git remote topology — upstream / fork / extras.
|
||||||
./modules/git/remotes.nix
|
./modules/git/remotes.nix
|
||||||
|
|
||||||
# Dev environment (worktree mgmt, regtest, fakewallet, tmux).
|
# Dev environment (worktree mgmt, regtest stack, dev CLI, tmux).
|
||||||
./modules/dev-env
|
./modules/dev-env
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,37 +49,20 @@ in
|
||||||
|
|
||||||
regtest = mkEnableOption ''
|
regtest = mkEnableOption ''
|
||||||
Full Bitcoin/Lightning regtest docker stack (LND + CLN + Eclair
|
Full Bitcoin/Lightning regtest docker stack (LND + CLN + Eclair
|
||||||
+ bitcoind + electrs). Implies a container engine. See
|
+ bitcoind + electrs). Implies a container engine — install
|
||||||
modules/dev-env/regtest.nix and modules/dev-env/scripts/regtest.sh
|
docker only if you actually plan to invoke `dev up --regtest`.
|
||||||
'';
|
The default `dev up` (FakeWallet) needs none of this
|
||||||
|
|
||||||
fakewallet = mkEnableOption ''
|
|
||||||
FakeWallet dev mode — no docker, no chains, nothing to start.
|
|
||||||
Default LNbits backend; this flag mostly controls dev-env
|
|
||||||
helpers and symmetry with the regtest workflow
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
# --- LNbits service config ---
|
# --- LNbits bind addr ---
|
||||||
|
#
|
||||||
|
# Backend selection lives in the `dev` CLI (--fakewallet | --regtest),
|
||||||
|
# not as a NixOS option: the dev-env scaffold doesn't manage a
|
||||||
|
# systemd lnbits service, and we don't want two knobs (build-time
|
||||||
|
# vs runtime) that can disagree.
|
||||||
|
|
||||||
lnbits = {
|
lnbits = {
|
||||||
backend = mkOption {
|
|
||||||
type = types.enum [
|
|
||||||
"FakeWallet"
|
|
||||||
"LndRestWallet"
|
|
||||||
"CoreLightningWallet"
|
|
||||||
"EclairWallet"
|
|
||||||
];
|
|
||||||
default = "FakeWallet";
|
|
||||||
description = ''
|
|
||||||
Which Lightning backend LNbits talks to. FakeWallet is the
|
|
||||||
default — no real chain, no docker, nothing to start. The
|
|
||||||
regtest dev mode (modules/dev-env/regtest.nix) flips this to
|
|
||||||
LndRestWallet or CoreLightningWallet at activation time.
|
|
||||||
'';
|
|
||||||
example = "LndRestWallet";
|
|
||||||
};
|
|
||||||
|
|
||||||
port = mkOption {
|
port = mkOption {
|
||||||
type = types.port;
|
type = types.port;
|
||||||
default = 5000;
|
default = 5000;
|
||||||
|
|
|
||||||
|
|
@ -121,8 +121,9 @@ in
|
||||||
enable = mkEnableOption ''
|
enable = mkEnableOption ''
|
||||||
Bitcoin/Lightning regtest docker stack. Wraps an upstream
|
Bitcoin/Lightning regtest docker stack. Wraps an upstream
|
||||||
fork of `lnbits/legend-regtest-enviroment` (LND + CLN +
|
fork of `lnbits/legend-regtest-enviroment` (LND + CLN +
|
||||||
Eclair + bitcoind + electrs). Implies a container engine —
|
Eclair + bitcoind + electrs). Brought up via
|
||||||
the substantive pass will gate this on a containers feature
|
`dev up --regtest`. Implies a container engine — the
|
||||||
|
substantive pass will gate this on a containers feature
|
||||||
'';
|
'';
|
||||||
|
|
||||||
repoUrl = mkOption {
|
repoUrl = mkOption {
|
||||||
|
|
@ -136,15 +137,6 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
fakewallet = {
|
|
||||||
enable = mkEnableOption ''
|
|
||||||
FakeWallet dev mode helpers. Installs the symmetric `fakewallet`
|
|
||||||
wrapper script (a no-op for parity with `regtest up`) so the
|
|
||||||
dev experience is identical whether you're on the default
|
|
||||||
FakeWallet path or the full regtest stack
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
tmux = {
|
tmux = {
|
||||||
enable = mkEnableOption "declarative tmux session launcher";
|
enable = mkEnableOption "declarative tmux session launcher";
|
||||||
|
|
||||||
|
|
|
||||||
53
modules/dev-env/scripts/dev.sh
Executable file
53
modules/dev-env/scripts/dev.sh
Executable file
|
|
@ -0,0 +1,53 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# dev — single entry point for spinning up an LNbits dev environment.
|
||||||
|
#
|
||||||
|
# dev up [--fakewallet|--regtest] start lnbits (default: --fakewallet)
|
||||||
|
# dev down tear down whatever's running
|
||||||
|
# dev logs follow lnbits (and docker, if regtest) logs
|
||||||
|
# dev shell drop into the lnbits venv (or regtest container)
|
||||||
|
#
|
||||||
|
# Modes:
|
||||||
|
# --fakewallet (default) LNBITS_BACKEND_WALLET_CLASS=FakeWallet — no docker,
|
||||||
|
# no chains, instant. Good for extension / UI work.
|
||||||
|
# --regtest docker-compose up the multi-node regtest stack
|
||||||
|
# (LND + CLN + Eclair + bitcoind + electrs), then
|
||||||
|
# start lnbits pointed at the LND-rest endpoint.
|
||||||
|
# Wraps lnbits/legend-regtest-enviroment.
|
||||||
|
#
|
||||||
|
# Skeleton — no real wiring yet. The substantive pass will:
|
||||||
|
# - locate the lnbits checkout via inputs.lnbits-src (or a configurable path)
|
||||||
|
# - locate the regtest docker repo via config.lnbits-sensei.devEnv.regtest.repoUrl
|
||||||
|
# - bring up containers, wait-for-it, populate LND credentials, exec lnbits
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
cmd="${1:-up}"
|
||||||
|
shift || true
|
||||||
|
|
||||||
|
mode="fakewallet"
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--fakewallet) mode="fakewallet"; shift ;;
|
||||||
|
--regtest) mode="regtest"; shift ;;
|
||||||
|
*) echo "dev: unknown flag: $1" >&2; exit 1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
case "$cmd" in
|
||||||
|
up)
|
||||||
|
echo "dev up --$mode: TODO — wire substantive startup in next pass."
|
||||||
|
;;
|
||||||
|
down)
|
||||||
|
echo "dev down: TODO — wire teardown in next pass."
|
||||||
|
;;
|
||||||
|
logs)
|
||||||
|
echo "dev logs: TODO — tail lnbits + (docker logs if regtest) here."
|
||||||
|
;;
|
||||||
|
shell)
|
||||||
|
echo "dev shell: TODO — drop into venv / regtest container here."
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: dev {up|down|logs|shell} [--fakewallet|--regtest]" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
# fakewallet.sh — symmetric no-op for parity with regtest.sh.
|
|
||||||
#
|
|
||||||
# FakeWallet is the default LNbits backend. There is nothing to start,
|
|
||||||
# nothing to stop, nothing to log: LNbits with `LNBITS_BACKEND_WALLET_CLASS=FakeWallet`
|
|
||||||
# just runs.
|
|
||||||
#
|
|
||||||
# This wrapper exists purely so the dev experience is symmetric with
|
|
||||||
# the regtest stack:
|
|
||||||
#
|
|
||||||
# fakewallet up # no-op, prints reassurance
|
|
||||||
# fakewallet down # no-op, prints reassurance
|
|
||||||
# fakewallet logs # tails lnbits' own logs (not a backend's)
|
|
||||||
# fakewallet shell # no-op (no container to enter)
|
|
||||||
#
|
|
||||||
# Muscle memory wins. `regtest up` and `fakewallet up` mean the same
|
|
||||||
# thing — "make the chosen backend ready" — even when one is a docker
|
|
||||||
# stack and the other is a constant.
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# TODO(skeleton): wire the substantive variants in a later pass.
|
|
||||||
# `up` / `down` / `shell` stay no-ops by design; `logs` should
|
|
||||||
# `journalctl --user -u lnbits` (or whatever unit the lnbits module
|
|
||||||
# ends up declaring) so the dev still has a single place to look.
|
|
||||||
|
|
||||||
case "${1:-up}" in
|
|
||||||
up | down | shell)
|
|
||||||
echo "FakeWallet is the default — nothing to start."
|
|
||||||
;;
|
|
||||||
logs)
|
|
||||||
echo "fakewallet logs: TODO — tail the lnbits service log here."
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Usage: fakewallet {up|down|logs|shell}"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
# regtest.sh — wrapper around a Bitcoin/Lightning regtest docker stack.
|
|
||||||
#
|
|
||||||
# Mirrors the workflow of `lnbits/legend-regtest-enviroment` (LND + CLN
|
|
||||||
# + Eclair + bitcoind + electrs). Cloned to
|
|
||||||
# `${dev-env.root}/local/docker/regtest/` by the bootstrap script
|
|
||||||
# (later pass); this wrapper just dispatches `up` / `down` / `logs` /
|
|
||||||
# `shell` to the underlying docker-compose stack.
|
|
||||||
#
|
|
||||||
# Symmetric with fakewallet.sh so the dev experience reads the same
|
|
||||||
# whether you're on the default FakeWallet path or the regtest stack:
|
|
||||||
#
|
|
||||||
# regtest up # boot the regtest stack
|
|
||||||
# regtest down # tear it down
|
|
||||||
# regtest logs # tail compose logs
|
|
||||||
# regtest shell # drop into a node container
|
|
||||||
#
|
|
||||||
# Once `regtest up` is healthy, point LNbits at the appropriate
|
|
||||||
# backend (LndRestWallet / CoreLightningWallet) by flipping
|
|
||||||
# `lnbits-sensei.lnbits.backend` and rebuilding.
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# TODO(skeleton): replace with real dispatcher in the substantive pass.
|
|
||||||
# Intended shape:
|
|
||||||
# case "${1:-}" in
|
|
||||||
# up) docker compose -f "${REGTEST_DIR}/docker-compose.yml" up -d ;;
|
|
||||||
# down) docker compose -f "${REGTEST_DIR}/docker-compose.yml" down ;;
|
|
||||||
# logs) docker compose -f "${REGTEST_DIR}/docker-compose.yml" logs -f ;;
|
|
||||||
# shell) docker compose -f "${REGTEST_DIR}/docker-compose.yml" exec "${2}" sh ;;
|
|
||||||
# *) usage ;;
|
|
||||||
# esac
|
|
||||||
|
|
||||||
echo "regtest: TODO — substantive implementation lands in a later pass."
|
|
||||||
echo "See modules/dev-env/scripts/regtest.sh for the intended dispatcher shape."
|
|
||||||
exit 0
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
# lnbits-sensei — LNbits service wrapper.
|
|
||||||
#
|
|
||||||
# Stub. Wraps an as-yet-unwritten `services.lnbits` NixOS module (or
|
|
||||||
# a hand-rolled systemd unit) and exposes the small surface area
|
|
||||||
# consumers actually tune: backend, port, host. Sourced from
|
|
||||||
# `config.lnbits-sensei.lnbits.*` so the option schema stays in
|
|
||||||
# modules/core.nix.
|
|
||||||
#
|
|
||||||
# Default `backend = "FakeWallet"` — no docker, no chains, nothing to
|
|
||||||
# start. The regtest mode (modules/dev-env/regtest.nix, scripts/regtest.sh)
|
|
||||||
# flips this to LndRestWallet / CoreLightningWallet and wires the
|
|
||||||
# credentials from the regtest stack's generated artifacts.
|
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (lib) mkIf;
|
|
||||||
cfg = config.lnbits-sensei;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
# TODO(skeleton): wire services.lnbits (or a hand-rolled systemd
|
|
||||||
# user/system unit) here. Intended shape:
|
|
||||||
#
|
|
||||||
# services.lnbits = {
|
|
||||||
# enable = true;
|
|
||||||
# backend = cfg.lnbits.backend;
|
|
||||||
# host = cfg.lnbits.host;
|
|
||||||
# port = cfg.lnbits.port;
|
|
||||||
# # source = inputs.lnbits-src; (resolved in flake.nix → specialArgs)
|
|
||||||
# };
|
|
||||||
#
|
|
||||||
# Until a real services.lnbits module is published in nixpkgs,
|
|
||||||
# the substantive pass will likely declare a systemd.services.lnbits
|
|
||||||
# entry that runs `poetry run lnbits` out of a checkout of
|
|
||||||
# `inputs.lnbits-src`.
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in a new issue