Hey,
I’m trying to use DuckDB inside elixir and the recommended way by Jose seems to be through adbc.
I followed this blog post about elixir/iceberg/duckdb and found that the the typical way to install it is to run:
# Change URL for your architecture: https://github.com/duckdb/duckdb/releases/tag/v1.4.0
Adbc.download_driver!(:duckdb, version: "1.4.0", url: "https://github.com/duckdb/duckdb/releases/download/v1.4.0/libduckdb-linux-arm64.zip", force: true)
This is of course problematic to do in the production with read only nix store.
I would mainly need the shared library libduckdb.so from the zip file:
$ curl https://github.com/duckdb/duckdb/releases/download/v1.4.2/libduckdb-linux-arm64.zip -O
$ unzip -l libduckdb-linux-amd64.zip
Archive: libduckdb-linux-amd64.zip
Length Date Time Name
--------- ---------- ----- ----
64805880 11-11-2025 13:38 libduckdb.so
70935094 11-11-2025 13:38 libduckdb_static.a
1875021 11-11-2025 13:39 duckdb.hpp
190571 11-11-2025 13:13 duckdb.h
--------- -------
137806566 4 files
I’m now wondering if this is already built in the duckdb nix package or some other duckdb lib?
Is there a way for me to search with filenames from nix packages?
What would be the best course of action to include this in my project?
Claude Code currently helped me to do this and it does seem way too complex for me:
{
mixRelease,
fetchMixDeps,
elixir,
writeScript,
pkgs,
lib,
beamPackages,
stdenv,
}:
let
# DuckDB version - defined once and used everywhere
duckdbVersion = "1.4.2";
# Fetch DuckDB library with ADBC support built-in
duckdbLib = pkgs.fetchzip {
url = "https://github.com/duckdb/duckdb/releases/download/v${duckdbVersion}/libduckdb-linux-amd64.zip";
sha256 = "sha256-W1YOf4zBQkkLxEGWyWg2dXJhWSzRrm+MWau9bvvMSQA=";
stripRoot = false;
};
in
mixRelease rec {
...
postInstall = ''
...
# Create drivers directory for pre-installed DuckDB library
DRIVERS_DIR="$ADBC_LIB_DIR/priv/drivers"
mkdir -p "$DRIVERS_DIR"
# Copy libduckdb.so from fetched DuckDB release
echo "Installing DuckDB library v${duckdbVersion} from ${duckdbLib}"
cp "${duckdbLib}/libduckdb.so" "$DRIVERS_DIR/libduckdb.so"
chmod +w "$DRIVERS_DIR/libduckdb.so"
# Patch RPATH to include Nix store paths for dependencies
# DuckDB needs libstdc++, libgcc_s, and libz
${pkgs.patchelf}/bin/patchelf --set-rpath "${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.zlib}/lib" "$DRIVERS_DIR/libduckdb.so"
echo "Installed and patched DuckDB library at $DRIVERS_DIR/libduckdb.so"
echo "DuckDB library RPATH: $(${pkgs.patchelf}/bin/patchelf --print-rpath "$DRIVERS_DIR/libduckdb.so")"
'';
...