Skip to content

Declare Hosts & Users

den.hosts is keyed by <system>.<name>:

{
den.hosts.x86_64-linux.laptop.users.alice = { };
den.hosts.aarch64-darwin.mac = {
users.alice = { };
brew.apps = [ "iterm2" ];
};
}

Each host entry produces a configuration in flake.nixosConfigurations or flake.darwinConfigurations depending on its class (auto-detected from the host platform).

Hosts have these options (all with sensible defaults):

OptionDefaultDescription
nameattrset keyConfiguration name
hostNamenameNetwork hostname
systemparent keyx86_64-linux, aarch64-darwin, etc.
class"nixos" or "darwin"OS class, auto-detected from system
aspectnamePrimary aspect name
instantiateclass-dependentlib.nixosSystem, darwinSystem, etc.
intoAttrclass-dependentFlake output path
users{}User account definitions
*from den.schema.hostAny option defined by base module
*Any other free-form attribute

Users are declared as part of a host:

den.hosts.x86_64-linux.laptop = {
users.alice = { };
users.bob.classes = [ "homeManager" "hjem" ];
};

Each user has:

OptionDefaultDescription
nameattrset keyUser configuration name
userNamenameSystem account name
aspectnamePrimary aspect name
classes[ "homeManager" ]Nix classes this user participates in
*from den.schema.userAny option defined by base module
*Any other free-form attribute

For systems without root access or for home-manager-only setups:

{
den.homes.x86_64-linux.alice = { };
den.homes.aarch64-darwin.alice = { };
}

Standalone homes produce flake.homeConfigurations.<name>.

Home schema:

OptionDefaultDescription
nameattrset keyHome configuration name
userNamenameUser account name
systemparent keyPlatform system
class"homeManager"Home class
aspectnamePrimary aspect name
pkgsinputs.nixpkgs.legacyPackages.${system}nixpkgs instance
instantiateinputs.home-manager.lib.homeManagerConfigurationBuilder function
*from den.schema.hostAny option defined by base module
*Any other free-form attribute

den.schema.{host,user,home} provides shared configuration applied to all entities of each kind.

Some batteries also extend base modules see home-env.nix that is used by home-manager/hjem/maid to extend the Host schema with options like hjem.module/home-manager.module.

Another more advanced examples is our templates/microvm that adds options related to running virtualized OS.

{
# Can be used to specify features of all host
den.schema.host.home-manager.enable = true;
# Can be used to add schema options with defaults
den.schema.user = { user, lib, ... }: {
options.groupName = lib.mkOption { default = user.userName; };
};
# Applied to every host and user and home.
den.schema.conf = {
options.copyright = lib.mkOption { default = "Copy-Left"; };
};
}

Host and user types use freeformType, so you can add arbitrary attributes:

den.hosts.x86_64-linux.laptop = {
users.alice = { };
gpu = "nvidia"; # custom attribute, accessible in aspects via host.gpu
};

Access custom attributes in aspects:

den.aspects.laptop.includes = [
({ host, ... }: lib.optionalAttrs (host ? gpu) {
nixos.hardware.nvidia.enable = true;
})
];
Contribute Community Sponsor