Why Nix? Eliminates "works on my machine" by pinning every dependency - from Go version to system libraries - in a single file. Build today, rebuild in 5 years, get identical binaries.
# Enter dev shell (installs all dependencies)
nix develop
# Pre-commit hooks are automatically installed in Nix shell
# They include: nixpkgs-fmt for Nix formatting
# Build QNTX binary
nix build
# Run checks (flake validation, build verification)
nix flake check
.github/workflows/ci-image.ymlWhy Cachix? First build takes ~30 min (compiles everything). Cachix caches binaries. Next build: ~5 min (just downloads from cache).
Caching strategy:
flake.lock hash (nixpkgs version)flake.lock → rebuild everything (new cache key)flake.lock → instant downloads from CachixWhy vendorHash? Nix downloads your Go modules during build. Hash proves you got what you expected (security). Wrong hash = build fails.
How to update:
# After changing go.mod/go.sum, run this:
./.githooks/update-nix-hash.sh
# Or manually: let it fail, copy new hash from error
nix build .#qntx # Fails with "got: sha256-ABC..."
# Copy "got" hash to vendorHash in flake.nix
# Verify
nix build .#qntx
# Commit together
git add flake.nix go.mod go.sum
Why upgrade? Get newer Go/Rust versions, security patches, bug fixes in build tools.
nix flake update nixpkgs # Updates flake.lock
nix build .#qntx # Test build still works
nix flake check # Verify all packages build
git add flake.lock
git commit -m "Update nixpkgs"
Why: Nix hashes your Go modules to detect tampering. You changed go.mod but didn't update the hash → security check fails.
Fix: ./.githooks/update-nix-hash.sh or copy "got:" hash from error to flake.nix.
Why: Nix sandbox blocks network to force reproducibility. Can't download during build → must declare all deps upfront.
Fix: Update vendorHash (Go deps) or add to contents = [...] (system deps).
Why: You're on different nixpkgs version. CI uses flake.lock, you might have uncommitted flake.lock.
Fix: git add flake.lock and commit it. Or nix flake update to match CI.
.githooks/README.md - Git hooks setupflake.nix - QNTX app image.github/workflows/nix-image.ymlci/flake.nix - CI image.github/workflows/ci-image.yml