Skip to content

Getting started

Welcome to nix-config! This guide will help you get started with this NixOS and nix-darwin configuration repository.

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)

If you haven’t enabled flakes yet, add this to ~/.config/nix/nix.conf:

experimental-features = nix-command flakes

Or for NixOS, add to /etc/nixos/configuration.nix:

nix.settings.experimental-features = [ "nix-command" "flakes" ];

Choose one of these methods:

Option A: Use as GitHub template

Terminal window
# Click "Use this template" on GitHub, then:
git clone https://github.com/YOUR_USERNAME/YOUR_REPO.git
cd YOUR_REPO

Option B: Fork manually

Terminal window
git clone https://github.com/cameronraysmith/infra.git my-project
cd my-project
rm -rf .git
git init
Terminal window
# Allow direnv (recommended)
direnv allow
# Or enter manually
nix develop

The first time may take a few minutes as Nix downloads dependencies.

Terminal window
bun install
Terminal window
just dev

Visit http://localhost:4321 to see your site.

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 guidelines

See Architecture decisions for design rationale.

Terminal window
# Start dev server
just dev
# Build for production
just build
# Preview production build
just preview
Terminal window
# Run all tests
just test
# Run unit tests only
just test-unit
# Run E2E tests only
just test-e2e
# Watch mode
just test-watch

See Testing guide for comprehensive documentation.

Terminal window
# Format code
just format
# Lint code
just lint
# Check and fix
just check
Terminal window
# Rebuild flake
nix flake check --impure
# Show flake info
nix flake show
# Update dependencies
nix flake update

If you’re using this as a template for your project:

  1. Customize the template - Follow Template usage guide to rename packages and update configuration
  2. Set up CI/CD - Follow CI/CD setup guide for GitHub Actions automation
  3. Configure secrets - Follow Secrets management guide for SOPS setup
  4. Write tests - Follow Testing guide to add your own tests
  5. Deploy - Deploy to Cloudflare Workers or your preferred platform

If you’re contributing to this template:

  1. Read contributing guidelines - See CONTRIBUTING.md
  2. Understand architecture - Read Architecture decisions
  3. Follow conventions - Use conventional commits for semantic versioning
  4. Test changes - Run full test suite before committing
  5. Create atomic commits - Commit changes immediately after editing

Create a new markdown file in packages/docs/src/content/docs/:

Terminal window
# Create a guide
touch packages/docs/src/content/docs/guides/my-guide.md
# Add frontmatter
cat > packages/docs/src/content/docs/guides/my-guide.md << 'EOF'
---
title: My guide
description: Description of my guide
---
Content here...
EOF

The page will be automatically available at /guides/my-guide/.

To add another package to the monorepo:

Terminal window
# Create package directory
mkdir -p packages/my-package/src
# Create package.json
cd packages/my-package
# ... add package configuration

See Template usage guide for details.

Terminal window
# Using just (recommended)
just docs dev # Run dev in docs package
# Using bun directly
bun run --filter '@infra/docs' dev
Terminal window
# Build and deploy
cd packages/docs
bun run deploy
# Or use justfile
just cf-deploy-production

See CI/CD setup guide for automated deployment.

Problem: “experimental features not enabled”

Solution: Enable flakes in nix configuration (see Prerequisites above)


Problem: Direnv not activating automatically

Solution:

Terminal window
# Add to ~/.bashrc or ~/.zshrc
eval "$(direnv hook bash)" # or zsh

Problem: “error: getting status of ‘/nix/store/…’: No such file or directory”

Solution: Rebuild the flake:

Terminal window
nix develop --rebuild

Problem: “command not found: bun”

Solution: Ensure you’re in the Nix development shell:

Terminal window
nix develop

Problem: Workspace dependencies not resolving

Solution: Reinstall dependencies:

Terminal window
rm -rf node_modules packages/*/node_modules
bun install

Problem: “Module not found” during build

Solution: Check TypeScript paths and ensure all imports are correct:

Terminal window
just check # Run biome check

Problem: Playwright browsers not found

Solution: The browsers are managed by Nix. Rebuild the development shell:

Terminal window
exit # Exit current shell
nix develop --rebuild

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:

Terminal window
just build # Build before E2E tests
just test-e2e

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!