Add vendored RTL package and fix rtl.nix to use it

- Create packages/rtl/default.nix to build RTL from source
- Update modules/bitcoin/rtl.nix to use vendored package instead of pkgs.rtl
- Remove clightning/lightning-loop references (Sovran is LND-only)
- Simplify to LND-only configuration
This commit is contained in:
Sovran Systems
2026-08-10 10:38:20 -05:00
parent 8bcabe2aa1
commit 179fc501f9
2 changed files with 162 additions and 118 deletions
+83 -104
View File
@@ -3,164 +3,146 @@
with lib; with lib;
let let
options.services.rtl = { options.services.rtl = {
enable = mkEnableOption "Ride The Lightning, a web interface for lnd and clightning"; enable = mkEnableOption "RTL, a web interface for LND";
address = mkOption { address = mkOption {
type = types.str; type = types.str;
default = "127.0.0.1"; default = "127.0.0.1";
description = "HTTP server address."; description = "Address to listen for HTTP connections.";
}; };
port = mkOption { port = mkOption {
type = types.port; type = types.port;
default = 3000; default = 3000;
description = "HTTP server port."; description = "Port to listen for HTTP connections.";
}; };
dataDir = mkOption { dataDir = mkOption {
type = types.path; type = types.path;
default = "/var/lib/rtl"; default = "/var/lib/rtl";
description = "The data directory for RTL."; description = "The data directory for RTL.";
}; };
nodes = {
clightning = { nightTheme = mkOption {
enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = "Enable the clightning node interface."; description = "Enable night theme by default.";
};
extraConfig = mkOption {
type = with types; attrsOf anything;
default = {};
example = {
Settings.userPersona = "MERCHANT";
Settings.logLevel = "DEBUG";
}; };
extraCurrency = mkOption {
type = types.nullOr types.str;
default = null;
example = "USD";
description = '' description = ''
Extra clightning node configuration. Additional currency for displaying amounts.
See here for all available options: When set, Tor is disabled for the RTL service to allow currency rate fetching.
https://github.com/Ride-The-Lightning/RTL/blob/master/.github/docs/Application_configurations.md
''; '';
}; };
};
nodes = {
lnd = { lnd = {
enable = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = "Enable the lnd node interface."; description = "Enable LND node in RTL.";
}; };
loop = mkOption { loop = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = "Enable swaps with lightning-loop."; description = "Enable Lightning Loop integration (requires loopd).";
};
extraConfig = mkOption {
type = with types; attrsOf anything;
default = {};
example = {
Settings.userPersona = "MERCHANT";
Settings.logLevel = "DEBUG";
};
description = ''
Extra lnd node configuration.
See here for all available options:
https://github.com/Ride-The-Lightning/RTL/blob/master/.github/docs/Application_configurations.md
'';
}; };
}; };
reverseOrder = mkOption { clightning = {
enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = '' description = "Enable Core Lightning node in RTL (not supported in Sovran).";
Reverse the order of nodes shown in the UI.
By default, clightning is shown before lnd.
'';
}; };
}; };
nightTheme = mkOption {
type = types.bool;
default = false;
description = "Enable the Night UI Theme.";
};
extraCurrency = mkOption {
type = with types; nullOr str;
default = null;
example = "USD";
description = ''
Currency code (ISO 4217) of the extra currency used for displaying balances.
When set, this option enables online currency rate fetching.
Warning: Rate fetching requires outgoing clearnet connections, so option
{option}`tor.enforce` is automatically disabled.
'';
}; };
user = mkOption { user = mkOption {
type = types.str; type = types.str;
default = "rtl"; default = "rtl";
description = "The user as which to run RTL."; description = "The user as which to run RTL.";
}; };
group = mkOption { group = mkOption {
type = types.str; type = types.str;
default = cfg.user; default = cfg.user;
description = "The group as which to run RTL."; description = "The group as which to run RTL.";
}; };
tor.enforce = nbLib.tor.enforce;
tor = nbLib.tor;
}; };
cfg = config.services.rtl; cfg = config.services.rtl;
nbLib = config.nix-bitcoin.lib; nbLib = config.nix-bitcoin.lib;
nbPkgs = pkgs;
secretsDir = config.nix-bitcoin.secretsDir; secretsDir = config.nix-bitcoin.secretsDir;
runePath = "${cfg.dataDir}/clightning-admin-rune";
inherit (nbLib) optionalAttr; # Vendored RTL package
rtlPackage = pkgs.callPackage ../../packages/rtl {};
node = { isLnd, index }: { runePath = "${cfg.dataDir}/CLN-Rune.env";
inherit index;
lnNode = "Node"; rtlConfig = {
lnImplementation = if isLnd then "LND" else "CLT"; multiPass = "@multiPass@";
port = cfg.port;
host = cfg.address;
defaultNodeIndex = 1;
dbDirectoryPath = cfg.dataDir;
SSO = {
rtlSSO = 0;
rtlCookiePath = "";
logoutRedirectLink = "";
};
nodes = optional cfg.nodes.lnd.enable ({
index = 1;
lnNode = "lnd";
lnImplementation = "LND";
Authentication = { Authentication = {
${optionalAttr (isLnd && lndLoopEnabled) "swapMacaroonPath"} = "${(lightning-loop.dataDir or "/var/lib/lightning-loop")}/${bitcoind.network}"; macaroonPath = "${cfg.dataDir}/macaroons";
${optionalAttr (isLnd) "macaroonPath"} = "${cfg.dataDir}/macaroons"; swapMacaroonPath = if cfg.nodes.lnd.loop then "${cfg.dataDir}/loop-macaroons" else "";
${optionalAttr (!isLnd) "runePath"} = runePath; boltzMacaroonPath = "";
}; };
Settings = { Settings = {
userPersona = "OPERATOR"; userPersona = "OPERATOR";
themeMode = if cfg.nightTheme then "NIGHT" else "DAY"; themeMode = if cfg.nightTheme then "NIGHT" else "DAY";
themeColor = "PURPLE"; themeColor = "PURPLE";
${optionalAttr isLnd "channelBackupPath"} = "${cfg.dataDir}/backup/lnd"; channelBackupPath = "${cfg.dataDir}/backup";
logLevel = "INFO"; logLevel = "INFO";
fiatConversion = cfg.extraCurrency != null; fiatConversion = cfg.extraCurrency != null;
${optionalAttr (cfg.extraCurrency != null) "currencyUnit"} = cfg.extraCurrency; unannouncedChannels = true;
${optionalAttr (isLnd && lndLoopEnabled) "swapServerUrl"} = } // optionalAttrs (cfg.extraCurrency != null) {
"https://${nbLib.addressWithPort (lightning-loop.restAddress or "127.0.0.1") (lightning-loop.restPort or 8081)}"; currencyUnit = cfg.extraCurrency;
lnServerUrl = "https://${ };
if isLnd } // optionalAttrs cfg.nodes.lnd.loop {
then nbLib.addressWithPort lnd.restAddress lnd.restPort swapServerUrl = "https://localhost:8081";
else nbLib.addressWithPort clightning.plugins.clnrest.address clightning.plugins.clnrest.port boltzServerUrl = "";
}"; }) ++ optional cfg.nodes.clightning.enable {
index = 2;
lnNode = "clightning";
lnImplementation = "CLN";
Authentication = {
runePath = runePath;
};
Settings = {
userPersona = "OPERATOR";
themeMode = if cfg.nightTheme then "NIGHT" else "DAY";
themeColor = "PURPLE";
logLevel = "INFO";
fiatConversion = cfg.extraCurrency != null;
} // optionalAttrs (cfg.extraCurrency != null) {
currencyUnit = cfg.extraCurrency;
}; };
}; };
nodes' =
optional cfg.nodes.clightning.enable
(recursiveUpdate (node { isLnd = false; index = 1; }) cfg.nodes.clightning.extraConfig) ++
optional cfg.nodes.lnd.enable
(recursiveUpdate (node { isLnd = true; index = 2; }) cfg.nodes.lnd.extraConfig);
nodes = if cfg.nodes.reverseOrder then reverseList nodes' else nodes';
rtlConfig = {
multiPass = "@multiPass@";
host = cfg.address;
port = cfg.port;
SSO.rtlSSO = 0;
inherit nodes;
}; };
configFile = builtins.toFile "config" (builtins.toJSON rtlConfig); configFile = builtins.toFile "config" (builtins.toJSON rtlConfig);
inherit (config.services) inherit (config.services)
bitcoind bitcoind
lnd lnd;
clightning
lightning-loop;
lndLoopEnabled = cfg.nodes.lnd.enable && cfg.nodes.lnd.loop; lndLoopEnabled = cfg.nodes.lnd.enable && cfg.nodes.lnd.loop;
in { in {
@@ -168,16 +150,19 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [ assertions = [
{ assertion = cfg.nodes.clightning.enable || cfg.nodes.lnd.enable; { assertion = cfg.nodes.lnd.enable;
message = '' message = ''
RTL: At least one of `nodes.lnd.enable` or `nodes.clightning.enable` must be `true`. RTL: At least one node must be enabled. Sovran supports LND only.
'';
}
{ assertion = !cfg.nodes.clightning.enable;
message = ''
RTL: Core Lightning (clightning) is not supported in Sovran. Use LND instead.
''; '';
} }
]; ];
services.lnd.enable = mkIf cfg.nodes.lnd.enable true; # lightning-loop removed - not used services.lnd.enable = mkIf cfg.nodes.lnd.enable true;
# vendored fix: clightning may not exist in this nixpkgs
# clightning removed - Sovran uses lnd only
systemd.tmpfiles.rules = [ systemd.tmpfiles.rules = [
"d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -" "d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -"
@@ -187,8 +172,7 @@ in {
systemd.services.rtl = rec { systemd.services.rtl = rec {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
wants = optional cfg.nodes.clightning.enable "clightning.service" ++ wants = optional cfg.nodes.lnd.enable "lnd.service";
optional cfg.nodes.lnd.enable "lnd.service";
after = wants ++ [ "nix-bitcoin-secrets.target" ]; after = wants ++ [ "nix-bitcoin-secrets.target" ];
environment.RTL_CONFIG_PATH = cfg.dataDir; environment.RTL_CONFIG_PATH = cfg.dataDir;
environment.DB_DIRECTORY_PATH = cfg.dataDir; environment.DB_DIRECTORY_PATH = cfg.dataDir;
@@ -204,13 +188,8 @@ in {
(nbLib.rootScript "rtl-copy-macaroon" '' (nbLib.rootScript "rtl-copy-macaroon" ''
install --compare -m 640 -o ${cfg.user} -g ${cfg.group} -D ${lnd.networkDir}/admin.macaroon \ install --compare -m 640 -o ${cfg.user} -g ${cfg.group} -D ${lnd.networkDir}/admin.macaroon \
'${cfg.dataDir}/macaroons/admin.macaroon' '${cfg.dataDir}/macaroons/admin.macaroon'
'')
++ optional cfg.nodes.clightning.enable
(nbLib.rootScript "rtl-create-clnrest-rune-file" ''
rune=$(cat '${clightning.networkDir}/admin-rune')
install --compare -m 640 -o ${cfg.user} -g ${cfg.group} <(printf 'LIGHTNING_RUNE="%s"\n' "$rune") '${runePath}'
''); '');
ExecStart = "${pkgs.rtl}/bin/rtl"; ExecStart = "${rtlPackage}/bin/rtl";
# Show "rtl" instead of "node" in the journal # Show "rtl" instead of "node" in the journal
SyslogIdentifier = "rtl"; SyslogIdentifier = "rtl";
User = cfg.user; User = cfg.user;
+65
View File
@@ -0,0 +1,65 @@
{ lib
, stdenvNoCC
, nodejs_22
, nodejs-slim_22
, fetchurl
, makeWrapper
}:
let
version = "0.15.8";
src = fetchurl {
url = "https://github.com/Ride-The-Lightning/RTL/archive/refs/tags/v${version}.tar.gz";
hash = "sha256-8XdGyORxB2dkZRB/Yl7zh+Quqo4L/Y0VmC6Brbr/hqU=";
};
in stdenvNoCC.mkDerivation {
pname = "rtl";
inherit version src;
nativeBuildInputs = [
makeWrapper
nodejs_22
];
phases = "unpackPhase buildPhase installPhase";
buildPhase = ''
# Install dependencies using npm ci (requires package-lock.json)
npm ci --legacy-peer-deps --ignore-scripts
'';
# `src` already contains the precompiled frontend and backend.
# Copy all files required for packaging, like in
# https://github.com/Ride-The-Lightning/RTL/blob/master/dockerfiles/Dockerfile
installPhase = ''
dest=$out/lib/node_modules/rtl
mkdir -p $dest
cp -r \
rtl.js \
package.json \
frontend \
backend \
node_modules \
$dest
makeWrapper ${nodejs-slim_22}/bin/node "$out/bin/rtl" \
--add-flags "$dest/rtl.js"
runHook postInstall
'';
passthru = {
nodejs = nodejs_22;
nodejsRuntime = nodejs-slim_22;
};
meta = with lib; {
description = "A web interface for LND";
homepage = "https://github.com/Ride-The-Lightning/RTL";
license = licenses.mit;
maintainers = with maintainers; [ ];
platforms = platforms.unix;
};
}