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

feat(distribution): add Nix Flake based duckdb shared library + jar output #15

Merged
merged 2 commits into from
Feb 13, 2024
Merged
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
5 changes: 5 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.5.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.5.1/direnvrc" "sha256-5XwUul/GUzj52MC5LvjHaZXDW2iLnl93tEQSYm9f3Rc="
fi

use flake
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@ classes
pom.xml
*.asc

data.csv
data.csv

.direnv

# symlinked in by the Nix flake
lib

# `nix build` result
result
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,26 @@ user in data form there is no advantage to using apache arrow as a query result.

## Usage

### Preferred method (Nix)

You can get a jar for your own OS (Linux/MacOS) with duckdb included by [installing Nix](https://github.com/DeterminateSystems/nix-installer),
then running:

``` console
$ nix build github:techascent/tmducken

$ uname -s -p
Darwin arm

$ jar tf result/tmducken.jar | grep libduckdb.dylib
darwin-aarch64/libduckdb.dylib
```

You can include this in your deps.edn via: `{:local/root "result/tmducken.jar"}`
With this method, you can invoke `(duckdb/initialize!)` normally and it will load the shared library automatically.

### Manual method

First, download binaries and set either install then into your
system path or set the DUCKDB_HOME environment variable to where
the shared library is installed - see [enable-duckdb](scripts/enable-duckdb)
Expand All @@ -110,6 +130,14 @@ Next, you should be able to call [initialize!](https://techascent.github.io/tmdu
in the duckdb namespace. Be sure to read the [namespace documentation](https://techascent.github.io/tmducken/tmducken.duckdb.html)
and perhaps peruse the [unit tests](test/tmducken/duckdb_test.clj).

## Developing

Whenever the `deps.edn` file changes, you have to run `deps-lock`, as provided by the `nix shell`.
For more details see: https://jlesquembre.github.io/clj-nix/lock-file/

Not doing so fails local Nix builds (`nix build`) by trying to fetch dependencies in a non-network build environment.

Alternative CI-based solution to the above: https://jlesquembre.github.io/clj-nix/github-action/

## License

Expand Down
2 changes: 1 addition & 1 deletion build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
:version version
:basis basis
:src-dirs ["src"]})
(b/copy-dir {:src-dirs ["src" "resources"]
(b/copy-dir {:src-dirs ["src" "resources" "lib"]
:target-dir class-dir})
(b/jar {:class-dir class-dir
:jar-file jar-file}))
Loading