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

Update custom-classes.mdx

authored by oeiuwq.com and committed by

GitHub 6b33935f cc056939

+29
+29
docs/src/content/docs/guides/custom-classes.mdx
··· 177 177 # included at users who can fix things with nix. 178 178 den.aspects.tux.includes = [ nix-allowed ]; 179 179 ``` 180 + 181 + #### Example: An impermanence class 182 + 183 + The following example, creates a forwarding class that is propagated only 184 + when `environment.persistance` option is available in the host (the impermanence module was imported in host) 185 + 186 + One cool thing about these custom classes is that aspects can simply define 187 + settings at the new class, without having to worry if the options they depend or 188 + some capability is enabled. 189 + 190 + The froward-guard itself is reponsible checking in only one place, instead of having `mkIf` in a lot of places. 191 + 192 + ```nix 193 + # Custom `persys` forwards config into nixos.environment.persistance."/nix/persist/system" 194 + # only if environment.persistance option is present. 195 + persys = { class, aspect-chain }: den._.forward { 196 + each = lib.singleton true; 197 + fromClass = _: "persys"; 198 + intoClass = _: class; 199 + intoPath = _: [ "environment" "persistance" "/nix/persist/system" ]; 200 + fromAspect = _: lib.head aspect-chain; 201 + guard = { options, ... }@osArgs: options ? environment.persistance; 202 + }; 203 + 204 + den.hosts.my-laptop.includes = [ persys ]; 205 + 206 + # becomes nixos.environment.persistance."/nix/persist/system".hideMounts = true; 207 + den.aspects.my-laptop.persys.hideMounts = true; 208 + ```