From cde86ac852b533157cde76da0f3b1a4762f85690 Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Mon, 25 Mar 2024 23:21:07 +0100 Subject: [PATCH 1/2] meta: support nix flake for buliding As noted in [1] on Linux systems, it is not possible to build phoenixd due to a mismatch in the libc version. A possible solution is to use Nix and build phoenixd inside the shell with all the dependencies. This way, the host machine can use the binary directly without downgrading libc, which can be dangerous. [1] https://github.com/ACINQ/phoenixd/issues/1#issuecomment-2018205685 Co-authored-by: Pavol Rusnak Signed-off-by: Vincenzo Palazzo --- flake.nix | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 flake.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..c88b18cf --- /dev/null +++ b/flake.nix @@ -0,0 +1,68 @@ +{ + description = "Server equivalent of the popular Phoenix wallet"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ ]; + }; + + # Importing glibc 2.19 for compiling the recent version of curl + pkgs-glibc = import + (builtins.fetchTarball { + url = "https://github.com/NixOS/nixpkgs/archive/b6f505c60a2417d4fad4dc5245754e4e33eb4d40.tar.gz"; + sha256 = "sha256:0hhb8sar8qxi179d6c5h6n8f7nm71xxqqbynjv8pldvpsmsxxzh9"; + }) + { inherit system; }; + in + { + packages = { + default = pkgs.gnumake; + }; + formatter = pkgs.nixpkgs-fmt; + + devShell = pkgs.mkShellNoCC { + buildInputs = with pkgs; [ + # build dependencies + git + pkg-config + zlib + wget + + sqlite + jdk + gradle + kotlin + + # Ok this should help you lean a few things + # See https://github.com/ACINQ/phoenixd/issues/1#issuecomment-2018205685 + (pkgs.stdenv.mkDerivation { + name = "curl-7.87.0"; + src = pkgs.fetchurl { + url = "https://curl.se/download/curl-7.87.0.tar.bz2"; + sha256 = "sha256-XW4Sh2G3EQlG0Sdq/28PJm8rcm9eYZ9+CgV6R0FV8wc="; + }; + buildInputs = [ pkgs.zlib pkgs.openssl.dev ]; + configureFlags = [ "--with-zlib=${pkgs.zlib}" "--with-openssl=${pkgs.openssl.dev}" ]; + }) + + ncurses + ] ++ [ + pkgs-glibc.glibc + ]; + + shellHook = '' + # FIXME: this need to go in a build task + gradle linuxX64DistZip + ''; + }; + } + ); +} From 2381be5a8d78f3f0f6a006ee6b24f5bd16c79973 Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Mon, 25 Mar 2024 23:26:20 +0100 Subject: [PATCH 2/2] docs: adds info about nix builds Signed-off-by: Vincenzo Palazzo --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 86831eb7..0107ff6b 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ Requires `libsqlite-dev` and `libcurl4-gnutls-dev`, both compiled against `glibc ./gradlew linuxX64DistZip ``` +If you are on a system with a different glibc, try to use nix and build phoenixd inside the shell that you can create with the command `nix-shell .nix/shell.nix`. + ### Native MacOS x64 ```shell ./gradlew macosX64DistZip @@ -31,4 +33,4 @@ Requires `libsqlite-dev` and `libcurl4-gnutls-dev`, both compiled against `glibc ### JVM ```shell ./gradlew distZip -``` \ No newline at end of file +```