Skip to content

den.aspects Reference

import { Aside } from ‘@astrojs/starlight/components’;

Every aspect is an attribute set with these recognized keys:

AttributeTypeDescription
nixosmoduleNixOS configuration module
darwinmodulenix-darwin configuration module
homeManagermoduleHome-Manager configuration module
<class>moduleAny custom Nix class
includeslistDependencies on other aspects or functions
providesattrsetNested sub-aspects
_aliasShorthand for provides
descriptionstrHuman-readable description
__functorfunctionContext-aware behavior

Den creates an aspect for each host, user, and home you declare:

den.hosts.x86_64-linux.igloo.users.tux = { };
# Creates: den.aspects.igloo and den.aspects.tux

Aspects are created with parametric { <class> = {}; } functor matching the entity’s class.

To extract a class module from an aspect:

module = aspect.resolve { class = "nixos"; aspect-chain = []; };

Resolution collects the specified class from the aspect and all transitive includes into a single merged Nix module.

options.den.aspects = lib.mkOption {
type = aspectsType;
default = { };
};

Contributions from any module are merged:

file1.nix
den.aspects.igloo.nixos.networking.hostName = "igloo";
# file2.nix
den.aspects.igloo.homeManager.programs.vim.enable = true;
options.den.provides = lib.mkOption {
type = lib.types.submodule {
freeformType = lib.types.attrsOf providerType;
};
};

Access via den._.name or den.provides.name. See Batteries Reference for all built-in aspects.

The global dispatcher aspect:

den.default = den.lib.parametric.atLeast { };

All hosts, users, and homes include den.default. Set global configs and shared parametric includes here.

Aliased from den.ctx.default.

den.aspects.igloo.includes = [
# another aspect
den.aspects.gaming
# nested provides
den.aspects.tools._.editors
# static config
{ homeManager.programs.direnv.enable = true; }
# context function
({ host, ... }: { nixos.time.timeZone = "UTC"; })
# battery
den._.define-user
# battery with args
(den._.user-shell "fish")
(den._.unfree [ "discord" ])
];

den is available as a module argument in all Den modules:

{ den, ... }: {
den.aspects.foo = den.lib.parametric { ... };
}