home-manager modes — standalone vs NixOS module#
home-manager has two deployment modes and they feel very different in day-to-day use. Choosing the right one for a given host is worth getting right once, because changing modes later involves small-but-real migration work.
This page exists because both modes are used interchangeably across the rest of the chapter and the distinction is rarely made explicit. Short version:
Standalone — home-manager is its own tool with its own CLI (
home-manager switch). Good when the host is not NixOS: Kali, Debian, WSL2-Debian. Also fine as a first step on NixOS.As a NixOS module — home-manager becomes part of the NixOS system build.
nixos-rebuild switchrebuilds the whole thing — system plus every user’s home config — atomically, in one closure. The canonical choice once the host is NixOS and you are managing it as a single-user (or known-users) machine.
In this page#
Standalone mode#
The mode that works on any Linux, NixOS or not. home-manager is a thin CLI that:
Evaluates
~/.config/home-manager/home.nix(or your flake’shomeConfigurations.<name>).Builds a user-profile closure.
Swaps symlinks in your
$HOMEto point at the new closure.Writes a generation record under
~/.local/state/nix/profiles/home-manager-*.
Install (classic)#
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update
nix-shell '<home-manager>' -A install
Install (flakes)#
# ~/.config/home-manager/flake.nix
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.home-manager.url = "github:nix-community/home-manager";
inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs";
outputs = { nixpkgs, home-manager, ... }:
let system = "x86_64-linux"; in {
homeConfigurations."alice" = home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs { inherit system; config.allowUnfree = true; };
modules = [ ./home.nix ];
};
};
}
The home.nix is self-contained#
{ config, pkgs, ... }:
{
home.username = "alice";
home.homeDirectory = "/home/alice";
home.stateVersion = "24.11";
# On non-NixOS hosts — critical for GUI integration:
targets.genericLinux.enable = true;
programs.home-manager.enable = true;
programs.fish.enable = true;
home.packages = with pkgs; [ ripgrep fd bat eza ];
}
Switch#
home-manager switch # classic
home-manager switch --flake ~/nixos-config#alice # flakes
Generations:
home-manager generations
/nix/store/<hash>-home-manager-generation/activate # jump to a prior one
Pros#
Works on any Linux. This is the only mode available on Debian/Kali/WSL2.
User-owned — no root. Nothing the user does touches
/etcor/run/current-system.Independent update cadence. System and user can be updated at different times, with different input revisions.
Portable across hosts. The exact same
home.nixworks on Kali, on a NixOS VM, and inside WSL2 — no host-shape assumptions.
Cons#
Two tools to know —
nixos-rebuildfor the system,home-managerfor the user.Two profiles to roll back. Rolling back the system without rolling back home-manager can leave them at inconsistent input revisions.
Duplicated evaluation. Nix evaluates nixpkgs twice — once for the system build, once for home-manager. Slightly slower, and the two evaluations can import different revisions of nixpkgs if you’re not careful.
NixOS module mode#
On a NixOS host, home-manager can be imported as a module and becomes part of the system build. One command (nixos-rebuild switch), one closure, one rollback unit.
Classic#
/etc/nixos/configuration.nix:
{ config, pkgs, ... }:
{
imports = [
./hardware-configuration.nix
<home-manager/nixos>
];
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.alice = import ./home.nix;
}
The <home-manager/nixos> path requires a home-manager nix-channel, added once:
sudo nix-channel --add https://github.com/nix-community/home-manager/archive/release-24.11.tar.gz home-manager
sudo nix-channel --update
Flakes#
The more common modern setup. In your flake:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
home-manager = {
url = "github:nix-community/home-manager/release-24.11";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, home-manager, ... }: {
nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.alice = import ./home.nix;
}
];
};
};
}
inputs.nixpkgs.follows = "nixpkgs" is the key line — it forces home-manager to use the same nixpkgs as the system, eliminating the duplicated-evaluation concern.
Activate — no separate CLI#
sudo nixos-rebuild switch --flake /etc/nixos#myhost
The same command that builds and activates the system also builds and activates every user’s home-manager closure.
Pros#
Single source of truth. One file, one rebuild, one rollback. Generation
Nof the system contains generationNof every user’s home.Shared
pkgs. WithuseGlobalPkgs = true, home-manager imports nixpkgs exactly once with the system’s overlays and config — no duplication, no drift.User packages go system-wide. With
useUserPackages = true, each user’shome.packagesis installed into the system closure viausers.users.<name>.packages, so they’re visible in login-shellPATHeven before home-manager’s session hooks have run.Declarative everywhere. No “remember to also run
home-manager switch” after a reboot.
Cons#
NixOS-only. Cannot be used on Kali, Debian, or WSL2-with-Debian.
Single bootloader transaction. If the build fails because of a user-level mistake (a broken
home.nix),nixos-rebuild switchfails as a whole — you don’t get the system changes without the home ones.Harder to work on a user’s config without touching root. Every
switchrequiressudo. Partial workaround:nixos-rebuild buildas a normal user, inspect./result, thensudo nixos-rebuild switchwhen happy.
Side-by-side comparison#
Concern |
Standalone |
NixOS module |
|---|---|---|
Works on non-NixOS? |
✅ (Kali, Debian, WSL2, Arch, …) |
❌ |
Needs |
Never |
Always for switch |
Rebuild command |
|
|
Atomicity with system |
Independent |
One atomic closure |
|
Required on non-NixOS |
N/A (system handles XDG paths) |
|
Duplicated unless you share |
Shared via |
Generation rollback |
|
Bootloader menu (system + home as one) |
Packages on PATH at login |
Via |
Via |
First-party in nixpkgs options |
No (home-manager has its own option index) |
Yes, under |
Which to use where#
Mapping to the six venues from getting-started.md:
Venue |
Host |
Mode |
|---|---|---|
WSL2 + Nix on Debian/Ubuntu |
Windows |
Standalone only. (Host is not NixOS.) |
NixOS-WSL |
Windows |
Either works; standalone if you are iterating on |
VirtualBox NixOS VM |
Windows |
NixOS module is natural — your flake already declares the VM as a |
Nix / home-manager on Kali |
Kali |
Standalone only. |
libvirt/QEMU NixOS VM on Kali |
Kali |
NixOS module — same reasoning as VirtualBox. |
NixOS on an external SSD |
Either |
NixOS module. This is a real system; treat it like one. |
The practical rule: use standalone where you have to (Kali, WSL2-Debian), module where you can (any real NixOS). Keep the same home.nix file across both — the module mode wraps the standalone home.nix without rewriting.
Migrating between modes#
The file you care about — home.nix — is the same in both modes. The migration work is entirely about how you invoke the build.
Standalone → NixOS module#
Assuming you already have home.nix working standalone on a NixOS host:
Add
home-manager.nixosModules.home-managerto your flake’smodules = [ ... ]list.Add these three lines to
configuration.nix:home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.users.alice = import ./home.nix;
sudo nixos-rebuild switch --flake /etc/nixos#myhost. It will build and activate home-manager inside the system closure.Optional: uninstall the standalone CLI to avoid confusion —
nix-env -e home-manageror remove it from your user profile. Thehome-managerbinary will still be on the system PATH because the NixOS module installs it; the difference is that you usenixos-rebuild, nothome-manager, as the entry point.
NixOS module → standalone#
The rare direction. Typical reason: you want to iterate on home.nix faster than a full nixos-rebuild allows.
Remove the three
home-manager.*lines fromconfiguration.nix(or.users.aliceto leave other users intact).Rebuild system:
sudo nixos-rebuild switch --flake /etc/nixos#myhost. The previous home-manager generation is still on disk but no longer the “current”.Install the standalone CLI and point it at your
home.nix:nix run home-manager/master -- switch --flake ~/nixos-config#alice
From now on,
home-manager switch --flake ~/nixos-config#aliceis your per-user update command;nixos-rebuild switchhandles system-only.
The stateVersion gotcha#
home.stateVersion and system.stateVersion are separate options with unrelated semantics. Both exist to pin state defaults that change between releases; do not cross-pollinate them.
system.stateVersion = "24.11";— lives inconfiguration.nix. Pins NixOS state semantics. Bump intentionally, rarely.home.stateVersion = "24.11";— lives inhome.nix. Pins home-manager state semantics. Bump intentionally, rarely.
They can be different values on the same machine. A common layout: system.stateVersion = "23.11"; (the release you installed two years ago), home.stateVersion = "24.11"; (the release when you last migrated home-manager state). Nothing bad happens.
See also#
getting-started.md — Level 2a; where home-manager first appears.
kali-to-nixos.md — the standalone mode in practice on Kali.
configuration.md — the one-line pointer in the system-config anchor page.
multi-host-flake.md — how
homeConfigurationsvshome-manager.users.*compose across hosts.home-manager option index — authoritative list of every
programs.*/home.*option.