LinuxCommandLibrary

home-manager

nix-based tool for managing user environment configuration declaratively

TLDR

Apply home configuration from default location

$ home-manager switch
copy
Apply a specific flake configuration
$ home-manager switch --flake [.#username]
copy
Build without activating
$ home-manager build
copy
List generations (configuration history)
$ home-manager generations
copy
Rollback to previous generation
$ home-manager rollback
copy
Remove old generations
$ home-manager expire-generations "[30 days ago]"
copy
Edit configuration file
$ home-manager edit
copy
Show news about configuration changes
$ home-manager news
copy

SYNOPSIS

home-manager [options] command [args]

DESCRIPTION

home-manager is a Nix-based tool for managing user environment configuration declaratively. It handles dotfiles, user packages, and environment settings through Nix expressions, enabling reproducible and versionable home directory setups.
Configuration is written in Nix language, typically in ~/.config/home-manager/home.nix or as part of a Nix flake. The configuration declares packages to install, programs to configure, files to manage, and services to run.
Many programs have dedicated Home Manager modules that generate configuration files automatically. For example, configuring programs.git generates ~/.gitconfig with proper syntax. This is more maintainable than managing dotfiles manually.
Generations provide configuration history. Each switch creates a new generation, and you can roll back to any previous state. This makes experimentation safe - broken configurations can be reverted instantly.
Home Manager can run standalone or integrate with NixOS. In standalone mode, it manages the user environment independently. With NixOS, it can be imported as a module for tighter integration.

PARAMETERS

switch

Build and activate new configuration.
build
Build configuration without activating.
generations
List all configuration generations.
rollback
Revert to previous generation.
expire-generations period
Remove generations older than period.
remove-generations IDs
Remove specific generations by ID.
edit
Open configuration in $EDITOR.
news
Show news entries about configuration.
packages
List installed packages.
option name
Show value of configuration option.
--flake flake-uri
Use flake-based configuration.
-f, --file file
Configuration file path.
-A attribute
Attribute to build from configuration.
-n, --dry-run
Show what would be done without doing it.
-v, --verbose
Increase verbosity.

CAVEATS

Requires Nix package manager. Learning curve for Nix language. Some program configurations may conflict with manually managed dotfiles. Flake-based configs need experimental features enabled. Generation management requires manual cleanup to prevent disk usage growth.

HISTORY

Home Manager was created by Robert Helgesson (rycee) around 2017 to bring NixOS's declarative configuration approach to user home directories. It filled a gap for users who wanted Nix's reproducibility for their personal environment without running NixOS. The project has grown to include modules for hundreds of programs.

SEE ALSO

nix(1), nix-env(1), nixos-rebuild(8), chezmoi(1), stow(8)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community