Overview
Nixidy is a declarative Kubernetes manifest generator that uses Nix to define applications and Helm charts. The microservices-app uses Nixidy to:- Define all Kubernetes resources in Nix
- Manage Helm chart values declaratively
- Generate ArgoCD Applications for GitOps
- Ensure reproducible manifests
Architecture
Nixidy modules are organized as follows:Environment Configuration
The main environment file atdeploy/nixidy/env/local.nix imports all service modules:
Key Settings
- target.repository: Git repository for ArgoCD sync
- target.rootPath: Where manifests are stored
- autoSync: Automatically sync changes from Git
- prune: Delete resources not in Git
- selfHeal: Reconcile manual changes
Service Module Example
Example fromdeploy/k8s/greeter.nix:
Key Features
- Type safety: Nix validates structure at evaluation time
- Reusable labels: Define labels once, reference everywhere
- Environment variables: Declarative configuration
- Health probes: Kubernetes liveness and readiness checks
- Resource limits: CPU and memory constraints
Helm Chart Integration
Thedeploy/nixidy/env/traefik.nix shows Helm chart usage:
charts attribute provides access to Helm charts defined in flake.nix.
Generating Manifests
Thegen-manifests command builds and copies manifests:
scripts/gen-manifests.sh:
Build Process
- Nix evaluation: Evaluates
flake.nix#nixidyEnvs.local - Build: Generates all YAML manifests
- Copy: Copies from Nix store to
deploy/manifests/ - Cleanup: Removes ArgoCD bootstrap Application (deployed separately)
- Diff: Shows changes to commit
Auto-Regeneration
Tilt watches Nixidy files and auto-regenerates manifests:.nix files trigger automatic manifest regeneration and kubectl apply.
Watching Manifests
Monitor Nixidy changes and apply automatically:.nix files and runs gen-manifests + kubectl apply on changes.
Adding a New Service
When adding a new service, update Nixidy:- Create module:
deploy/k8s/my-service.nix - Import in environment: Add to
deploy/nixidy/env/local.niximports - Add to Tiltfile: Include in
gen-manifestsdeps - Stage files: Run
git add deploy/k8s/my-service.nix(Nix requires tracked files) - Generate: Run
gen-manifests
Fixing Chart Hashes
If you see achartHash error:
.nix files.
Troubleshooting
Nix Evaluation Errors
Git-Tracked Files
Nixidy usesbuiltins.path which only reads Git-tracked files. Always git add new .nix files before running gen-manifests.
Manifest Diff
Review changes before committing:Next Steps
- Deploy to Kubernetes: Kubernetes Deployment
- Configure Traefik: Traefik Configuration
- Add observability: Observability Stack