Skip to content

Commit

Permalink
feat(distribution): add Nix Flake based duckdb shared library + jar o…
Browse files Browse the repository at this point in the history
…utput (#15)

* Add Nix Flake based duckdb shared library + jar output

* Update README.md to integrate into upstream
  • Loading branch information
thenonameguy authored Feb 13, 2024
1 parent 64bc1d2 commit 6dcd76a
Show file tree
Hide file tree
Showing 9 changed files with 3,162 additions and 5 deletions.
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

0 comments on commit 6dcd76a

Please sign in to comment.