summary refs log tree commit diff
path: root/pkgs/servers/nosql/eventstore/default.nix
blob: d1f4938197ca4bafa0f86015e478cca017592c4c (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
{ stdenv
, fetchFromGitHub
, fetchurl
, makeWrapper
, dotnet-sdk
, mono
, Nuget
}:

let

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

in

stdenv.mkDerivation rec {

  pname = "EventStore";
  version = "5.0.7";

  src = fetchFromGitHub {
    owner = "EventStore";
    repo = "EventStore";
    rev = "oss-v${version}";
    sha256 = "0yvprql73g4lc88b6kp1kk8h64az2hn4am5hc4gyiaxfavaww3ci";
  };

  buildInputs = [
    makeWrapper
    dotnet-sdk
    mono
    Nuget
  ];

  # that dependency seems to not be required for building, but pulls in libcurl which fails to be located.
  # see: https://github.com/EventStore/EventStore/issues/1897
  patchPhase = ''
    for f in $(find . -iname "*.csproj"); do
      sed -i '/Include="Microsoft.SourceLink.GitHub"/d' $f
    done
  '';

  buildPhase = ''
    mkdir home
    export HOME=$PWD/home
    export DOTNET_CLI_TELEMETRY_OPTOUT=1
    export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
    export FrameworkPathOverride=${mono}/lib/mono/4.7.1-api

    # disable default-source so nuget does not try to download from online-repo
    nuget sources Disable -Name "nuget.org"
    # add all dependencies to a source called 'nixos'
    for package in ${toString deps}; do
      nuget add $package -Source nixos
    done

    dotnet restore --source nixos src/EventStore.sln
    dotnet build --no-restore -c Release src/EventStore.sln
  '';

  installPhase = ''
    mkdir -p $out/{bin,lib/eventstore}
    cp -r bin/Release/* $out/lib/eventstore
    makeWrapper "${mono}/bin/mono" $out/bin/eventstored \
      --add-flags "$out/lib/eventstore/EventStore.ClusterNode/net471/EventStore.ClusterNode.exe"
  '';

  doCheck = true;

  checkPhase = ''
    dotnet test src/EventStore.Projections.Core.Tests/EventStore.Projections.Core.Tests.csproj -- RunConfiguration.TargetPlatform=x64
  '';

  meta = {
    homepage = "https://geteventstore.com/";
    description = "Event sourcing database with processing logic in JavaScript";
    license = stdenv.lib.licenses.bsd3;
    maintainers = with stdenv.lib.maintainers; [ puffnfresh ];
    platforms = [ "x86_64-linux" ];
  };

}