Template: Minimal
The minimal template demonstrates Den’s core with zero extra dependencies beyond nixpkgs.
Initialize
Section titled “Initialize”mkdir my-nix && cd my-nixnix flake init -t github:vic/den#minimalnix flake update denProject Structure
Section titled “Project Structure”flake.nixmodules/ den.nixflake.nix
Section titled “flake.nix”{ outputs = inputs: (inputs.nixpkgs.lib.evalModules { modules = [ (inputs.import-tree ./modules) ]; specialArgs = { inherit inputs; }; }).config.flake;
inputs = { nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"; import-tree.url = "github:vic/import-tree"; flake-aspects.url = "github:vic/flake-aspects"; den.url = "github:vic/den"; };}Key points:
- No flake-parts — uses
lib.evalModulesdirectly - import-tree — recursively loads all
.nixfiles undermodules/ - Results land in
.config.flake(nixosConfigurations, etc.)
modules/den.nix
Section titled “modules/den.nix”{ inputs, den, ... }:{ imports = [ inputs.den.flakeModule ];
den.hosts.x86_64-linux.igloo.users.tux = { };
den.aspects.igloo = { nixos = { pkgs, ... }: { environment.systemPackages = [ pkgs.hello ]; boot.loader.grub.enable = false; # TODO: remove for real hardware fileSystems."/".device = "/dev/null"; }; };
den.aspects.tux = { includes = [ den.provides.primary-user ]; };}What This Declares
Section titled “What This Declares”- One host named
iglooonx86_64-linuxwith one user namedtux - Host aspect
den.aspects.igloo— provides NixOS config (a package + boot/fs stubs) - User aspect
den.aspects.tux— includes theprimary-userbattery
How It Works
Section titled “How It Works”graph TD H["den.hosts.x86_64-linux.igloo"] -->|"ctx.host"| A["den.aspects.igloo"] H -->|"ctx.user"| U["den.aspects.tux"] U -->|"includes"| PU["den.provides.primary-user"] A -->|"resolve nixos"| NixOS["nixosConfigurations.igloo"]
- Den reads
den.hostsand creates actx.host { host = igloo }context - The host aspect
igloois activated with its NixOS config - For each user, a
ctx.user { host, user }context is created - The user aspect
tuxincludesprimary-user(adds wheel/networkmanager groups) - Everything resolves into
nixosConfigurations.igloo
Build It
Section titled “Build It”nix build .#nixosConfigurations.igloo.config.system.build.toplevelCustomize
Section titled “Customize”To add your own host configuration, edit den.aspects.igloo.nixos. To add user packages, add a homeManager key to den.aspects.tux (requires adding home-manager input). Or keep it simple — the minimal template works without Home-Manager.
What It Provides
Section titled “What It Provides”| Feature | Provided |
|---|---|
| NixOS host configuration | ✓ |
| User with wheel/networkmanager | ✓ |
| Home-Manager | ✗ |
| Darwin support | ✗ |
| Namespaces | ✗ |
| VM testing | ✗ |
Next Steps
Section titled “Next Steps”- Add more aspects in separate files under
modules/ - Graduate to the Default template for Home-Manager support
- Read Core Principles to understand the context pipeline