Skip to content

Commit

Permalink
albyhub: build ldk-node from source
Browse files Browse the repository at this point in the history
  • Loading branch information
bleetube committed Mar 11, 2025
1 parent b73a17e commit ab84d36
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 24 deletions.
27 changes: 14 additions & 13 deletions pkgs/by-name/al/albyhub/ldk-node-go/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
buildGoModule,
fetchFromGitHub,
stdenv,
# ldkNode,
callPackage,
...
}:

let
ldkNode = callPackage ../ldk-node { };
in

buildGoModule rec {
pname = "ldk-node-go";
version = "unstable-2024-12-11";
version = "8911834564db720e9b22950441df706d69622d81";

src = fetchFromGitHub {
owner = "getAlby";
Expand All @@ -23,18 +30,12 @@ buildGoModule rec {
"-w"
];

installPhase = ''
mkdir -p $out/lib
case ${stdenv.hostPlatform.parsed.cpu.name} in
x86_64|aarch64)
cp -v "${src}/ldk_node/${stdenv.hostPlatform.parsed.cpu.name}-unknown-linux-gnu/libldk_node.so" $out/lib/
;;
*)
echo "Unsupported architecture: ${stdenv.hostPlatform.parsed.cpu.name}"
exit 1
;;
esac
'';
buildInputs = [
ldkNode
];

# Ensure this package provides its library to dependent packages
propagatedBuildInputs = [ ldkNode ];

meta = {
description = "Experimental Go bindings for LDK-node";
Expand Down
15 changes: 8 additions & 7 deletions pkgs/by-name/al/albyhub/ldk-node/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
lib,
rustPlatform,
fetchFromGitHub,
fetchurl,
pkg-config,
protobuf,
bzip2,
Expand All @@ -13,23 +14,27 @@

rustPlatform.buildRustPackage rec {
pname = "ldk-node";
version = "unstable-2024-12-23";
version = "3152b8a0c180d0b7e402d2563192f85e6f027f4f";

src = fetchFromGitHub {
owner = "getAlby";
repo = "ldk-node";
rev = "3152b8a0c180d0b7e402d2563192f85e6f027f4f";
rev = version;
hash = "sha256-4/SGfM0VmVnLLC+7UGfbc0/QRiPZDX1q7l5Dd6vfxWI=";
};

cargoLock = {
lockFile = ./Cargo.lock;
};

buildFeatures = [ "uniffi" ];

postPatch = ''
ln -s ${./Cargo.lock} Cargo.lock
'';

doCheck = false;

nativeBuildInputs = [
pkg-config
protobuf
Expand All @@ -47,11 +52,7 @@ rustPlatform.buildRustPackage rec {
darwin.apple_sdk.frameworks.SystemConfiguration
];

env = {
ZSTD_SYS_USE_PKG_CONFIG = true;
};

meta = {
meta = { # This is for building libldk_node.so
description = "Embeds the LDK node implementation compiled as shared library objects";
homepage = "https://github.com/getAlby/ldk-node";
changelog = "https://github.com/getAlby/ldk-node/blob/${src.rev}/CHANGELOG.md";
Expand Down
20 changes: 16 additions & 4 deletions pkgs/by-name/al/albyhub/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
}:

let
ldkNodeGo = callPackage ./ldk-node-go { };
ldkNode = callPackage ./ldk-node { };
ldkNodeGo = callPackage ./ldk-node-go {
inherit ldkNode;
};
glalbyGo = callPackage ./glalby-go { };
breezSdkGo = callPackage ./breez-sdk-go { };
in
Expand Down Expand Up @@ -54,6 +57,7 @@ buildGoModule rec {

preBuild = ''
export HOME=$TMPDIR
pushd frontend
fixup-yarn-lock yarn.lock
yarn config set yarn-offline-mirror "${frontendYarnOfflineCache}"
Expand All @@ -74,12 +78,20 @@ buildGoModule rec {
];

postInstall = ''
patchelf --set-rpath "${lib.makeLibraryPath buildInputs}" $out/bin/http
mkdir -p $out/lib
patchelf --set-rpath "${lib.makeLibraryPath [
glalbyGo
breezSdkGo
]}" $out/bin/http
'';

postFixup = ''
wrapProgram $out/bin/http --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
wrapProgram $out/bin/http --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [
glalbyGo
breezSdkGo
ldkNode
ldkNodeGo
stdenv.cc.cc.lib
]}
'';

meta = {
Expand Down

0 comments on commit ab84d36

Please sign in to comment.