Replies: 2 comments 6 replies
-
|
This looks like a fundamental shift from static module trees to a dynamic traversal pipeline. The reason "aspect-oriented" fits here is that you're decoupling the what (the host/user data) from the where (the pointcut). Unlike standard NixOS # Example of a custom pointcut/transition
den.ctx.user.into.ssh-key = { user, ... }:
lib.optional (user ? pubkey) { key = user.pubkey; owner = user.name; };
den.ctx.ssh-key.provides.setup = { key, owner }: {
nixos.users.users.${owner}.openssh.authorizedKeys.keys = [ key ];
};One gotcha I've noticed: because these are functions and not standard modules, you have to be explicit about merging if your |
Beta Was this translation helpful? Give feedback.
-
|
Hi! Even though the concept and message of the post still stands, the naming of stuff in Den has changed dramatically (ctx is legacy). Also, this post is currently pinned to the top of the discussions page, giving it a more official feeling. I think we should either unpin it or update the post? I'd help with the rewording, but I don't yet understand the concepts at a deep enough level to confidently edit yet 😅 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Note
No, this is actually how Den configures a NixOS host and support things like machine fleets, or terraform infra, anything that you can describe via a data structure and can be traversed can be configured like we do for NixOS.
Den is a data transformation pipeline (of your infra entities) to which functions (aspects producing configurations) are applied.
From docs about Aspects:
Most importantly, the context
{host,user}here are NOT_module.argsnorspecialArgs, it is an actual function, not a module-looking-as-a-function. This means config can depend on context without Nix infinite loops.Den uses
den.ctx.<name>.provides.<name>as Aspect Pointcuts where configuration is applied to data in that context stage.Say you have a data shape:
{ x }, that you name as afoocontext stage:This
den.ctx.bar.provides.baris the actual aspect that configures using data{ y }available atbarcontext stage. It is the point wherebarconfiguration is applied.AND since
den.ctx.barIS an aspect:also apply at
barstage.This is how everything works in Den, the following is the
den.ctx.host { host }people can define their own extensions to Den's NixOS pipeline, or define other pipelines enterely, see the README example of three-lines on how Den invokes the den.ctx.host pipeline:
Note
v0.9.0 Release Notes where
den.ctxwas designed and introduced in Den.From conversation at matrix. Docs about aspects and context pipeline
Minimal real-life example: wsl support
Context extensions examples: home-env is how Den implements homeManager/hjem/maid support, perSystem classes, microvm support
Beta Was this translation helpful? Give feedback.
All reactions