Using as a template
This guide explains how to use nix-config as a starting point for your TypeScript monorepo projects.
Quick start
Section titled “Quick start”Option 1: GitHub template
Section titled “Option 1: GitHub template”- Click “Use this template” button on GitHub
- Create your new repository
- Clone to your local machine
- Follow customization steps below
Option 2: Nix flake (coming soon)
Section titled “Option 2: Nix flake (coming soon)”nix flake init --template github:sciexp/nix-configOption 3: Manual fork
Section titled “Option 3: Manual fork”git clone https://github.com/cameronraysmith/infra.git my-projectcd my-projectrm -rf .gitgit initgit add .git commit -m "chore: initial commit from infra template"Understanding the naming pattern
Section titled “Understanding the naming pattern”This template uses framework-agnostic, purpose-based naming that works for both the template itself and your forked projects.
Package naming strategy
Section titled “Package naming strategy”Template package: @infra/docs
Why this naming works:
- Framework independence: No mention of Astro/Starlight - these are implementation details
- Template perspective: Most projects need documentation - immediately useful
- Brevity: Shortest meaningful name
- Pattern clarity:
@{scope}/{purpose}scales to multiple packages - Template duality: Works as both a working deployment and a forkable template
For your project
Section titled “For your project”When you fork this template, you’ll rename packages to match your organization and project:
Single-package projects:
@myorg/docs # If docs are your main/only package@myorg/api # If building an API service@myorg/web # If building a web applicationMulti-package projects:
@mycompany/docs # Documentation site@mycompany/api # API backend@mycompany/web # Web frontend@mycompany/shared # Shared utilitiesPattern: Use the package’s purpose, not its implementation framework.
Deployment subdomain patterns
Section titled “Deployment subdomain patterns”Understanding how to structure your deployment URLs is important for scalability.
Subdomain hierarchy
Section titled “Subdomain hierarchy”Top-level (reserved, precious namespace)
Section titled “Top-level (reserved, precious namespace)”Reserve these for organization-wide services:
example.com # Main org sitewww.example.com # Main org sitedocs.example.com # Org-wide documentationapi.example.com # Org-wide API gatewayblog.example.com # Org blogProject-level (scalable)
Section titled “Project-level (scalable)”Use project subdomains for individual applications:
{project}.example.com # Project main site{component}.{project}.example.com # Project componentsDeployment examples
Section titled “Deployment examples”Single-package projects
Section titled “Single-package projects”If your project has only one public-facing site:
Configuration:
- Package:
@myorg/docs - Worker:
myproject - Route:
myproject.example.com
When to use:
- Documentation sites
- Simple web applications
- Single-purpose services
Multi-package projects
Section titled “Multi-package projects”If your project has multiple public-facing components:
Configuration:
- Package:
@myorg/docs→ Worker:myproject-docs→docs.myproject.example.com - Package:
@myorg/api→ Worker:myproject-api→api.myproject.example.com - Package:
@myorg/web→ Worker:myproject-web→www.myproject.example.com
When to use:
- Multi-component architectures
- Clear separation of concerns needed
- Professional multi-service setup
Template deployment example
Section titled “Template deployment example”For infra:
- Package:
@infra/docs - Worker:
nix-config-docs - Route:
infra.cameronraysmith.net
Rationale:
- Preserves
docs.*for actual org documentation ts-nixis short identifier for the template project- Shows project-level subdomain pattern
Customization checklist
Section titled “Customization checklist”When forking this template, update these files:
1. Root package.json
Section titled “1. Root package.json”{ "name": "my-project", "description": "Your project description", "repository": { "type": "git", "url": "https://github.com/yourorg/my-project.git" }, "workspaces": ["packages/*"]}2. Package directories
Section titled “2. Package directories”Rename packages/docs/ to match your package purpose:
mv packages/docs packages/my-package-name3. Package package.json
Section titled “3. Package package.json”Update packages/my-package-name/package.json:
{ "name": "@yourorg/my-package-name", "description": "Your package description", "repository": { "type": "git", "url": "https://github.com/yourorg/my-project.git" }, "release": { "plugins": [ // ... existing plugins ... [ "semantic-release-major-tag", { "customTags": [ "my-package-name-v${major}", "my-package-name-v${major}.${minor}" ] } ] ] }}4. Wrangler configuration
Section titled “4. Wrangler configuration”Update packages/my-package-name/wrangler.jsonc:
{ "name": "my-project-package-name", "routes": [ { "pattern": "my-project.example.com", "custom_domain": true } ]}5. GitHub Actions workflows
Section titled “5. GitHub Actions workflows”Update workflow matrices in .github/workflows/:
ci.yaml:
matrix: package: - name: my-package-name path: packages/my-package-namerelease.yaml:
matrix: package: - name: my-package-name path: packages/my-package-name6. Justfile
Section titled “6. Justfile”Update filter patterns:
# Beforebun run --filter '@infra/docs' dev
# Afterbun run --filter '@yourorg/my-package-name' devSearch and replace @infra/docs with your package name.
7. Documentation
Section titled “7. Documentation”Update:
README.md- Project name and descriptionCONTRIBUTING.md- Scope examples in commit message sectionpackages/my-package-name/README.md- Package-specific docs
8. Flake description
Section titled “8. Flake description”Update flake.nix:
{ description = "my-project: Your project description"; # ... rest of flake}Verification steps
Section titled “Verification steps”After customization:
1. Install dependencies
Section titled “1. Install dependencies”nix developbun install2. Build and test
Section titled “2. Build and test”# Buildjust build
# Run testsjust test
# Run in developmentjust dev3. Verify Nix flake
Section titled “3. Verify Nix flake”nix flake check --impure4. Test semantic-release
Section titled “4. Test semantic-release”# Dry run to verify configurationjust test-release5. Update secrets
Section titled “5. Update secrets”If using SOPS for secrets management:
# Generate new age keysjust sops-bootstrap devjust sops-bootstrap ci
# Add secretsjust edit-secrets
# Upload to GitHubjust sops-upload-github-keyjust sops-setup-githubSee Secrets management guide for details.
Adding more packages
Section titled “Adding more packages”As your project grows, add additional packages:
1. Create package directory
Section titled “1. Create package directory”mkdir -p packages/new-package/srccd packages/new-package2. Create package.json
Section titled “2. Create package.json”{ "name": "@yourorg/new-package", "version": "0.0.0-development", "private": true, "description": "Package description", "type": "module", "repository": { "type": "git", "url": "https://github.com/yourorg/my-project.git" }, "license": "MIT", "scripts": { "build": "...", "test": "...", "test-release": "semantic-release --dry-run --no-ci" }, "release": { "extends": "semantic-release-monorepo", "branches": [{ "name": "main" }], "npmPublish": false, "plugins": [ // Copy from existing package ] }}3. Update workflow matrices
Section titled “3. Update workflow matrices”Add to .github/workflows/ci.yaml and .github/workflows/release.yaml:
matrix: package: - name: existing-package path: packages/existing-package - name: new-package path: packages/new-package4. Create package-specific config
Section titled “4. Create package-specific config”tsconfig.jsonextending root config- Test configuration if needed
- Build configuration
5. Install and test
Section titled “5. Install and test”cd ../..bun installjust test-pkg new-packageRemoving template-specific content
Section titled “Removing template-specific content”After forking, you may want to remove template-specific documentation:
Optional removals
Section titled “Optional removals”docs/notes/- Template development notes (safe to remove)- Template-specific guides (if creating your own)
- Example content in
packages/docs/src/content/docs/
Keep these
Section titled “Keep these”CONTRIBUTING.md- Conventional commit guidelines.github/workflows/- CI/CD automationjustfile- Task automation (customize commands)- Nix configuration - Development environment
Enabling releases
Section titled “Enabling releases”When ready for public releases:
1. Verify conventional commits
Section titled “1. Verify conventional commits”Ensure your team understands and uses conventional commit format.
2. Test releases
Section titled “2. Test releases”# Test at rootbun run test-release
# Test per packagecd packages/my-packagebun run test-release3. Enable workflow
Section titled “3. Enable workflow”Uncomment triggers in .github/workflows/release.yaml:
# Change from:on: workflow_dispatch: inputs: dry-run: default: true
# To:on: push: branches: - main workflow_dispatch: inputs: dry-run: default: false4. Verify first release
Section titled “4. Verify first release”Push a conventional commit and watch the release workflow:
git commit -m "feat(my-package): add initial functionality"git pushgh run watchSee Architecture decisions for release strategy details.
Getting help
Section titled “Getting help”Template issues
Section titled “Template issues”If you encounter issues with the template itself:
- Check GitHub Issues
- Open a new issue with reproduction steps
Project-specific issues
Section titled “Project-specific issues”For your forked project:
- Consult the guides in this documentation
- Check the Nix documentation
- Review Bun workspace docs
- See semantic-release docs
Next steps
Section titled “Next steps”After customization:
- Set up CI/CD - Follow CI/CD setup guide
- Configure secrets - Follow Secrets management guide
- Add tests - Follow Testing guide
- Deploy - Configure Cloudflare Workers or your deployment target
- Start building - Create your application code
Welcome to your new TypeScript monorepo!