Skip to content

Home-Manager Integration

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

Den automatically detects hosts that need Home-Manager. When a host has users with class = "homeManager" (the default), Den:

  1. Imports the Home-Manager NixOS/Darwin module
  2. Creates a homeManager class for each user
  3. Forwards homeManager configs into home-manager.users.<name>

No explicit opt-in needed — just declare users.

graph LR
  Host["{host}"] -->|"hm-detect"| Check{"class ∈ nixos,darwin?<br/>HM users exist?<br/>HM module available?"}
  Check -->|"yes"| HM["ctx.hm-host<br/>imports HM module"]
  HM -->|"per user"| FW["forward homeManager<br/>→ home-manager.users.‹name›"]
  Check -->|"no"| Skip["HM pipeline skipped"]
den.hosts.x86_64-linux.igloo.users.tux = { };
den.default.homeManager.home.stateVersion = "25.11";
den.aspects.tux.homeManager.programs.vim.enable = true;

The vim config is forwarded into igloo.home-manager.users.tux.

For Home-Manager without an OS host:

den.homes.aarch64-darwin.vic = { };
den.default.homeManager.home.stateVersion = "25.11";
den.aspects.vic.homeManager.programs.fish.enable = true;

Build with home-manager switch --flake .#vic.

Use den._.define-user to automatically set username and home directory:

den.default.includes = [ den._.define-user ];

This sets home.username, home.homeDirectory, and users.users.<name> on both NixOS and Darwin.

Configure Home-Manager to use the host’s nixpkgs:

den.ctx.hm-host.nixos.home-manager.useGlobalPkgs = true;

This only activates for hosts that actually have Home-Manager users. Hosts without users are unaffected.

Override the Home-Manager module source:

den.hosts.x86_64-linux.igloo = {
hm-module = inputs.home-manager-unstable.nixosModules.home-manager;
users.tux = { };
};

Access NixOS config from standalone Home-Manager:

den.homes.x86_64-linux.pingu = {
instantiate = { pkgs, modules }:
inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs modules;
extraSpecialArgs.osConfig =
config.flake.nixosConfigurations.igloo.config;
};
};
den.aspects.pingu.homeManager = { osConfig, ... }: {
programs.emacs.enable = osConfig.programs.vim.enable;
};

Use den.ctx.hm-host to configure things only when HM is active:

den.ctx.hm-host.nixos.home-manager.useGlobalPkgs = true;
den.ctx.hm-host.includes = [
{ nixos.home-manager.backupFileExtension = "bak"; }
];

These only apply to hosts that have Home-Manager users with a supported OS (NixOS or Darwin).