···1818`den._.forward` creates an aspect that takes configs from a source class
1919and inserts them into a target class at a specified path.
20202121-### Example: How Den forwards `hjem` user class to NixOS
2121+### Example: Den `user` class works on both NixOS and nix-Darwin
22222323-Den already integrates nix-maid and hjem just like home-manager.
2424-2525-Forward a new `hjem` class into NixOS top-level:
2323+Den already provides a `user` class like this example,
2424+that forwards into the OS `user.user.<userName>` submodule.
26252726```nix
2828-{ den, lib, ... }:
2929-let
3030- hjem = { host }: { class, aspect-chain }:
3131- den._.forward {
3232- each = host.users;
3333- fromClass = user: "hjem";
3434- intoClass = user: class;
3535- intoPath = user: [ "hjem" "users" user.userName ]
3636- fromAspect = user: den.aspects.${user.aspect};
3737- };
3838-in {
3939- # host forwards user hjem modules into nixos level.
4040- den.aspects.igloo = { includes = [ hjem ]; };
2727+userClass = { host }: { class, aspect-chain }:
2828+ den._.forward {
2929+ each = host.users;
3030+ fromClass = _user: "user";
3131+ intoClass = _user: class; # the class being resolved: nixos or darwin.
3232+ intoPath = user: [ "users" "users" user.userName ]
3333+ fromAspect = user: den.aspects.${user.aspect};
3434+ adaptArgs = os-args: { osConfig = os-args.config; };
3535+ };
41364242- # user aspect has hjem class
4343- # settings at host become nixos.hjem.users.<userName> = ...;
4444- den.aspects.tux.hjem = { ... };
4545-}
3737+# this would enable it on all hosts
3838+# den.ctx.host.includes = [ userClass ];
3939+4040+# settings at `user` class forward into host `users.users.<userName>`
4141+den.aspects.tux.user = { osConfig, pkgs, ... }: {
4242+ packages = [ pkgs.hello ];
4343+};
4644```
47454846### Example: A git class that forwards to home-manager.
···6563};
6664```
67656868-This will set at host: `igloo.home-manager.users.tux.programs.git.userEmail`
6666+This will set at host: `home-manager.users.tux.programs.git.userEmail`
69677068### Example: A `nix` class that propagates settings to NixOS and HomeManager
7169···8381 adaptArgs = lib.id;
8482 };
85838686-nix-allowed = { user, ... }: {
8787- nix.allowed-users = [ user.userName ];
8888-};
8484+# enable class for all users:
8585+den.ctx.user.includes = [ nixClass ];
89869090-den.aspects.tux.includes = [ nixClass nix-allowed ];
8787+8888+# custom aspect that uses the `nix` class.
8989+nix-allowed = { user, ... }: { nix.allowed-users = [ user.userName ]; };
9090+9191+# included at users who can fix things with nix.
9292+den.aspects.tux.includes = [ nix-allowed ];
9193```
92949395## Use Cases