From 72d265d5480d5ad99085e2f56e1f5cd5a85dfe5c Mon Sep 17 00:00:00 2001 From: Peter Neuroth Date: Thu, 3 Mar 2022 13:57:36 +0100 Subject: [PATCH 1/3] clightning: add darwin support - Patch usage of gsed to sed - Add darwin natives --- .../blockchains/clightning/default.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/blockchains/clightning/default.nix b/pkgs/applications/blockchains/clightning/default.nix index df7eace3284d..c51a2ced056c 100644 --- a/pkgs/applications/blockchains/clightning/default.nix +++ b/pkgs/applications/blockchains/clightning/default.nix @@ -1,5 +1,6 @@ { lib , stdenv +, darwin , fetchurl , autoconf , automake @@ -27,16 +28,25 @@ stdenv.mkDerivation rec { sha256 = "3c9dcb686217b2efe0e988e90b95777c4591e3335e259e01a94af87e0bf01809"; }; - nativeBuildInputs = [ autogen autoconf automake gettext libtool pkg-config py3 unzip which ]; + # when building on darwin we need dawin.cctools to provide the correct libtool + # as libwally-core detects the host as darwin and tries to add the -static + # option to libtool, also we have to add the modified gsed package. + nativeBuildInputs = [ autogen autoconf automake gettext pkg-config py3 unzip which ] + ++ lib.optionals stdenv.isDarwin [ darwin.cctools ] ++ [ libtool ]; buildInputs = [ gmp libsodium sqlite zlib ]; - postPatch = '' + # this causes some python trouble on a darwin host so we skip this step. + # also we have to tell libwally-core to use sed instead of gsed. + postPatch = if !stdenv.isDarwin then '' patchShebangs \ tools/generate-wire.py \ tools/update-mocks.sh \ tools/mockup.sh \ devtools/sql-rewrite.py + '' else '' + substituteInPlace external/libwally-core/tools/autogen.sh --replace gsed sed && \ + substituteInPlace external/libwally-core/configure.ac --replace gsed sed ''; configureFlags = [ "--disable-developer" "--disable-valgrind" ]; @@ -56,6 +66,6 @@ stdenv.mkDerivation rec { homepage = "https://github.com/ElementsProject/lightning"; maintainers = with maintainers; [ jb55 prusnak ]; license = licenses.mit; - platforms = platforms.linux; + platforms = platforms.linux ++ [ "x86_64-darwin" ]; }; } From 324f0a4e76cc1c2ce42179fc58d2bdd043deb089 Mon Sep 17 00:00:00 2001 From: Peter Neuroth Date: Thu, 3 Mar 2022 14:02:50 +0100 Subject: [PATCH 2/3] fixup! clightning: add darwin support --- pkgs/applications/blockchains/clightning/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/blockchains/clightning/default.nix b/pkgs/applications/blockchains/clightning/default.nix index c51a2ced056c..b6f149e3a7f1 100644 --- a/pkgs/applications/blockchains/clightning/default.nix +++ b/pkgs/applications/blockchains/clightning/default.nix @@ -31,7 +31,7 @@ stdenv.mkDerivation rec { # when building on darwin we need dawin.cctools to provide the correct libtool # as libwally-core detects the host as darwin and tries to add the -static # option to libtool, also we have to add the modified gsed package. - nativeBuildInputs = [ autogen autoconf automake gettext pkg-config py3 unzip which ] + nativeBuildInputs = [ autogen autoconf automake gettext pkg-config py3 unzip which ] ++ lib.optionals stdenv.isDarwin [ darwin.cctools ] ++ [ libtool ]; buildInputs = [ gmp libsodium sqlite zlib ]; From d39c8a2bf69a0e66b7f36eaa6187f21bc4893f11 Mon Sep 17 00:00:00 2001 From: Peter Neuroth Date: Fri, 4 Mar 2022 15:56:48 +0100 Subject: [PATCH 3/3] clightning: add sigining for darwin We need this for darwin-aarch64 support --- pkgs/applications/blockchains/clightning/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/blockchains/clightning/default.nix b/pkgs/applications/blockchains/clightning/default.nix index b6f149e3a7f1..b58524d1eee3 100644 --- a/pkgs/applications/blockchains/clightning/default.nix +++ b/pkgs/applications/blockchains/clightning/default.nix @@ -32,7 +32,7 @@ stdenv.mkDerivation rec { # as libwally-core detects the host as darwin and tries to add the -static # option to libtool, also we have to add the modified gsed package. nativeBuildInputs = [ autogen autoconf automake gettext pkg-config py3 unzip which ] - ++ lib.optionals stdenv.isDarwin [ darwin.cctools ] ++ [ libtool ]; + ++ lib.optionals stdenv.isDarwin [ darwin.cctools darwin.autoSignDarwinBinariesHook ] ++ [ libtool ]; buildInputs = [ gmp libsodium sqlite zlib ]; @@ -66,6 +66,6 @@ stdenv.mkDerivation rec { homepage = "https://github.com/ElementsProject/lightning"; maintainers = with maintainers; [ jb55 prusnak ]; license = licenses.mit; - platforms = platforms.linux ++ [ "x86_64-darwin" ]; + platforms = platforms.linux ++ platforms.darwin; }; }