Overview
The Data Fortress is built on a foundation of clear design principles that guide every architectural decision. These principles ensure the infrastructure remains maintainable, reproducible, and stable at scale.Core Tenets
1. Declarative Everything
If it’s not in code, it doesn’t exist. Every aspect of the infrastructure—from system configurations to user environments—must be declared in version-controlled Nix expressions. This eliminates drift, ensures reproducibility, and provides a complete audit trail.Manual changes made directly to systems will be overwritten on the next deployment. All modifications must go through the configuration repository.
- Complete infrastructure as code
- Git history serves as change log
- Easy rollbacks to any previous state
- No undocumented “tribal knowledge”
2. Single Command Invocation
Deployment and updates should be one command. Complexity should be hidden behind simple, idempotent commands. Whether deploying a new system or updating an existing one, the process should be straightforward:3. Dynamic Discovery
The system automatically finds code. You shouldn’t have to manually import every new file. Traditional Nix configurations require manually importing every module and configuration file. This homelab uses automatic discovery functions that scan directories and build configurations dynamically. What this means in practice:- Create a new directory in
systems/→ automatically becomes a NixOS configuration - Add a file to
homes/→ automatically available as a Home Manager configuration - Drop a module in
modules/nixos/→ automatically imported and available
Discovery eliminates boilerplate and reduces cognitive overhead. You can focus on writing configurations instead of managing imports.
4. Stability
nix flake check is the law.
Every change must pass nix flake check before being merged or deployed. This command validates:
- All NixOS configurations evaluate successfully
- All Home Manager configurations evaluate successfully
- All Nix-on-Droid configurations evaluate successfully
- Code formatting is correct
- Pre-commit hooks pass
CI/CD pipelines enforce this rule. Pull requests cannot be merged if
nix flake check fails.- Catches errors before deployment
- Prevents broken configurations from reaching production
- Ensures all systems remain buildable
- Forces evaluation of lazy Nix expressions
Design Implications
Hermetic Builds
All builds are hermetic and reproducible thanks to Nix Flakes. Theflake.lock file pins every input to exact revisions, ensuring:
- Identical builds on different machines
- Ability to reproduce historical configurations
- Protection against supply chain attacks
Modularity
Configurations are composed from reusable modules:- System-level modules in
modules/nixos/ - User-level modules in
modules/home/ - Android modules in
modules/droid/
Separation of Concerns
The directory structure enforces clear boundaries:| Layer | Location | Scope |
|---|---|---|
| System configuration | systems/ | Machine-level settings |
| User configuration | homes/ | Per-user environments |
| Reusable logic | modules/ | Shared functionality |
| Custom software | pkgs/ | Package definitions |
| Utilities | lib/ | Helper functions |
Zero Trust Secrets
Secrets are managed usingagenix with encryption at rest:
- Secrets never stored in plaintext
- Encrypted with age keys derived from host SSH keys
- Decrypted only at deployment time
- Separate secrets per system/user
Philosophy in Practice
Adding a New System
- Create directory:
systems/newhost/ - Add
default.nixwith configuration - Optionally add
meta.jsonfor metadata - Run
nix flake check - Deploy:
nixos-rebuild switch --flake .#newhost
Adding a New User
- Create directory:
homes/newuser/ - Add
default.nixwith Home Manager configuration - Run
nix flake check - Deploy:
home-manager switch --flake .#newuser
Creating a Module
- Add file to
modules/nixos/ormodules/home/ - Module is automatically imported
- Enable in system/user configuration
- Run
nix flake checkto validate
Conclusion
These four principles—declarative everything, single command invocation, dynamic discovery, and stability—create an infrastructure that is:- Easy to understand and navigate
- Simple to extend with new systems
- Reliable through automated validation
- Reproducible across environments