Files
2026-11-22 18:21:36 +01:00

2.2 KiB

sirmem

Nim CLI (stdlib only, no nimble deps) for a file-based knowledge-graph memory.

Tooling: devbox

All tooling comes from devbox (nim, git, file). Cross toolchains come from Nix (below). Use devbox shell or devbox run <script>. Fixing devbox.json / devbox.lock or running devbox update needs no permission.

Layout

  • src/sirmem/core.nim: all logic; every command is a cmdXxx proc returning its output, dispatch routes args.
  • src/sirmem.nim: thin main (--dir/SIRMEM_DIR, exit codes, stderr).
  • tests/test_all.nim: std/unittest; the CLI suite runs bin/sirmem, so build first.
  • scripts/build.sh: cross-compile with Nix-provided gcc toolchains.
  • .gitea/workflows/release.yml: CI (test on push, release on v* tag).

Build / test

  • devbox run build -> bin/sirmem
  • devbox run test (builds the binary, then runs the tests)

Cross-compile (Nix cross gcc)

scripts/build.sh <linux-x86_64|linux-aarch64|windows-x86_64> [out], or devbox run cross-all -> dist/. Follows https://nim-lang.org/docs/nimc.html#crossminuscompilation: the script runs nix shell nixpkgs#<pkg>.stdenv.cc and sets --os/--cpu plus --<cpu>.<os>.gcc.exe/.linkerexe/.path (and plain --gcc.*, since the per-platform ones are ignored when target == host).

  • linux-x86_64: pkgsCross.musl64, static. linux-aarch64: pkgsCross.aarch64-multiplatform (glibc, static via glibc.static; the musl gcc is not in cache.nixos.org so CI would compile gcc).
  • windows-x86_64: pkgsCross.mingwW64, -d:mingw, static; needs windows.mcfgthreads on -L (gcc 15 threading lib). Supported targets: linux x86_64, linux aarch64, windows x86_64. No macOS build (dropped; no darwin toolchain). Quirk: nim.cfg pins the mingw gcc.path to /usr/bin, so the script overrides .gcc.path. The Nim version must be the devbox one (>= 2.2.12); older system nims fail to compile.

Conventions

  • Errors: raise SirmemError (via fail); main prints sirmem: error: ..., exit 1. Warnings go to Store.warnings (stderr).
  • Relations are always rewritten through saveRels (sorted, unique, atomic).

CI / release

CI runs only on pushed v* tags (.gitea/workflows/release.yml: tests, cross-build, release). It never runs on branch pushes, so run devbox run test locally before tagging.