Batteries Reference
import { Aside } from ‘@astrojs/starlight/components’;
Overview
Section titled “Overview”Batteries are pre-built aspects at den.provides (accessed via den._.<name>).
All are opt-in — include them explicitly where needed.
define-user
Section titled “define-user”Defines a user at OS and Home-Manager levels. (source)
den.default.includes = [ den._.define-user ];Sets:
users.users.<name>.{name, home, isNormalUser}(NixOS)users.users.<name>.{name, home}(Darwin)home.{username, homeDirectory}(Home-Manager)
Contexts: { host, user }, { home }
primary-user
Section titled “primary-user”Makes a user an administrator. (source)
den.aspects.vic.includes = [ den._.primary-user ];Sets:
- NixOS:
users.users.<name>.extraGroups = [ "wheel" "networkmanager" ] - Darwin:
system.primaryUser = <name> - WSL:
wsl.defaultUser = <name>(if host haswslattribute)
Context: { host, user }
user-shell
Section titled “user-shell”Sets default shell at OS and HM levels. (source)
den.aspects.vic.includes = [ (den._.user-shell "fish") ];Sets:
programs.<shell>.enable = true(NixOS/Darwin)users.users.<name>.shell = pkgs.<shell>(NixOS/Darwin)programs.<shell>.enable = true(Home-Manager)
Contexts: { host, user }, { home }
unfree
Section titled “unfree”Enables unfree packages by name. (source · predicate)
den.aspects.laptop.includes = [ (den._.unfree [ "discord" ]) ];Sets: unfree.packages option + nixpkgs.config.allowUnfreePredicate
Contexts: All (host, user, home) — works for any class.
tty-autologin
Section titled “tty-autologin”Automatic tty login.
den.aspects.laptop.includes = [ (den._.tty-autologin "root") ];Sets: systemd.services."getty@tty1" with autologin.
Class: NixOS only.
import-tree
Section titled “import-tree”Auto-imports non-dendritic Nix files by class directory. (source)
den.aspects.laptop.includes = [ (den._.import-tree ./path) ];Looks for ./path/_nixos/, ./path/_darwin/, ./path/_homeManager/.
Helpers:
den._.import-tree._.host ./hosts # per host: ./hosts/<name>/_<class>den._.import-tree._.user ./users # per user: ./users/<name>/_<class>den._.import-tree._.home ./homes # per home: ./homes/<name>/_<class>Requires: inputs.import-tree
inputs’ (flake-parts)
Section titled “inputs’ (flake-parts)”Provides per-system inputs' as a module argument.
den.default.includes = [ den._.inputs' ];Requires: flake-parts with withSystem.
self’ (flake-parts)
Section titled “self’ (flake-parts)”Provides per-system self' as a module argument.
den.default.includes = [ den._.self' ];Requires: flake-parts with withSystem.
forward
Section titled “forward”Creates custom Nix classes by forwarding configs between classes. (source · usage guide)
den._.forward { each = lib.singleton class; fromClass = _: "source"; intoClass = _: "nixos"; intoPath = _: [ "target" "path" ]; fromAspect = _: sourceAspect;}Returns an aspect. Used internally for Home-Manager integration.
home-manager
Section titled “home-manager”HM integration is handled by
den.ctx.hm-host and den.ctx.hm-user context types, which are
activated automatically when hosts have HM users.
All homeManager class settings are forwarded to os-level home-manager.users.<userName>.
The user class is automatically handled by Den and forwards to os-level users.users.<userName>
You can write:
den.aspects.tux.user.description = "bird";
# same as setting at host:den.aspects.igloo.nixos.users.users.tux.description = "bird";