Modular, context-aware and aspect-oriented dendritic Nix configurations. Discussions: https://oeiuwq.zulipchat.com/join/nqp26cd4kngon6mo3ncgnuap/ den.oeiuwq.com
configurations den dendritic nix aspect oriented

docs

+28 -26
+28 -26
docs/src/content/docs/guides/custom-classes.mdx
··· 18 18 `den._.forward` creates an aspect that takes configs from a source class 19 19 and inserts them into a target class at a specified path. 20 20 21 - ### Example: How Den forwards `hjem` user class to NixOS 21 + ### Example: Den `user` class works on both NixOS and nix-Darwin 22 22 23 - Den already integrates nix-maid and hjem just like home-manager. 24 - 25 - Forward a new `hjem` class into NixOS top-level: 23 + Den already provides a `user` class like this example, 24 + that forwards into the OS `user.user.<userName>` submodule. 26 25 27 26 ```nix 28 - { den, lib, ... }: 29 - let 30 - hjem = { host }: { class, aspect-chain }: 31 - den._.forward { 32 - each = host.users; 33 - fromClass = user: "hjem"; 34 - intoClass = user: class; 35 - intoPath = user: [ "hjem" "users" user.userName ] 36 - fromAspect = user: den.aspects.${user.aspect}; 37 - }; 38 - in { 39 - # host forwards user hjem modules into nixos level. 40 - den.aspects.igloo = { includes = [ hjem ]; }; 27 + userClass = { host }: { class, aspect-chain }: 28 + den._.forward { 29 + each = host.users; 30 + fromClass = _user: "user"; 31 + intoClass = _user: class; # the class being resolved: nixos or darwin. 32 + intoPath = user: [ "users" "users" user.userName ] 33 + fromAspect = user: den.aspects.${user.aspect}; 34 + adaptArgs = os-args: { osConfig = os-args.config; }; 35 + }; 41 36 42 - # user aspect has hjem class 43 - # settings at host become nixos.hjem.users.<userName> = ...; 44 - den.aspects.tux.hjem = { ... }; 45 - } 37 + # this would enable it on all hosts 38 + # den.ctx.host.includes = [ userClass ]; 39 + 40 + # settings at `user` class forward into host `users.users.<userName>` 41 + den.aspects.tux.user = { osConfig, pkgs, ... }: { 42 + packages = [ pkgs.hello ]; 43 + }; 46 44 ``` 47 45 48 46 ### Example: A git class that forwards to home-manager. ··· 65 63 }; 66 64 ``` 67 65 68 - This will set at host: `igloo.home-manager.users.tux.programs.git.userEmail` 66 + This will set at host: `home-manager.users.tux.programs.git.userEmail` 69 67 70 68 ### Example: A `nix` class that propagates settings to NixOS and HomeManager 71 69 ··· 83 81 adaptArgs = lib.id; 84 82 }; 85 83 86 - nix-allowed = { user, ... }: { 87 - nix.allowed-users = [ user.userName ]; 88 - }; 84 + # enable class for all users: 85 + den.ctx.user.includes = [ nixClass ]; 89 86 90 - den.aspects.tux.includes = [ nixClass nix-allowed ]; 87 + 88 + # custom aspect that uses the `nix` class. 89 + nix-allowed = { user, ... }: { nix.allowed-users = [ user.userName ]; }; 90 + 91 + # included at users who can fix things with nix. 92 + den.aspects.tux.includes = [ nix-allowed ]; 91 93 ``` 92 94 93 95 ## Use Cases