Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pg_mooncake test #1394

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
./nix/ext/pg_hashids.nix
./nix/ext/pgsodium.nix
./nix/ext/pg_graphql.nix
./nix/ext/pg_mooncake.nix
./nix/ext/pg_stat_monitor.nix
./nix/ext/pg_jsonschema.nix
./nix/ext/pgvector.nix
Expand Down
88 changes: 88 additions & 0 deletions nix/ext/pg_mooncake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
lib,
stdenv,
fetchFromGitHub,
postgresql,
cmake,
openssl,
curl,
pkg-config,
cacert,
rust-bin,
}:

let
rustVersion = "1.81.0";
targets = [
"aarch64-apple-darwin"
"x86_64-apple-darwin"
"x86_64-unknown-linux-gnu"
"aarch64-unknown-linux-gnu"
];
rustc = rust-bin.stable."${rustVersion}".default.override {
inherit targets;
};
cargo = rust-bin.stable."${rustVersion}".default.override {
inherit targets;
};
in
stdenv.mkDerivation rec {
pname = "pg_mooncake";
version = "61a2c495ba8e8bbcf59142f05dc85a3059bdf42c";

src = fetchFromGitHub {
owner = "olirice";
repo = pname;
rev = version;
hash = "sha256-zyQ0LREOSIF+25NODoZb8fTVH0sYEVu5YUqsJigWEb8=";
fetchSubmodules = true;
};

# Tools needed for building:
nativeBuildInputs = [
cargo
rustc
cmake
pkg-config
];

buildInputs = [
postgresql
openssl
curl
cacert
];

# Skip the default configure phase because there's no top-level CMakeLists.txt.
dontConfigure = true;

# Use "make release -j" with Nix's parallel build cores:
buildPhase = ''
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt

# Make sure these env vars are set in the same shell invocation:
export HOME=$PWD/home
export CARGO_HOME=$HOME/cargo
mkdir -p "$CARGO_HOME"

# Pass HOME and CARGO_HOME explicitly to `make`, in case the upstream
# Makefile does something like `HOME ?= /homeless-shelter`.
HOME="$HOME" \
CARGO_HOME="$CARGO_HOME" \
make release -j$NIX_BUILD_CORES PG_CONFIG="${postgresql}/bin/pg_config"
'';

installPhase = ''
mkdir -p $out/{lib,share/postgresql/extension}

cp *${postgresql.dlSuffix} $out/lib
cp *.sql $out/share/postgresql/extension
'';

meta = with lib; {
description = "Mooncake: user-defined pipeline analytics in Postgres";
homepage = "https://github.com/Mooncake-Labs/${pname}";
platforms = postgresql.meta.platforms;
license = licenses.postgresql;
};
}
Loading