Overview
nixidy is a declarative Kubernetes manifest generator that uses Nix to create ArgoCD applications. The project uses nixidy to manage all Kubernetes resources with type safety, composability, and reproducibility.Integration
Nixidy is integrated via Nix flakes (flake.nix:15-18):Directory Structure
Nixidy modules are organized in thenixidy/env/ directory:
Environment Definitions
Local Environment
The local environment (nixidy/env/local.nix) imports all application modules:Production Environment
The production environment (nixidy/env/prod.nix) is a subset with security overrides:Creating Application Modules
Application modules follow a consistent structure. Here’s an example from nixidy/env/local/argocd.nix:Module Structure
- Application Declaration:
applications.<name> - Namespace: Set namespace and optionally create it
- Helm Release: Configure chart and values
- Chart Reference: Use charts from nixhelm (e.g.,
charts.prometheus-community.kube-prometheus-stack)
Helm Chart Access
Charts are injected via thecharts parameter, which comes from nixhelm. Available chart repositories include:
charts.argoproj.*- ArgoCD and related toolscharts.prometheus-community.*- Prometheus ecosystemcharts.grafana.*- Grafana and Loki- And many more…
Advanced Patterns
Using Raw Manifests
For resources not managed by Helm, use theresources attribute (from nixidy/env/local/grafana-dashboards.nix):
- Compiles Jsonnet dashboards at build time
- Injects them as ConfigMaps
- Uses Grafana’s dashboard sidecar to auto-discover them
Sync Options
For resources requiring server-side apply (from nixidy/env/local/kube-prometheus-stack.nix:7):Generating Manifests
Manual Generation
To regenerate manifests from nixidy modules:- Detects platform using
platform.sh - Builds the nixidy environment package
- Copies manifests to
manifests/ - Removes the self-referencing ArgoCD application
- Shows a git diff summary
Automatic Regeneration
Usewatch-manifests to automatically regenerate and apply manifests on file changes:
Flake Integration
Nixidy environments are exposed as flake outputs (flake.nix:111-122):Building Specific Environments
Debugging
Validate Nix Expressions
Quickly check if nixidy modules evaluate correctly:Fix Chart Hashes
If you encounter emptychartHash errors:
Inspect Generated Manifests
After runninggen-manifests, inspect the output:
Best Practices
- Module Organization: Keep one application per file in
nixidy/env/local/ - Environment Parity: Use
lib.mkForcein prod.nix to override security-sensitive defaults - Chart Versions: Let nixhelm manage chart versions for reproducibility
- Sync Policies: Enable auto-sync, prune, and self-heal for GitOps workflow
- Namespace Management: Use
createNamespace = truefor application-specific namespaces
Next Steps
- Learn about environment setup
- Explore Grafana dashboard integration
- Run performance benchmarks