Skip to content

Context-aware Dendritic Nix

Context-driven, aspect-oriented, cross-class Nix configurations

Den builds on flake-aspectsparametric aspects, and provides a declarative context-pipeline as cutting-points for these aspects.

Context Transformation

Data flows through a declarative pipeline of contexts. Each stage enriches the context — from host definitions through user enumeration to domain-specific requirements.

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.

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.

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.

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.

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.

Built upon den.lib, Den provides ready-made facilities for the common use-case of OS and User configurations.

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