Skip to content

Commit cde86ac

Browse files
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] #1 (comment) Co-authored-by: Pavol Rusnak <[email protected]> Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent 3072963 commit cde86ac

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

flake.nix

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
description = "Server equivalent of the popular Phoenix wallet";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils, ... }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = import nixpkgs {
13+
inherit system;
14+
overlays = [ ];
15+
};
16+
17+
# Importing glibc 2.19 for compiling the recent version of curl
18+
pkgs-glibc = import
19+
(builtins.fetchTarball {
20+
url = "https://github.com/NixOS/nixpkgs/archive/b6f505c60a2417d4fad4dc5245754e4e33eb4d40.tar.gz";
21+
sha256 = "sha256:0hhb8sar8qxi179d6c5h6n8f7nm71xxqqbynjv8pldvpsmsxxzh9";
22+
})
23+
{ inherit system; };
24+
in
25+
{
26+
packages = {
27+
default = pkgs.gnumake;
28+
};
29+
formatter = pkgs.nixpkgs-fmt;
30+
31+
devShell = pkgs.mkShellNoCC {
32+
buildInputs = with pkgs; [
33+
# build dependencies
34+
git
35+
pkg-config
36+
zlib
37+
wget
38+
39+
sqlite
40+
jdk
41+
gradle
42+
kotlin
43+
44+
# Ok this should help you lean a few things
45+
# See https://github.com/ACINQ/phoenixd/issues/1#issuecomment-2018205685
46+
(pkgs.stdenv.mkDerivation {
47+
name = "curl-7.87.0";
48+
src = pkgs.fetchurl {
49+
url = "https://curl.se/download/curl-7.87.0.tar.bz2";
50+
sha256 = "sha256-XW4Sh2G3EQlG0Sdq/28PJm8rcm9eYZ9+CgV6R0FV8wc=";
51+
};
52+
buildInputs = [ pkgs.zlib pkgs.openssl.dev ];
53+
configureFlags = [ "--with-zlib=${pkgs.zlib}" "--with-openssl=${pkgs.openssl.dev}" ];
54+
})
55+
56+
ncurses
57+
] ++ [
58+
pkgs-glibc.glibc
59+
];
60+
61+
shellHook = ''
62+
# FIXME: this need to go in a build task
63+
gradle linuxX64DistZip
64+
'';
65+
};
66+
}
67+
);
68+
}

0 commit comments

Comments
 (0)