Building from Source¶
Instructions for building DecentDb from source code.
Prerequisites¶
Required¶
- Nim >= 1.6.0
- libpg_query (PostgreSQL parser library)
- git (for cloning)
Optional¶
- Python >= 3.8 (for test harness)
- libpg_query development headers (for building)
Installing Nim¶
Using choosenim (Recommended)¶
Or on Windows:
Using Package Manager¶
Ubuntu/Debian:
macOS:
Arch Linux:
Verify Installation¶
Installing libpg_query¶
Ubuntu/Debian¶
macOS¶
From Source¶
If your distribution doesn't have it:
Verify¶
Cloning the Repository¶
Building¶
Standard Build¶
This creates the decentdb executable.
Release Build¶
Optimized for performance:
Debug Build¶
With debug symbols and assertions:
Static Build¶
Self-contained binary (Linux only):
Running Tests¶
All Tests¶
This runs: - All Nim unit tests - Python harness tests
Nim Tests Only¶
Python Tests Only¶
Specific Test¶
Installation¶
Local Install¶
Installs to ~/.nimble/bin/
System Install¶
Verify¶
Development Build¶
For active development with fast rebuilds:
# Compile without optimization
nim c -d:development src/decentdb.nim
# Or use the debug task
nimble build -d:debug
Cross-Compilation¶
Windows from Linux¶
Requires mingw-w64:
macOS from Linux¶
Requires macOS SDK (complex setup).
ARM64 from x64¶
Docker Build¶
Build Image¶
Run Container¶
Troubleshooting¶
"libpg_query not found"¶
Problem:
Solution:
# Find the library
find /usr -name "libpg_query*" 2>/dev/null
# Add to library path
export LIBRARY_PATH=/usr/local/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
# Rebuild
nimble build
"nim not found"¶
Problem:
Solution:
# Add nimble bin to PATH
export PATH=$HOME/.nimble/bin:$PATH
# Or reinstall choosenim
curl https://nim-lang.org/choosenim/init.sh -sSf | sh
Tests Fail¶
Problem: Some tests fail after build.
Solution:
# Run specific test for details
nim c -r tests/nim/test_wal.nim
# Check Python tests separately
python -m pytest tests/harness/test_runner.py -v
Slow Build¶
Problem: Build takes too long.
Solution:
# Use release flags (faster compilation)
nimble build -d:release
# Or parallel compilation
nim c --parallelBuild:4 src/decentdb.nim
IDE Setup¶
VS Code¶
Install extensions: - Nim (by kosz78) - Syntax highlighting, compilation - nim-lsp - Language server support
Configuration:
Vim/Neovim¶
Using nimlsp:
Emacs¶
Using nim-mode:
Continuous Integration¶
The project uses GitHub Actions:
- Build: Compiles on Linux, macOS, Windows
- Test: Runs all tests
- Lint: Static analysis
- Docs: Builds documentation
See .github/workflows/ for details.
Release Checklist¶
Before creating a release:
- [ ] All tests pass
- [ ] Version updated in
decentdb.nimble - [ ] CHANGELOG.md updated
- [ ] Documentation built
- [ ] Binaries built for all platforms
- [ ] Version bumped (e.g.
0.0.1->0.0.2) and changelog updated - [ ] Git tag created:
git tag -a v0.0.1 -m "Release 0.0.1" - [ ] Tag pushed:
git push origin v0.0.1