servo: try to integrate peerswap with clightning, but it fails

This commit is contained in:
Colin 2024-01-14 04:33:12 +00:00
parent faa0a7c9ea
commit 02e03227d8
2 changed files with 25 additions and 1 deletions

View File

@ -70,7 +70,7 @@
# - maxfeepercent defaults to 0.5
# - label is a human-friendly label for my records
{ config, ... }:
{ config, pkgs, ... }:
{
sane.persist.sys.byStore.ext = [
{ user = "clightning"; group = "clightning"; mode = "0710"; path = "/var/lib/clightning"; }
@ -117,6 +117,12 @@
# - feature configs (i.e. experimental-xyz options)
sane.services.clightning.extraConfig = ''
log-level=debug:lightningd
# peerswap:
# - config example: <https://github.com/fort-nix/nix-bitcoin/pull/462/files#diff-b357d832705b8ce8df1f41934d613f79adb77c4cd5cd9e9eb12a163fca3e16c6>
# XXX: peerswap crashes clightning on launch. stacktrace is useless.
# plugin=${pkgs.peerswap}/bin/peerswap
# peerswap-db-path=/var/lib/clightning/peerswap/swaps
# peerswap-policy-path=...
'';
sane.services.clightning.extraConfigFiles = [ config.sops.secrets."lightning-config".path ];
sops.secrets."lightning-config" = {

View File

@ -26,6 +26,24 @@ buildGoModule rec {
vendorHash = "sha256-OOwXWsFVxieOtzF7arXVNeWo4YB/EQbxQMAIxDVIhfg=";
proxyVendor = true;
postPatch = ''
# upstream Makefile builds with `-ldflags "-X main.GitCommit=<hash>"`, but we bypass Makefile and have to do that manually.
# GOFLAGS or CGO_LDFLAGS could both sort of do this, but they struggle with the spaces/quoting of the above,
# so instead i manually patch in the values
substituteInPlace cmd/peerswap-plugin/main.go \
--replace 'var GitCommit string' 'var GitCommit string = "${src.rev}"'
substituteInPlace cmd/peerswaplnd/peerswapd/main.go \
--replace 'var GitCommit string' 'var GitCommit string = "${src.rev}"'
substituteInPlace cmd/peerswaplnd/pscli/main.go \
--replace 'var GitCommit string' 'var GitCommit string = "${src.rev}"'
'';
postInstall = ''
# the upstream Makefile compiles peerswap-plugin/main.go into a binary named `peerswap`,
# but since we use buildGoModule, that doesn't go through the Makefile and we have to manually rename.
mv $out/bin/peerswap-plugin $out/bin/peerswap
'';
meta = with lib; {
description = "PeerSwap enables Lightning Network nodes to balance their channels by facilitating atomic swaps with direct peers.";
homepage = "https://peerswap.dev";