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 acmdXxxproc returning its output,dispatchroutes args.src/sirmem.nim: thin main (--dir/SIRMEM_DIR, exit codes, stderr).tests/test_all.nim: std/unittest; the CLI suite runsbin/sirmem, so build first.scripts/build.sh: cross-compile with Nix-provided gcc toolchains..gitea/workflows/release.yml: CI (test on push, release onv*tag).
Build / test
devbox run build->bin/sirmemdevbox 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 viaglibc.static; the musl gcc is not in cache.nixos.org so CI would compile gcc). - windows-x86_64:
pkgsCross.mingwW64,-d:mingw, static; needswindows.mcfgthreadson-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 mingwgcc.pathto /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(viafail); main printssirmem: error: ..., exit 1. Warnings go toStore.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.