Context Transformation
Context-aware Dendritic Nix
Two Core Principles
Section titled “Two Core Principles”Den builds on flake-aspects’ parametric aspects, and provides a declarative context-pipeline as cutting-points for these aspects.
Context-Aware Aspects
Aspects are composable bundles of cross-class Nix configs. They inspect context to produce conditional, parametric configurations — and are activated by a matching context.
1. Context Transformation
Section titled “1. Context Transformation”Data flows through a declarative pipeline. You declare the entities (data) that exists in your universe, Den transforms them into progressively richer contexts to which aspects are attached, providing configuration for each context:
graph LR
H["den.ctx.host {host}"] --> U["den.ctx.user {host, user} (for each user)"]
U --> HM["aspect provides homeManager/hjeim class"]
H --> OS["aspect provides nixos/darwin class"]
Each stage of the pipeline is a context type defined in den.ctx. Context types
declare how to find aspects, how to transform into other contexts, and which
parametric includes to activate.
2. Context-Aware Aspects
Section titled “2. Context-Aware Aspects”Aspects are composable bundles that inspect their context parameters to decide
what to produce. A function taking { host, ... } only runs when a host context
exists. A function taking { host, user, ... } runs once per user on each host.
Functions that require parameters not present in the current context are not included. Den introduces pattern matching on context shape.
Den as a Library
Section titled “Den as a Library”All parts of Den are optional, re-usable and replaceable. Even the default NixOS configuration pipeline is opt-in, and you can use Den lib to configure anything supporting Nix modules.
Any Nix Class
NixOS, Darwin, Home-Manager, Terraform, NixVim — Den works with anything configurable through Nix.
Context Pipeline
Define custom context types with den.ctx. Declarative
transformations propagate data through your config graph.
No Lock-in
Works with flakes, without flakes, with flake-parts, or standalone. Den plays well with your existing Nix choices. And integrates with your existing infra.
Sharable Aspects
Re-usablity is one of the goals of Den. Allowing people to create truly-generic configuration modules. Namespaces let you publish and consume aspect libraries across repositories and flakes.
Den as a Framework
Section titled “Den as a Framework”Built upon den.lib, Den provides ready-made facilities for the common use-case of OS and User configurations.
Declare Systems
One-liner host and user definitions with freeform schemas. NixOS, Darwin, Home-Manager — all from a single source.
Bidirectional
Hosts configure their users. Users contribute to their hosts. Aspects flow in both directions automatically.
Batteries Included
Opt-in aspects for common tasks: define-user, primary-user, user-shell, unfree packages, import-tree, and more.
Community
Share configurations through namespaces. Real-world setups and a growing ecosystem at denful (wip).
Feel free to to explore the codebase, particularly our included batteries and tests that serve as examples.
Join our community discussion.
den and vic’s dendritic libs made for you with Love++ and AI—. If you like my work, consider sponsoring