Template: Default
The default template is the recommended way to start a new Den project. It includes flake-parts, Home-Manager, dendritic flake-file, and a VM for testing.
Initialize
Section titled “Initialize”mkdir my-nix && cd my-nixnix flake init -t github:vic/den#defaultnix flake update denProject Structure
Section titled “Project Structure”flake.nix # auto-generated by flake-filemodules/ dendritic.nix # flake-file + den dendritic setup hosts.nix # host and user declarations defaults.nix # global settings (stateVersion, etc.) igloo.nix # host aspect tux.nix # user aspect vm.nix # VM runnerFile by File
Section titled “File by File”hosts.nix — Declare Your Infrastructure
Section titled “hosts.nix — Declare Your Infrastructure”{ den.hosts.x86_64-linux.igloo.users.tux = { };}This single line declares:
- A host
iglooonx86_64-linux(class:nixos) - A user
tuxon that host (class:homeManager)
The host and user each get an aspect (den.aspects.igloo and den.aspects.tux) that you configure in separate files.
igloo.nix — Host Aspect
Section titled “igloo.nix — Host Aspect”{ den.aspects.igloo = { nixos = { pkgs, ... }: { environment.systemPackages = [ pkgs.hello ]; }; homeManager = { pkgs, ... }: { home.packages = [ pkgs.vim ]; }; };}The host aspect provides:
- NixOS config — system packages available to all users
- Home-Manager config — default home environment for every user on this host
tux.nix — User Aspect
Section titled “tux.nix — User Aspect”{ den, ... }:{ den.aspects.tux = { includes = [ den.provides.primary-user (den.provides.user-shell "fish") ]; homeManager = { pkgs, ... }: { home.packages = [ pkgs.htop ]; }; };}The user aspect:
- Includes
primary-user— adds wheel + networkmanager groups - Includes
user-shell— sets fish as default shell at OS and HM level - Provides personal Home-Manager packages
defaults.nix — Global Settings
Section titled “defaults.nix — Global Settings”{ den.default.nixos.system.stateVersion = "25.11"; den.default.homeManager.home.stateVersion = "25.11";}den.default applies settings to all hosts, users, and homes. This is the right place for stateVersion and other global policies.
vm.nix — Test in a VM
Section titled “vm.nix — Test in a VM”{ inputs, den, ... }:{ den.aspects.igloo.includes = [ (den.provides.tty-autologin "tux") ];
perSystem = { pkgs, ... }: { packages.vm = pkgs.writeShellApplication { name = "vm"; text = let host = inputs.self.nixosConfigurations.igloo.config; in '' ${host.system.build.vm}/bin/run-${host.networking.hostName}-vm "$@" ''; }; };}Run the VM with:
nix run .#vmdendritic.nix — Flake Wiring
Section titled “dendritic.nix — Flake Wiring”{ inputs, ... }:{ imports = [ (inputs.flake-file.flakeModules.dendritic or { }) (inputs.den.flakeModules.dendritic or { }) ]; flake-file.inputs = { den.url = "github:vic/den"; flake-file.url = "github:vic/flake-file"; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; };}This uses flake-file so inputs can be defined close to where they are used. Run nix run .#write-flake to regenerate flake.nix after changing inputs.
Data Flow
Section titled “Data Flow”graph TD
H["hosts.nix: igloo + tux"] --> CH["ctx.host {host=igloo}"]
CH --> AI["den.aspects.igloo<br/>nixos + homeManager"]
CH --> CU["ctx.user {host=igloo, user=tux}"]
CU --> AT["den.aspects.tux<br/>primary-user + fish + htop"]
CH --> HM["ctx.hm-host: import HM module"]
HM --> HMU["ctx.hm-user: forward homeManager<br/>into home-manager.users.tux"]
AI --> NixOS["nixosConfigurations.igloo"]
AT --> NixOS
HMU --> NixOS
What It Provides
Section titled “What It Provides”| Feature | Provided |
|---|---|
| NixOS host configuration | ✓ |
| Home-Manager integration | ✓ |
| Dendritic flake-file | ✓ |
| VM testing | ✓ |
| flake-parts | ✓ |
| Darwin support | Add input |
| Namespaces | Add manually |
Next Steps
Section titled “Next Steps”- Edit
hosts.nixto add more hosts or users - Create new aspect files under
modules/ - Add Darwin support by adding
nix-darwininput - Explore the Example template for namespaces and advanced features