From ee6650a5522f4a49ce9924ac62a84b0ee55f47ed Mon Sep 17 00:00:00 2001 From: Sergey Konotopov Date: Sat, 16 May 2026 03:26:25 +0100 Subject: [PATCH 1/2] maintainers: add skonotopov --- maintainers/maintainer-list.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 8d804af54824..dfd89098c555 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -25575,6 +25575,11 @@ github = "skohtv"; githubId = 101289702; }; + skonotopov = { + name = "Sergey Konotopov"; + github = "kinkou"; + githubId = 931329; + }; skovati = { github = "skovati"; githubId = 49844593; From 56614748bef9bd9585acb333349ad783c354d1fe Mon Sep 17 00:00:00 2001 From: Sergey Konotopov Date: Sat, 16 May 2026 03:34:23 +0100 Subject: [PATCH 2/2] postgresqlPackages.pg_duckdb: init at 1.1.1 --- pkgs/servers/sql/postgresql/ext/pg_duckdb.nix | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 pkgs/servers/sql/postgresql/ext/pg_duckdb.nix diff --git a/pkgs/servers/sql/postgresql/ext/pg_duckdb.nix b/pkgs/servers/sql/postgresql/ext/pg_duckdb.nix new file mode 100644 index 000000000000..c761d5a1cab3 --- /dev/null +++ b/pkgs/servers/sql/postgresql/ext/pg_duckdb.nix @@ -0,0 +1,126 @@ +{ + lib, + fetchFromGitHub, + writeText, + + postgresqlBuildExtension, + postgresqlTestExtension, + postgresql, + + openssl, + curl, + + cmake, + ninja, + pkg-config, + python3, + git, + which, +}: + +postgresqlBuildExtension (finalAttrs: { + pname = "pg_duckdb"; + version = "1.1.1"; + + # duckdbVersionFull is used to set OVERRIDE_GIT_DESCRIBE, which effectively suppresses + # build script attempts to use git to figure it out. + # To get the version first run `git submodule update --init --recursive` inside pg_duckdb/, + # then run `git describe --tags --long --match "v*.*.*"` inside pg_duckdb/third_party/duckdb + duckdbVersion = "1.4.3"; + duckdbVersionFull = "${finalAttrs.duckdbVersion}-0-gd1dc88f950"; + + src = fetchFromGitHub { + owner = "duckdb"; + repo = "pg_duckdb"; + tag = "v${finalAttrs.version}"; + fetchSubmodules = true; + hash = "sha256-B/9U1j29zqNMNgK2t2MFJemCrLgQo1qRrCacSjPzYdg="; + }; + + nativeBuildInputs = [ + cmake + ninja + pkg-config + python3 + git + which + ]; + + # Avoid build errors by suppressing these hooks. + # Extension build scripts drive cmake and ninja themselves. + dontUseCmakeConfigure = true; + dontUseNinjaBuild = true; + dontUseNinjaInstall = true; + dontUseNinjaCheck = true; + + # curl is required by httpfs (duckdb-httpfs/vcpkg.json), but not included in postgresql.buildInputs + buildInputs = postgresql.buildInputs ++ [ + openssl + curl + ]; + + # 1. Disable calling `git submodule update --init --recursive` from Makefile: + # submodules are already in place thanks to fetchFromGitHub's fetchSubmodules option. + # 2. duckdb-httpfs prefers to use vcpkg to build its dependencies (see + # duckdb-httpfs/README.md), but this derivation won't run vcpkg, so the + # libraries are linked dynamically. But because the -lssl and -lcrypto flags + # are missing, libssl/libcrypto symbols can't be resolved during the link time. + postPatch = '' + substituteInPlace Makefile \ + --replace-fail \ + 'git submodule update --init --recursive' \ + 'true' + + substituteInPlace Makefile \ + --replace-fail \ + 'PG_DUCKDB_LINK_FLAGS += -Wl,-rpath,$(PG_LIB)/ -L$(DUCKDB_BUILD_DIR)/src -L$(PG_LIB) -lstdc++ -llz4' \ + 'PG_DUCKDB_LINK_FLAGS += -Wl,-rpath,$(PG_LIB)/ -L$(DUCKDB_BUILD_DIR)/src -L$(PG_LIB) -lstdc++ -llz4 -lssl -lcrypto' + ''; + + # Download httpfs extension source code and override pg_duckdb's attempt to + # get it using git in pg_duckdb_extensions.cmake by using EXTENSION_CONFIGS + httpfsSrc = fetchFromGitHub { + owner = "duckdb"; + repo = "duckdb-httpfs"; + rev = "9c7d34977b10346d0b4cbbde5df807d1dab0b2bf"; + fetchSubmodules = true; + hash = "sha256-/gR99nrks2nRmfk1ypZCSAKpok1DGizXgNz0u5Bw3Jk="; + }; + + makeFlags = + let + httpfsCmake = writeText "pg_duckdb_httpfs.cmake" '' + duckdb_extension_load(httpfs + SOURCE_DIR ${finalAttrs.httpfsSrc} + EXTENSION_VERSION v${finalAttrs.duckdbVersion} + ) + ''; + in + [ + "GEN=ninja" + "DUCKDB_BUILD=ReleaseStatic" + "PG_CONFIG=${postgresql.pg_config}/bin/pg_config" + "DUCKDB_VERSION=v${finalAttrs.duckdbVersionFull}" + "EXTENSION_CONFIGS=${httpfsCmake};../pg_duckdb_extensions.cmake" + ]; + + passthru.tests.extension = postgresqlTestExtension { + inherit (finalAttrs) finalPackage; + postgresqlExtraSettings = '' + shared_preload_libraries = 'pg_duckdb' + ''; + sql = '' + CREATE EXTENSION pg_duckdb; + SELECT duckdb.raw_query('SELECT 42'); + ''; + }; + + meta = { + description = "DuckDB-powered Postgres extension for high-performance analytics"; + homepage = "https://github.com/duckdb/pg_duckdb"; + changelog = "https://github.com/duckdb/pg_duckdb/releases/tag/v${finalAttrs.version}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ skonotopov ]; + platforms = lib.platforms.linux ++ lib.platforms.darwin; + }; +})