summary refs log tree commit diff
path: root/pkgs/applications/blockchains/wasabibackend/default.nix
blob: 43deb6f3c6cd9b99a64caeb495bb8ee30506a2f0 (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, stdenv
, fetchFromGitHub
, fetchurl
, makeWrapper
, Nuget
, dotnetCorePackages
, openssl
, zlib
}:

let
  deps = import ./deps.nix { inherit fetchurl; };

  dotnet-sdk = dotnetCorePackages.sdk_3_1;
  dotnet-aspnetcore = dotnetCorePackages.aspnetcore_3_1;

  nugetSource = stdenv.mkDerivation {
    pname = "${pname}-nuget-deps";
    inherit version;

    dontUnpack = true;
    dontInstall = true;

    nativeBuildInputs = [ Nuget ];

    buildPhase = ''
      export HOME=$(mktemp -d)
      mkdir -p $out/lib

      nuget sources Disable -Name "nuget.org"
      for package in ${toString deps}; do
        nuget add $package -Source $out/lib
      done
    '';
  };

  pname = "WasabiBackend";
  version = "1.1.12";

  projectName = "WalletWasabi.Backend";
  projectConfiguration = "Release";
  projectRuntime = "linux-x64";
in

stdenv.mkDerivation rec {
  inherit pname version;

  src = fetchFromGitHub {
    owner = "zkSNACKs";
    repo = "WalletWasabi";
    rev = "v${version}";
    sha256 = "001k43z2jxvs03csyzndlzlk034aclzc4n8ddrqxykgrq508xk1d";
  };

  buildInputs = [
    Nuget
    dotnet-sdk
    makeWrapper
  ];

  buildPhase = ''
    export HOME=$(mktemp -d)
    export DOTNET_CLI_TELEMETRY_OPTOUT=1
    export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
    export DOTNET_ROOT="${dotnet-sdk}/bin"

    nuget sources Disable -Name "nuget.org"

    dotnet restore \
      --source ${nugetSource}/lib \
      --runtime ${projectRuntime} \
      ${projectName}

    dotnet publish \
      --no-restore \
      --runtime ${projectRuntime} \
      --configuration ${projectConfiguration} \
      ${projectName}
  '';

  installPhase = ''
    mkdir -p $out
    cp -r ${projectName}/bin/${projectConfiguration}/netcoreapp3.1/${projectRuntime}/publish $out/lib
    mkdir -p $out/bin
    makeWrapper $out/lib/WalletWasabi.Backend $out/bin/${pname} \
      --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ openssl zlib ]} \
      --run "cd $out/lib"
  '';

  # If we don't disable stripping the executable fails to start with segfault
  dontStrip = true;

  meta = with lib; {
    description = "Backend for the Wasabi Wallet";
    homepage = "https://wasabiwallet.io/";
    license = licenses.mit;
    maintainers = with maintainers; [ mmahut ];
    platforms = [ "x86_64-linux" ];
  };
}