2024-01-14 02:36:43 +00:00
|
|
|
# based on: <https://github.com/fort-nix/nix-bitcoin/pull/462>
|
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, buildGoModule
|
|
|
|
}:
|
|
|
|
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "peerswap";
|
|
|
|
# the don't do releases yet
|
|
|
|
version = "unstable-20240111";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ElementsProject";
|
|
|
|
repo = "peerswap";
|
|
|
|
rev = "4d1270b9dd2986ce683f61e684996b5961b05db0";
|
|
|
|
hash = "sha256-lnmimWtkc2hy+SPzXMeybetZldSLbcPEN5apKGFYo7k=";
|
|
|
|
};
|
|
|
|
|
|
|
|
subPackages = [
|
|
|
|
"cmd/peerswaplnd/peerswapd"
|
|
|
|
"cmd/peerswaplnd/pscli"
|
|
|
|
"cmd/peerswap-plugin" # this becomes the actual `peerswap` binary
|
|
|
|
];
|
|
|
|
|
|
|
|
vendorHash = "sha256-OOwXWsFVxieOtzF7arXVNeWo4YB/EQbxQMAIxDVIhfg=";
|
|
|
|
proxyVendor = true;
|
|
|
|
|
2024-01-14 04:33:12 +00:00
|
|
|
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 \
|
2024-05-19 23:31:54 +00:00
|
|
|
--replace-fail 'var GitCommit string' 'var GitCommit string = "${src.rev}"'
|
2024-01-14 04:33:12 +00:00
|
|
|
substituteInPlace cmd/peerswaplnd/peerswapd/main.go \
|
2024-05-19 23:31:54 +00:00
|
|
|
--replace-fail 'var GitCommit string' 'var GitCommit string = "${src.rev}"'
|
2024-01-14 04:33:12 +00:00
|
|
|
substituteInPlace cmd/peerswaplnd/pscli/main.go \
|
2024-05-19 23:31:54 +00:00
|
|
|
--replace-fail 'var GitCommit string' 'var GitCommit string = "${src.rev}"'
|
2024-01-14 04:33:12 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2024-01-14 02:36:43 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "PeerSwap enables Lightning Network nodes to balance their channels by facilitating atomic swaps with direct peers.";
|
|
|
|
homepage = "https://peerswap.dev";
|
|
|
|
maintainers = with maintainers; [ colinsane ];
|
|
|
|
license = licenses.mit;
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|