summaryrefslogtreecommitdiff
path: root/pkgs/socialpredict/default.nix
blob: 22dc6a99cae2dadd614248e47c5130212ac17ea9 (plain)
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
{
  buildGoModule,
  buildNpmPackage,
  fetchFromGitHub,
  lib,
}: let
  version = "2.1.0";

  src = fetchFromGitHub {
    owner = "openpredictionmarkets";
    repo = "socialpredict";
    tag = "v${version}";
    hash = "sha256-aV6Z7vsqV8zxyB+v7hSyOm/jzGqR8YnhG+xLKSC9Qoo=";
  };

  meta = {
    description = "Easy to Deploy Prediction Market Platform ";
    homepage = "https://github.com/openpredictionmarkets/socialpredict";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; []; # [ _3442 ];
  };
in {
  backend = buildGoModule {
    pname = "socialpredict-backend";
    inherit src version;

    patches = [
      ./0001-Support-POSTGRES_URL-for-overriding-the-PG-DSN.patch
    ];

    sourceRoot = "source/backend";
    vendorHash = "sha256-ah2d+gHe7HULEsqMSUwGOL4D00aY0QtZvcD3pTQp/Q0=";

    meta = meta // {mainProgram = "socialpredict";};
  };

  frontend = buildNpmPackage {
    pname = "socialpredict-frontend";
    inherit src meta version;

    sourceRoot = "source/frontend";
    npmDepsHash = "sha256-zn1yPtvi8DaKESMGAtqnh/66xET+QaCa1TUlpbatI70=";

    patches = [
      ./0002-Fix-API_URL-api-v0-.-API_URL-v0.patch
    ];

    buildPhase = ''
      runHook preBuild

      node --max_old_space_size=1024000 ./node_modules/vite/bin/vite.js build

      runHook postBuild
    '';

    installPhase = ''
      runHook preInstall

      mkdir -p $out
      cp -r build/* $out
      rm $out/env-config.js.template

      runHook postInstall
    '';
  };
}