Batteries
Den ships reusable aspect providers under den.provides (aliased den._).
Each battery contributes NixOS/Darwin/home-manager modules to hosts and
users that include them.
Batteries fall into two categories:
- Opt-in — you include them explicitly in
den.default.includes,den.aspects.<name>.includes, orden.schema.<kind>.includes. - Auto-activated — Den activates them via built-in policies. They define new classes or integration layers that work without explicit inclusion.
System
Section titled “System”den._.define-user
Section titled “den._.define-user”Creates OS-level user accounts (users.users.<name>) with isNormalUser and home directory. Also sets home.username and home.homeDirectory for Home Manager. Works on NixOS, Darwin, and standalone Home Manager.
Opt-in.
den.default.includes = [ den.provides.define-user ];den._.hostname
Section titled “den._.hostname”Sets the system hostname from den.hosts.<name>.hostName. Works on NixOS and Darwin.
Opt-in.
den.default.includes = [ den.provides.hostname ];den._.os-class
Section titled “den._.os-class”Provides an os convenience class that forwards its contents into both nixos and darwin classes. This lets you write platform-agnostic host configuration without duplicating it across classes.
Auto-activated for both host and user entity kinds.
den.aspects.my-host = { os.networking.hostName = "foo";};den._.os-user
Section titled “den._.os-user”Provides a user class that forwards settings into the host’s users.users.<userName> at OS level. Instead of writing the full nixos.users.users.alice path, you write directly into the user class.
Auto-activated for the user entity kind.
den.aspects.alice.user = { pkgs, ... }: { packages = [ pkgs.hello ]; extraGroups = [ "wheel" ];};den._.primary-user
Section titled “den._.primary-user”Marks a user as the primary (admin-level) user. On NixOS, adds wheel and networkmanager groups. On Darwin, sets system.primaryUser. On WSL, sets defaultUser.
Opt-in.
den.aspects.alice.includes = [ den.provides.primary-user ];den._.user-shell
Section titled “den._.user-shell”Sets the user’s login shell at both OS and Home Manager levels. Enables programs.<shell>.enable and sets users.users.<name>.shell.
Opt-in. Takes a shell name as argument.
den.aspects.alice.includes = [ (den.provides.user-shell "fish")];den._.mutual-provider
Section titled “den._.mutual-provider”Allows hosts and users to contribute configuration to each other through the provides attribute. Users can provide to specific hosts or to all hosts they belong to, and vice versa.
Opt-in. Typically included for the user entity kind.
den.schema.user.includes = [ den._.mutual-provider ];Then in aspects:
# user provides to a specific hostden.aspects.tux.provides.igloo.nixos.programs.emacs.enable = true;
# host provides to all its usersden.aspects.igloo.provides.to-users = { user, ... }: { homeManager.programs.helix.enable = true;};den._.host-aspects
Section titled “den._.host-aspects”Projects user-relevant classes (like homeManager) from the host’s aspect tree onto users who opt in. Any homeManager key defined in the host aspect is forwarded to the user’s home-manager evaluation.
Opt-in.
den.aspects.tux.includes = [ den._.host-aspects ];den._.tty-autologin
Section titled “den._.tty-autologin”Configures automatic TTY1 login on NixOS via a systemd getty override. NixOS only.
Opt-in. Takes a username as argument.
den.aspects.laptop.includes = [ (den.provides.tty-autologin "alice")];den._.wsl
Section titled “den._.wsl”Enables WSL support on NixOS using the NixOS-WSL project. Adds a wsl-host entity kind and forwards the wsl class into the host’s NixOS configuration.
Auto-activated when host.wsl.enable = true. Requires inputs.nixos-wsl.
den.hosts.x86_64-linux.igloo.wsl.enable = true;den._.forward
Section titled “den._.forward”A generic forwarding primitive that creates custom Nix classes by routing module contents from one class into a target submodule path. This is how os-user, homeManager, hjem, and maid integrations are implemented internally.
Opt-in. Used when building custom classes. See the Custom Classes guide.
den.provides.forward { each = lib.singleton user; fromClass = _: "myClass"; intoClass = _: host.class; intoPath = _: [ "some" "path" ]; fromAspect = _: user.aspect;};den._.import-tree
Section titled “den._.import-tree”Recursively imports non-dendritic .nix files, auto-detecting class from directory name conventions (_nixos/, _darwin/, _homeManager/). Useful for migrating existing configurations.
Opt-in. Requires inputs.import-tree.
# Import per hostden.schema.host.includes = [ (den.provides.import-tree._.host ./hosts)];
# Import per userden.schema.user.includes = [ (den.provides.import-tree._.user ./users)];
# Import for a specific aspectden.aspects.laptop.includes = [ (den.provides.import-tree ./disko)];Home Environments
Section titled “Home Environments”den._.home-manager
Section titled “den._.home-manager”Integrates home-manager as a user environment class. Defines the hm-host entity kind, imports the appropriate home-manager NixOS or Darwin module, and merges home-manager.users.<name> from each user’s homeManager class.
Auto-activated when users have homeManager classes. Requires inputs.home-manager.
den.aspects.alice.homeManager = { programs.git.enable = true;};den._.hjem
Section titled “den._.hjem”Integrates hjem as an alternative home environment. Imports hjem’s NixOS or Darwin module and merges hjem.users.<name> from each user’s hjem class.
Auto-activated when users have hjem classes. Requires inputs.hjem.
den.aspects.alice.hjem = { packages = [ pkgs.ripgrep ];};den._.maid
Section titled “den._.maid”Integrates maid as an alternative home environment. NixOS only. Merges configuration into users.users.<name>.maid for each user’s maid class.
Auto-activated when users have maid classes. Requires inputs.nix-maid.
den.aspects.alice.maid = { programs.helix.enable = true;};Package Management
Section titled “Package Management”den._.unfree
Section titled “den._.unfree”Allows specific unfree packages by name via nixpkgs.config.allowUnfreePredicate. Works for any class (nixos, darwin, homeManager). The predicate builder is automatically included in den.default.
Opt-in. Takes a list of package names as argument.
den.aspects.laptop.includes = [ (den.provides.unfree [ "nvidia-x11" "steam" ])];den._.insecure
Section titled “den._.insecure”Allows specific insecure packages by name and version via nixpkgs.config.permittedInsecurePackages. Works for any class (nixos, darwin, homeManager). The predicate builder is automatically included in den.default.
Opt-in. Takes a list of package name-version strings as argument.
den.aspects.laptop.includes = [ (den.provides.insecure [ "openssl-1.1.1w" ])];Flake-parts
Section titled “Flake-parts”These batteries require flake-parts as the module system.
den._.inputs'
Section titled “den._.inputs'”Provides inputs' (the flake’s inputs with system pre-selected) as a top-level module argument. Contextual: configures the appropriate class depending on whether it is included in a host, user, or home aspect.
Opt-in.
den.default.includes = [ den.provides.inputs' ];den._.self'
Section titled “den._.self'”Provides self' (the flake’s self outputs with system pre-selected) as a top-level module argument. Contextual: configures the appropriate class depending on whether it is included in a host, user, or home aspect.
Opt-in.
den.default.includes = [ den.provides.self' ];Usage Patterns
Section titled “Usage Patterns”Global defaults
Section titled “Global defaults”Apply batteries to all hosts, users, and homes:
den.default.includes = [ den.provides.define-user den.provides.hostname den.provides.inputs'];Per-aspect inclusion
Section titled “Per-aspect inclusion”Apply batteries to specific aspects:
den.aspects.alice.includes = [ den.provides.primary-user (den.provides.user-shell "zsh") (den.provides.unfree [ "vscode" ])];Per-entity-kind inclusion
Section titled “Per-entity-kind inclusion”Apply batteries to all entities of a kind:
den.schema.user.includes = [ den._.mutual-provider];Composing batteries with configuration
Section titled “Composing batteries with configuration”Batteries compose freely with inline configuration:
# den.lib.parametric is deprecated — bare attrsets work directly:den.aspects.my-admin = { includes = [ den.provides.primary-user (den.provides.user-shell "fish") { nixos.security.sudo.wheelNeedsPassword = false; } ];};