Getting started
Welcome to nix-config! This guide will help you get started with this NixOS and nix-darwin configuration repository.
Prerequisites
Section titled “Prerequisites”Before you begin, ensure you have:
- Nix with flakes enabled
- direnv (recommended for automatic shell activation)
- Git for version control
- A GitHub account (for CI/CD features)
Enabling Nix flakes
Section titled “Enabling Nix flakes”If you haven’t enabled flakes yet, add this to ~/.config/nix/nix.conf:
experimental-features = nix-command flakesOr for NixOS, add to /etc/nixos/configuration.nix:
nix.settings.experimental-features = [ "nix-command" "flakes" ];Quick setup
Section titled “Quick setup”1. Get the template
Section titled “1. Get the template”Choose one of these methods:
Option A: Use as GitHub template
# Click "Use this template" on GitHub, then:git clone https://github.com/YOUR_USERNAME/YOUR_REPO.gitcd YOUR_REPOOption B: Fork manually
git clone https://github.com/cameronraysmith/infra.git my-projectcd my-projectrm -rf .gitgit init2. Enter the development environment
Section titled “2. Enter the development environment”# Allow direnv (recommended)direnv allow
# Or enter manuallynix developThe first time may take a few minutes as Nix downloads dependencies.
3. Install JavaScript dependencies
Section titled “3. Install JavaScript dependencies”bun install4. Start development server
Section titled “4. Start development server”just devVisit http://localhost:4321 to see your site.
Understanding the structure
Section titled “Understanding the structure”This is a Bun workspace monorepo:
nix-config/├── packages/│ └── docs/ # Astro Starlight documentation│ ├── src/ # Source code│ ├── e2e/ # End-to-end tests│ ├── tests/ # Unit test fixtures│ └── package.json # Package configuration├── package.json # Workspace root├── flake.nix # Nix development environment├── justfile # Task automation└── CONTRIBUTING.md # Contribution guidelinesSee Architecture decisions for design rationale.
Essential commands
Section titled “Essential commands”Development
Section titled “Development”# Start dev serverjust dev
# Build for productionjust build
# Preview production buildjust previewTesting
Section titled “Testing”# Run all testsjust test
# Run unit tests onlyjust test-unit
# Run E2E tests onlyjust test-e2e
# Watch modejust test-watchSee Testing guide for comprehensive documentation.
Code quality
Section titled “Code quality”# Format codejust format
# Lint codejust lint
# Check and fixjust checkNix environment
Section titled “Nix environment”# Rebuild flakenix flake check --impure
# Show flake infonix flake show
# Update dependenciesnix flake updateNext steps
Section titled “Next steps”For template users
Section titled “For template users”If you’re using this as a template for your project:
- Customize the template - Follow Template usage guide to rename packages and update configuration
- Set up CI/CD - Follow CI/CD setup guide for GitHub Actions automation
- Configure secrets - Follow Secrets management guide for SOPS setup
- Write tests - Follow Testing guide to add your own tests
- Deploy - Deploy to Cloudflare Workers or your preferred platform
For contributors
Section titled “For contributors”If you’re contributing to this template:
- Read contributing guidelines - See CONTRIBUTING.md
- Understand architecture - Read Architecture decisions
- Follow conventions - Use conventional commits for semantic versioning
- Test changes - Run full test suite before committing
- Create atomic commits - Commit changes immediately after editing
Common tasks
Section titled “Common tasks”Adding a new page
Section titled “Adding a new page”Create a new markdown file in packages/docs/src/content/docs/:
# Create a guidetouch packages/docs/src/content/docs/guides/my-guide.md
# Add frontmattercat > packages/docs/src/content/docs/guides/my-guide.md << 'EOF'---title: My guidedescription: Description of my guide---
Content here...EOFThe page will be automatically available at /guides/my-guide/.
Adding a new package
Section titled “Adding a new package”To add another package to the monorepo:
# Create package directorymkdir -p packages/my-package/src
# Create package.jsoncd packages/my-package# ... add package configurationSee Template usage guide for details.
Running commands in specific packages
Section titled “Running commands in specific packages”# Using just (recommended)just docs dev # Run dev in docs package
# Using bun directlybun run --filter '@infra/docs' devDeploying to Cloudflare Workers
Section titled “Deploying to Cloudflare Workers”# Build and deploycd packages/docsbun run deploy
# Or use justfilejust cf-deploy-productionSee CI/CD setup guide for automated deployment.
Troubleshooting
Section titled “Troubleshooting”Nix issues
Section titled “Nix issues”Problem: “experimental features not enabled”
Solution: Enable flakes in nix configuration (see Prerequisites above)
Problem: Direnv not activating automatically
Solution:
# Add to ~/.bashrc or ~/.zshrceval "$(direnv hook bash)" # or zshProblem: “error: getting status of ‘/nix/store/…’: No such file or directory”
Solution: Rebuild the flake:
nix develop --rebuildBun issues
Section titled “Bun issues”Problem: “command not found: bun”
Solution: Ensure you’re in the Nix development shell:
nix developProblem: Workspace dependencies not resolving
Solution: Reinstall dependencies:
rm -rf node_modules packages/*/node_modulesbun installBuild issues
Section titled “Build issues”Problem: “Module not found” during build
Solution: Check TypeScript paths and ensure all imports are correct:
just check # Run biome checkProblem: Playwright browsers not found
Solution: The browsers are managed by Nix. Rebuild the development shell:
exit # Exit current shellnix develop --rebuildTest issues
Section titled “Test issues”Problem: Tests timing out
Solution: Increase timeout in test configuration or check for hanging async operations
Problem: E2E tests failing with “page not found”
Solution: Ensure dev server is running or build is complete:
just build # Build before E2E testsjust test-e2eGetting help
Section titled “Getting help”Documentation
Section titled “Documentation”- Template usage guide - Forking and customization
- CI/CD setup guide - Automated deployment
- Testing guide - Comprehensive testing
- Secrets management guide - SOPS workflow
- Architecture decisions - Design rationale
External resources
Section titled “External resources”- Nix manual - Nix package manager
- Bun documentation - Bun runtime and package manager
- Astro documentation - Astro framework
- Starlight documentation - Starlight docs framework
- Vitest documentation - Unit testing
- Playwright documentation - E2E testing
Community
Section titled “Community”- GitHub Discussions - Ask questions
- GitHub Issues - Report bugs or request features
What’s next?
Section titled “What’s next?”Now that you’re set up, you can:
- Explore the codebase - Look at example components and tests
- Customize for your needs - Follow the template usage guide
- Build something awesome - Start creating your project
Happy coding!