From 535b174a56390f75d1cb48b1ea88f829d8e96898 Mon Sep 17 00:00:00 2001 From: Oliver Rice Date: Fri, 3 Jan 2025 11:38:07 -0600 Subject: [PATCH 1/3] add pg_mooncake --- flake.nix | 1 + nix/ext/pg_mooncake.nix | 74 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 nix/ext/pg_mooncake.nix diff --git a/flake.nix b/flake.nix index 0ef79e1d0..c8c42a742 100644 --- a/flake.nix +++ b/flake.nix @@ -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 diff --git a/nix/ext/pg_mooncake.nix b/nix/ext/pg_mooncake.nix new file mode 100644 index 000000000..e244babd3 --- /dev/null +++ b/nix/ext/pg_mooncake.nix @@ -0,0 +1,74 @@ +{ + lib, + stdenv, + fetchFromGitHub, + postgresql, + cmake, + openssl, + curl, + pkg-config, + cargo, + rustc, + cacert, +}: + +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; + }; +} From 87a13c6a0403590ed8bc9a4bcd210fc538961edc Mon Sep 17 00:00:00 2001 From: Oliver Rice Date: Fri, 3 Jan 2025 11:55:43 -0600 Subject: [PATCH 2/3] bump rust to 1.80.0 --- nix/ext/pg_mooncake.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nix/ext/pg_mooncake.nix b/nix/ext/pg_mooncake.nix index e244babd3..2690d9add 100644 --- a/nix/ext/pg_mooncake.nix +++ b/nix/ext/pg_mooncake.nix @@ -7,11 +7,15 @@ openssl, curl, pkg-config, - cargo, - rustc, cacert, + rust-bin, }: +let + rustVersion = "1.80.0"; + rustc = rust-bin.stable."${rustVersion}".rustc; + cargo = rust-bin.stable."${rustVersion}".cargo; +in stdenv.mkDerivation rec { pname = "pg_mooncake"; version = "61a2c495ba8e8bbcf59142f05dc85a3059bdf42c"; From 32093ffd93eebfaa8fad19ce479f458e48c243b7 Mon Sep 17 00:00:00 2001 From: Oliver Rice Date: Fri, 3 Jan 2025 13:10:25 -0600 Subject: [PATCH 3/3] bump rust to 1.81 and set targets --- nix/ext/pg_mooncake.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/nix/ext/pg_mooncake.nix b/nix/ext/pg_mooncake.nix index 2690d9add..f6b1347de 100644 --- a/nix/ext/pg_mooncake.nix +++ b/nix/ext/pg_mooncake.nix @@ -12,9 +12,19 @@ }: let - rustVersion = "1.80.0"; - rustc = rust-bin.stable."${rustVersion}".rustc; - cargo = rust-bin.stable."${rustVersion}".cargo; + 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";