Lumosql

Documentation
Login

Documentation

Building LumoSQL on NixOS

LumoSQL builds on NixOS and passes all LumoSQL tests without any patches.

What NixOS does need is configuration, because NixOS installs software without putting it where tools that expect /usr will look. We provide:

The configuration

{ modulesPath, config, pkgs, lib, ... }:
...
  environment.sessionVariables = {
    PKG_CONFIG_PATH = lib.concatStringsSep ":" [
      "/run/current-system/sw/lib/pkgconfig"
      "${pkgs.zlib.dev}/share/pkgconfig"
    ];
    PERL5LIB = lib.concatStringsSep ":" [
      "${pkgs.git}/lib/perl5/site_perl/${pkgs.perl.version}"
      "${pkgs.perlPackages.TextGlob}/lib/perl5/site_perl/${pkgs.perl.version}"
    ];
  };
  environment.systemPackages = with pkgs; [
    gcc gnumake tcl tclPackages.tclx perl perlPackages.TextGlob
    zlib.dev readline.dev ncurses.dev libsodium.dev
    zlib readline ncurses libsodium pkg-config git
    # examples/fossil links against OpenSSL and runs its own configure, which
    # looks for headers where pkg-config would have answered.
    openssl.dev openssl
    # examples/node-better-sqlite3 drives node-gyp.
    nodejs python3
  ];

Shells that bypass PAM

incus exec, cron jobs and systemd units start without environment.sessionVariables, so PERL5LIB and PKG_CONFIG_PATH are empty and make doctor fails on a correctly configured system. Source the file NixOS generates:

. /etc/set-environment

Two more, for a container

The Incus NixOS image ships with an empty NIX_PATH, so nixos-rebuild fails with file 'nixpkgs/nixos' was not found in the Nix search path while the channel is registered and on disk:

export NIX_PATH="nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix"

Nix's build sandbox needs kernel namespaces an unprivileged container lacks, so every nixos-rebuild and nix-channel --update needs --option sandbox false. Setting nix.settings.sandbox = false; in configuration.nix is unreachable until the first rebuild succeeds, and /etc/nix/nix.conf is managed and mounted read-only, so the command-line override is the way in.

The Fossil example

Fossil's configure takes one directory per dependency: --with-zlib=DIR and --with-openssl=DIR each expect DIR/include and DIR/lib. nixpkgs has those two halves in different store paths, so no such directory exists and configure reports Error: zlib.h not found, then Error: OpenSSL not found.

A directory of symlinks per dependency emulates the expected filesystem:

mkdir -p /root/nixos-openssl
ln -s /nix/store/...-openssl-3.6.3-dev/include /root/nixos-openssl/include
ln -s /nix/store/...-openssl-3.6.3/lib         /root/nixos-openssl/lib

examples/fossil/tools/nixos-fossil.sh builds both directories and invokes the example.

Building NixOS from a bare Incus instance

incus launch images:nixos/26.05 lumo-nixos
incus exec lumo-nixos -- sh
# put the fragment above into /etc/nixos/configuration.nix
export NIX_PATH="nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix"
nixos-rebuild switch --option sandbox false
git clone https://codeberg.org/not-forking/not-forking
cd not-forking && perl Makefile.PL PREFIX=/root/.local && make && make install
export PATH=/root/.local/bin:$PATH
export PERL5LIB="/root/.local/lib/perl5/site_perl/5.42.0:$PERL5LIB"
git clone https://codeberg.org/lumosql/lumosql
cd lumosql && make doctor && make build TARGETS="3.53.2 3.53.2+lmdbv1-1.0"