Skip to content

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, or den.schema.<kind>.includes.
  • Auto-activated — Den activates them via built-in policies. They define new classes or integration layers that work without explicit inclusion.

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 ];

Sets the system hostname from den.hosts.<name>.hostName. Works on NixOS and Darwin.

Opt-in.

den.default.includes = [ den.provides.hostname ];

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";
};

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" ];
};

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 ];

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")
];

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 host
den.aspects.tux.provides.igloo.nixos.programs.emacs.enable = true;
# host provides to all its users
den.aspects.igloo.provides.to-users = { user, ... }: {
homeManager.programs.helix.enable = true;
};

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 ];

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")
];

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;

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;
};

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 host
den.schema.host.includes = [
(den.provides.import-tree._.host ./hosts)
];
# Import per user
den.schema.user.includes = [
(den.provides.import-tree._.user ./users)
];
# Import for a specific aspect
den.aspects.laptop.includes = [
(den.provides.import-tree ./disko)
];

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;
};

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 ];
};

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;
};

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" ])
];

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" ])
];

These batteries require flake-parts as the module system.

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' ];

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' ];

Apply batteries to all hosts, users, and homes:

den.default.includes = [
den.provides.define-user
den.provides.hostname
den.provides.inputs'
];

Apply batteries to specific aspects:

den.aspects.alice.includes = [
den.provides.primary-user
(den.provides.user-shell "zsh")
(den.provides.unfree [ "vscode" ])
];

Apply batteries to all entities of a kind:

den.schema.user.includes = [
den._.mutual-provider
];

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; }
];
};
Contribute Community Sponsor