Using @db/sqlite on Deno with Nix

I’ve been exploring some of the newer web frameworks in the JavaScript ecosystem. To measure how productive I am from the get-go with each one, I reproduce part of the features contained on this blog.

However, I don't like setting up a PostgreSQL instance for small experiments1. SQLite is the tool for this job and Deno has a pretty good library called @db/sqlite that uses Deno's FFI.

The trick to have it working with Nix is to setting the DENO_SQLITE_PATH to the SQLite shared library.

# using mkShell
export DENO_SQLITE_PATH="${lib.makeLibraryPath [ pkgs.sqlite ]}/libsqlite3${pkgs.stdenv.hostPlatform.extensions.sharedLibrary}"

# using devenv
env.DENO_SQLITE_PATH = "${lib.makeLibraryPath [ pkgs.sqlite ]}/libsqlite3${pkgs.stdenv.hostPlatform.extensions.sharedLibrary}";
  1. I'm even consider migrating the production website to SQLite.