···66import { Aside } from '@astrojs/starlight/components';
7788<Aside title="Source" icon="github">
99-[`modules/aspects/provides/forward.nix`](https://github.com/vic/den/blob/main/modules/aspects/provides/forward.nix) --
1010-[`modules/aspects/provides/os-user.nix`](https://github.com/vic/den/blob/main/modules/aspects/provides/os-user.nix) --
1111-[forward tests](https://github.com/vic/den/blob/main/templates/ci/modules/features/forward-from-custom-class.nix)
99+[`forward.nix`](https://github.com/vic/den/blob/main/modules/aspects/provides/forward.nix) --
1010+[`os-user.nix`](https://github.com/vic/den/blob/main/modules/aspects/provides/os-user.nix) --
1111+[`forward-alias-class.nix`](https://github.com/vic/den/blob/main/templates/ci/modules/features/forward-alias-class.nix) --
1212+[`forward-from-custom-class.nix`](https://github.com/vic/den/blob/main/templates/ci/modules/features/forward-from-custom-class.nix) --
1313+[`guarded-forward.nix`](https://github.com/vic/den/blob/main/templates/ci/modules/features/guarded-forward.nix)
1214</Aside>
13151416## What is a Custom Class
···4446| `each` | List of items to forward (typically `[ user ]` or `[ true ]`) |
4547| `fromClass` | The custom class name to read from |
4648| `intoClass` | The target class to write into |
4747-| `intoPath` | Target attribute path in the target class |
4949+| `intoPath` | Target attribute path in the target class|
4850| `fromAspect` | The aspect to read the custom class from |
49515252+5053## Example: The Built-in `user` Class
51545252-The `user` class (`modules/aspects/provides/os-user.nix`) forwards OS-level
5353-user settings without requiring Home Manager:
5555+The `user` class ([`provides/os-user.nix`](https://github.com/vic/den/tree/main/modules/aspects/provides/os-user.nix))
5656+forwards OS-level user settings to NixOS/nix-Darwin lightweight user-environment.
54575558```nix
5659# Instead of:
···156159157160## User contributed examples
158161159159-#### Example: Config across `nixos` and `darwin` classes.
162162+### Example: Alias a Class into the Target Root
163163+164164+This pattern is useful when you want a class to behave like an alias for another
165165+class while keeping a separate name in your aspects.
166166+167167+```nix
168168+hmAlias =
169169+ { class, aspect-chain }:
170170+ den._.forward {
171171+ each = lib.singleton class;
172172+ fromClass = _: "hm";
173173+ intoClass = _: "homeManager";
174174+ intoPath = _: [ ];
175175+ fromAspect = _: lib.head aspect-chain;
176176+ adaptArgs = { config, ... }: { osConfig = config; };
177177+ };
178178+179179+den.aspects.tux = {
180180+ includes = [ hmAlias ];
181181+ hm =
182182+ { osConfig, ... }:
183183+ {
184184+ programs.fish.enable = true;
185185+ home.keyboard.model = osConfig.networking.hostName;
186186+ };
187187+};
188188+```
189189+190190+This forwards `hm.*` directly into `homeManager.*`. A more interesting use case is the following:
191191+192192+193193+### Example: Platform specific `hm` classes
194194+195195+This pattern is useful when you need HM to distinguish between
196196+different OS Platforms, because some packages only build in
197197+Darwin and not NixOS.
198198+199199+200200+```nix
201201+hmPlatforms =
202202+ { class, aspect-chain }:
203203+ den._.forward {
204204+ each = [ "Linux" "Darwin" "Aarch64" "64bit" ];
205205+ fromClass = platform: "hm${platform}";
206206+ intoClass = _: "homeManager";
207207+ intoPath = _: [ ];
208208+ fromAspect = _: lib.head aspect-chain;
209209+ guard = { pkgs, ... }: platform: lib.mkIf pkgs.stdenv."is${platform}";
210210+ adaptArgs = { config, ... }: { osConfig = config; };
211211+ };
212212+213213+den.aspects.tux = {
214214+ includes = [ hmPlatforms ];
215215+216216+ hmLinux = { pkgs, ... }: {
217217+ home.packages = [ pkgs.wl-clipboard-rs ];
218218+ };
219219+220220+ hmDarwin = { pkgs, ... }: {
221221+ home.packages = [ pkgs.iterm2 ];
222222+ };
223223+};
224224+```
225225+226226+### Example: Config across `nixos` and `darwin` classes.
160227161228The `os` forward class ([provided by Den](https://github.com/vic/den/blob/main/modules/aspects/provides/os-class.nix)) can be useful for settings that must be forwarded to both on NixOS and MacOS.
162229···180247};
181248```
182249183183-#### Example: Role based configuration between users and hosts
250250+### Example: Role based configuration between users and hosts
184251185252A dynamic class for matching roles between users and hosts.
186253···215282};
216283```
217284218218-#### Example: A git class that checks enable.
285285+### Example: A git class that checks enable.
219286220287```nix
221288gitClass =
···237304238305This will set at host: `home-manager.users.tux.programs.git.userEmail`
239306240240-#### Example: A `nix` class that propagates settings to NixOS and HomeManager
307307+### Example: A `nix` class that propagates settings to NixOS and HomeManager
241308242309This can be used when you don't want NixOS and HomeManager to share the
243310same pkgs but still configure both at the same time.
···265332den.aspects.tux.includes = [ nix-allowed ];
266333```
267334268268-#### Example: An impermanence class
335335+### Example: An impermanence class
269336270337> Suggested by @Doc-Steve
271338