Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

denful/den

Repository files navigation

Sponsor Vic Ask DeepWiki Aspect-oriented Nix License CI Status

den and vic's aspect libs made for you with Love++ and AI--. If you like my work, consider sponsoring

den — Aspect-oriented, Context-driven Nix

Write a feature once. Run it on every host, user, and platform you have — and share it with anyone, flake or not.

Den turns Nix configuration into composable features instead of per-host piles of modules. A Den aspect is a plain function: give it context (your hosts and users) and it returns configuration for every Nix class it touches — nixos, darwin, homeManager, hjem, or a class you invent.

# An aspect is a function of context that returns
# configuration for many Nix classes at once.
den.aspects.gaming = { host, user }: {
 nixos = { pkgs, ... }: { programs.steam.enable = true; };
 darwin = { pkgs, ... }: { /* ... */ };
 homeManager = { pkgs, ... }: { /* ... */ };
 includes = [ den.aspects.performance ]; # aspects compose
 provides.emulation = { nixos = { /* ... */ }; }; # and nest
};

That one idea — a feature as a function — is what makes the rest possible.

What Den makes possible

  • One feature, everywhere, in one place. Stop scattering a single concern across separate nixos, darwin, and homeManager files. An aspect holds all of it together.
  • Reuse across hosts, users — and across projects. Share aspects between machines, between people, and between flake and non-flake setups, without forcing everyone to download each other's inputs.
  • No mkIf / enable clutter. The shape of the context is the condition — a function that asks for { host, user } simply doesn't run where there's no user. Conditionals disappear.
  • Hosts shape their users, users shape their hosts. Cross-entity configuration flows both ways, without coupling them together.
  • Add a capability in one line; remove it by deleting that line. Hosts just pick the aspects they want.
  • Bring your own classes and whole pipelines. Custom Nix classes, machine fleets, MicroVM guests, terranix, standalone neovim — if you can walk it as data, Den can configure it.

Principles

Four concepts, one job each:

  • Entitywhat exists: a host, user, or home.
  • Aspectwhat it does: a feature, spanning Nix classes.
  • Policyhow entities relate: topology and routing between them.
  • Quirkstructured data aspects share, without coupling.

Feature-first, not host-first. Traditional setups start from hosts and push modules down; Den flips that — features are primary, hosts just select them.

Den embraces your Nix. With or without flakes, flake-parts, or home-manager. Zero dependencies. Every part is optional and replaceable — Den works with the setup you already have, and gets out of the way.

Try it now

# a MicroVM
nix run github:denful/den?dir=templates/microvm#runnable-microvm
# a standalone neovim
nix run github:denful/den?dir=templates/nvf-standalone#my-neovim
# a qemu VM
nix run github:denful/den

Templates

Pick a starting point and grow from there:

In the wild

  • @vic — fleet-sharing config from Den's author
  • @quasigod — custom namespaces + angle brackets
  • @Gwenodai — path-naming conventions, custom guarded/forwarding classes
  • @adda — multiple hosts, flake-parts + home-manager

Den is also running on internal infra at The European Commission.

Growing adoption: usage search

What people say

Den takes the Dendritic pattern to a whole new level, and I cannot imagine going back.
@adda, early Den adopter (after Dendritic flake-parts and Unify)

I'm super impressed with den so far, I'm excited to try out some new patterns that Unify couldn't easily do.
@quasigod, author of Unify

Massive work you did here!
@drupol, author of "Flipping the Configuration Matrix"

Thanks for the awesome library and the support for non-flakes... it's positively brilliant! I really hope this gets wider adoption.
@vczf, at #den-lib:matrix.org

Den is a playground for some very advanced concepts... some of its ideas will play a role in future Nix areas. There are some raw diamonds in Den.
@Doc-Steve, author of the Dendritic Design Guide


Read the docs → · Sponsor · License

AltStyle によって変換されたページ (->オリジナル) /