···18`den._.forward` creates an aspect that takes configs from a source class
19and inserts them into a target class at a specified path.
2021-### Example: How Den forwards `hjem` user class to NixOS
2223-Den already integrates nix-maid and hjem just like home-manager.
24-25-Forward a new `hjem` class into NixOS top-level:
2627```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 ]; };
4142- # user aspect has hjem class
43- # settings at host become nixos.hjem.users.<userName> = ...;
44- den.aspects.tux.hjem = { ... };
45-}
00046```
4748### Example: A git class that forwards to home-manager.
···65};
66```
6768-This will set at host: `igloo.home-manager.users.tux.programs.git.userEmail`
6970### Example: A `nix` class that propagates settings to NixOS and HomeManager
71···83 adaptArgs = lib.id;
84 };
8586-nix-allowed = { user, ... }: {
87- nix.allowed-users = [ user.userName ];
88-};
8990-den.aspects.tux.includes = [ nixClass nix-allowed ];
0000091```
9293## Use Cases
···18`den._.forward` creates an aspect that takes configs from a source class
19and inserts them into a target class at a specified path.
2021+### Example: Den `user` class works on both NixOS and nix-Darwin
2223+Den already provides a `user` class like this example,
24+that forwards into the OS `user.user.<userName>` submodule.
02526```nix
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+ };
00003637+# 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+};
44```
4546### Example: A git class that forwards to home-manager.
···63};
64```
6566+This will set at host: `home-manager.users.tux.programs.git.userEmail`
6768### Example: A `nix` class that propagates settings to NixOS and HomeManager
69···81 adaptArgs = lib.id;
82 };
8384+# enable class for all users:
85+den.ctx.user.includes = [ nixClass ];
08687+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 ];
93```
9495## Use Cases