···78## Den as a Library
910-Den's core (`nix/lib.nix`) is domain-agnostic. It provides:
1112| Function | Purpose |
13|---|---|
···2829## Using Den for Non-OS Domains
30000031Nothing about `den.lib` assumes NixOS, Darwin, or Home Manager. You can build
32context pipelines for any Nix module system:
3334```nix
35-{ my-aspects, den, ... }: {
36-37- # create a private isolated aspect namespace independent of den.aspects
38- imports = [ (den.namespace "my-aspects" false) ];
3940- # Define aspects for a custom domain
41- my-aspects = {
42- web-server = den.lib.parametric {
43- terranix.resource.aws_instance.web = { ami = "..."; };
44- includes = [
45- # configures using the terranix Nix class
46- ({ env, ... }: { terranix.resource.aws_instance.web.tags.Env = env; })
47- ];
48- };
49 };
05051- # Resolve for your custom class
52- aspect = my-aspects.web-server { env = "production"; };
53- module = aspect.resolve { class = "terranix"; };
54-}
55```
5657## Den as a Framework
···78## Den as a Library
910+Den's core (`/default.nix`) is domain-agnostic. It provides:
1112| Function | Purpose |
13|---|---|
···2829## Using Den for Non-OS Domains
3031+<Aside title="Source" icon="github">
32+[default.nix](https://github.com/vic/den/tree/main/default.nix) - [CI test: den-as-lib.nix](https://github.com/vic/den/tree/main/templates/ci/modules/features/den-as-lib.nix)
33+</Aside>
34+35Nothing about `den.lib` assumes NixOS, Darwin, or Home Manager. You can build
36context pipelines for any Nix module system:
3738```nix
39+# see den-as-lib.nix CI test for working example
0004041+# Define aspects for a custom domain
42+den.aspects = {
43+ web-server = den.lib.parametric {
44+ terranix.resource.aws_instance.web = { ami = "..."; };
45+ includes = [
46+ # configures using the terranix Nix class
47+ ({ env, ... }: { terranix.resource.aws_instance.web.tags.Env = env; })
48+ ];
049 };
50+};
5152+# Resolve for your custom class
53+aspect = den.aspects.web-server { env = "production"; };
54+module = aspect.resolve { class = "terranix"; };
055```
5657## Den as a Framework