This project includes a Nix flake for reproducible development environments and builds.
Build the PDF without installing anything permanently:
nix run github:testaco/agentic-coding-book#build-pdfEnter the development shell:
nix developIf you have direnv installed and enabled:
# Allow direnv to load the environment
direnv allow
# The environment will automatically activate when you cd into the directoryEnter the development environment manually:
nix develop
# All dependencies will be available:
# - Node.js 20
# - Pandoc 3.x
# - Python 3 with PyYAML
# - TeX Live with XeLaTeX
# - Build scripts and utilities# Build the PDF
nix run .#build-pdf
# Validate all content
nix run .#validate
# Validate links only
nix run .#validate-links
# Render Mermaid diagrams
nix run .#build-mermaidBuild the complete book as a Nix package:
nix build
# Output will be in ./result/agentic-coding-book.pdfUpdate all flake inputs to their latest versions:
nix flake updateThe Nix flake provides:
- Node.js 20 - JavaScript runtime for build tools
- Pandoc 3.x - Document converter for PDF generation
- TeX Live with XeLaTeX - LaTeX distribution for PDF typesetting
- Python 3 with PyYAML - For validation scripts
- Git - Version control
- Build utilities - bash, coreutils, findutils, sed, awk
build-pdf- Generate the PDF bookvalidate- Run all validation checksvalidate-links- Check for broken linksbuild-mermaid- Render Mermaid diagrams
default- Complete book build (outputs PDF)
- Reproducible Builds - Same output on any machine
- No System Pollution - Dependencies are isolated
- Version Pinning - Exact versions locked in flake.lock
- Easy Onboarding - One command to get started
- CI/CD Ready - Same environment locally and in CI
If you don't have Nix installed:
# Install Nix (multi-user, recommended)
sh <(curl -L https://nixos.org/nix/install) --daemon
# Enable flakes (add to ~/.config/nix/nix.conf or /etc/nix/nix.conf)
experimental-features = nix-command flakesFor automatic environment activation:
# On NixOS
nix-env -iA nixpkgs.direnv
# On macOS with Homebrew
brew install direnv
# Add to your shell profile (.bashrc, .zshrc, etc.)
eval "$(direnv hook bash)" # for bash
eval "$(direnv hook zsh)" # for zshIf builds are slow, add the Nix community cache:
# Add to ~/.config/nix/nix.conf or /etc/nix/nix.conf
substituters = https://cache.nixos.org https://nix-community.cachix.org
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=The flake will automatically run npm install when needed. If you encounter issues:
# Clear npm cache
rm -rf node_modules package-lock.json
nix develop
npm installIf PDF generation fails due to missing LaTeX packages, add them to flake.nix:
texlive = pkgs.texlive.combine {
inherit (pkgs.texlive) scheme-basic
# ... existing packages ...
your-missing-package
;
};Then rebuild:
nix flake lock --update-input nixpkgs
nix developname: Build PDF with Nix
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
with:
extra_nix_config: |
experimental-features = nix-command flakes
- name: Build PDF
run: nix build
- name: Upload PDF
uses: actions/upload-artifact@v3
with:
name: book-pdf
path: result/agentic-coding-book.pdf| Task | npm/Traditional | Nix Flake |
|---|---|---|
| Install deps | npm install |
nix develop |
| Build PDF | npm run build:pdf |
nix run .#build-pdf |
| Validate | npm test |
nix run .#validate |
| System deps | Manual install | Automatic |
| Reproducibility | ✅ Guaranteed | |
| Isolation | ✅ Full isolation |
-
Initial Setup
git clone <repo> cd agentic-coding-book nix develop # or use direnv
-
Daily Development
# Environment auto-loads with direnv npm run build:pdf # Use familiar npm commands npm test
-
Clean Builds
nix build # Reproducible build from scratch -
CI/CD
# Use nix in CI for guaranteed reproducibility - run: nix build
- Nix Flakes Documentation
- Nix Pills - Learn Nix in depth
- Zero to Nix - Beginner-friendly guide
- direnv Documentation
For issues specific to the Nix setup, please open an issue on GitHub with the nix label.