diff options
Diffstat (limited to 'pkgs/socialpredict')
3 files changed, 143 insertions, 0 deletions
diff --git a/pkgs/socialpredict/0001-Support-POSTGRES_URL-for-overriding-the-PG-DSN.patch b/pkgs/socialpredict/0001-Support-POSTGRES_URL-for-overriding-the-PG-DSN.patch new file mode 100644 index 0000000..69dc660 --- /dev/null +++ b/pkgs/socialpredict/0001-Support-POSTGRES_URL-for-overriding-the-PG-DSN.patch @@ -0,0 +1,30 @@ +From 67cf25f7cb397d37d807797b6013447b19c8f73b Mon Sep 17 00:00:00 2001 +From: Alejandro Soto <alejandro@34project.org> +Date: Thu, 29 Jan 2026 23:21:21 -0600 +Subject: [PATCH] Support POSTGRES_URL for overriding the PG DSN + +--- + backend/util/postgres.go | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/util/postgres.go b/util/postgres.go +index ac69932..030f516 100644 +--- a/util/postgres.go ++++ b/util/postgres.go +@@ -49,8 +49,11 @@ func InitDB() { + dbPort = "5432" + } + +- dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable TimeZone=UTC", +- dbHost, dbUser, dbPassword, dbName, dbPort) ++ dsn := os.Getenv("POSTGRES_URL") ++ if dsn == "" { ++ dsn = fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable TimeZone=UTC", ++ dbHost, dbUser, dbPassword, dbName, dbPort) ++ } + + DB, err = gorm.Open(postgres.Open(dsn), &gorm.Config{}) + if err != nil { +-- +2.51.2 + diff --git a/pkgs/socialpredict/0002-Fix-API_URL-api-v0-.-API_URL-v0.patch b/pkgs/socialpredict/0002-Fix-API_URL-api-v0-.-API_URL-v0.patch new file mode 100644 index 0000000..09b0d70 --- /dev/null +++ b/pkgs/socialpredict/0002-Fix-API_URL-api-v0-.-API_URL-v0.patch @@ -0,0 +1,47 @@ +From 9ce9d4d3bdbd12dfb3dda98f3d4f72d3bbe724b7 Mon Sep 17 00:00:00 2001 +From: Alejandro Soto <alejandro@34project.org> +Date: Sat, 31 Jan 2026 13:04:28 -0600 +Subject: [PATCH 2/2] Fix ${API_URL}/api/v0/... -> ${API_URL}/v0/... + +--- + src/hooks/usePortfolio.jsx | 2 +- + src/hooks/useUserData.jsx | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/hooks/usePortfolio.jsx b/src/hooks/usePortfolio.jsx +index 0f0774b..a233ea3 100644 +--- a/src/hooks/usePortfolio.jsx ++++ b/src/hooks/usePortfolio.jsx +@@ -17,7 +17,7 @@ const usePortfolio = (username) => { + headers['Content-Type'] = 'application/json'; + } + +- const response = await fetch(`${API_URL}/api/v0/portfolio/${username}`, { headers }); ++ const response = await fetch(`${API_URL}/v0/portfolio/${username}`, { headers }); + if (!response.ok) { + throw new Error('Failed to fetch portfolio'); + } +diff --git a/src/hooks/useUserData.jsx b/src/hooks/useUserData.jsx +index 593594f..960c5aa 100644 +--- a/src/hooks/useUserData.jsx ++++ b/src/hooks/useUserData.jsx +@@ -15,14 +15,14 @@ const useUserData = (username, usePrivateProfile = false) => { + + if (usePrivateProfile) { + // Use private profile endpoint for authenticated user's own profile +- url = `${API_URL}/api/v0/privateprofile`; ++ url = `${API_URL}/v0/privateprofile`; + headers = { + 'Authorization': `Bearer ${token}`, + 'Content-Type': 'application/json' + }; + } else { + // Use public user endpoint for viewing other users' profiles +- url = `${API_URL}/api/v0/userinfo/${username}`; ++ url = `${API_URL}/v0/userinfo/${username}`; + if (token) { + headers = { + 'Authorization': `Bearer ${token}`, +-- +2.51.2 + diff --git a/pkgs/socialpredict/default.nix b/pkgs/socialpredict/default.nix new file mode 100644 index 0000000..22dc6a9 --- /dev/null +++ b/pkgs/socialpredict/default.nix @@ -0,0 +1,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 + ''; + }; +} |
