about summary refs log tree commit diff
path: root/pkgs/by-name/fe/fedimint/package.nix
blob: 7fa50da3620b274df9d5b5b6da0759e3f0b613f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{ lib
, buildPackages
, clang
, fetchFromGitHub
, libclang
, libiconv
, llvmPackages_12
, openssl
, pkg-config
, protobuf
, rustPlatform
, stdenv
, Security
, SystemConfiguration
}:
let
  # Rust rocksdb bindings have C++ compilation/linking errors on Darwin when using newer clang
  # Forcing it to clang 12 fixes the issue.
  buildRustPackage =
    if stdenv.isDarwin then
      rustPlatform.buildRustPackage.override { stdenv = llvmPackages_12.stdenv; }
    else
      rustPlatform.buildRustPackage;
in
buildRustPackage rec {
  pname = "fedimint";
  version = "0.3.2";

  src = fetchFromGitHub {
    owner = "fedimint";
    repo = "fedimint";
    rev = "v${version}";
    hash = "sha256-FEzlNLo6X4zZQM3KEsf6wwJm4Uw6/8HJNZiM4jK2x2k=";
  };

  cargoHash = "sha256-lILETtCaPDAWgObNwHIfO/w6pqs0PkbqpDbjODRDOzw=";

  nativeBuildInputs = [
    protobuf
    pkg-config
    clang
    libclang.lib
  ];

  buildInputs = [
    openssl
  ] ++ lib.optionals stdenv.isDarwin [
    Security
    libiconv
    Security
    SystemConfiguration
  ];

  outputs = [ "out" "fedimintCli" "fedimint" "gateway" "gatewayCli" "devimint" ];

  postInstall = ''
    mkdir -p $fedimint/bin $fedimintCli/bin $gateway/bin $gatewayCli/bin $devimint/bin

    # delete fuzzing targets and other binaries no one cares about
    binsToKeep=(fedimint-cli fedimint-dbtool recoverytool fedimintd gatewayd gateway-cli gateway-cln-extension devimint)
    keepPattern=$(printf "|%s" "''${binsToKeep[@]}")
    keepPattern=''${keepPattern:1}
    find "$out/bin" -maxdepth 1 -type f | grep -Ev "(''${keepPattern})" | xargs rm -f

    # fix the upstream name
    mv $out/bin/recoverytool $out/bin/fedimint-recoverytool


    cp -a $releaseDir/fedimint-cli  $fedimintCli/bin/
    cp -a $releaseDir/fedimint-dbtool  $fedimintCli/bin/
    cp -a $releaseDir/recoverytool  $fedimintCli/bin/fedimint-recoverytool

    cp -a $releaseDir/fedimintd  $fedimint/bin/

    cp -a $releaseDir/gateway-cli $gatewayCli/bin/

    cp -a $releaseDir/gatewayd $gateway/bin/
    cp -a $releaseDir/gateway-cln-extension $gateway/bin/

    cp -a $releaseDir/devimint $devimint/bin/
  '';

  PROTOC = "${buildPackages.protobuf}/bin/protoc";
  PROTOC_INCLUDE = "${protobuf}/include";
  OPENSSL_DIR = openssl.dev;
  LIBCLANG_PATH = "${libclang.lib}/lib";

  FEDIMINT_BUILD_FORCE_GIT_HASH = "0000000000000000000000000000000000000000";

  # currently broken, will require some upstream fixes
  doCheck = false;

  meta = {
    description = "Federated E-Cash Mint";
    homepage = "https://github.com/fedimint/fedimint";
    license = [ lib.licenses.mit ];
    maintainers = with lib.maintainers; [ dpc ];
    mainProgram = "fedimint-cli";
  };
}