what is it?

a system for managing a user environment using the nix package manager. lets you

  • install software declaratively in home directory of user
  • manage dotfiles in home directory of user

installation

can be installed 2 ways

  • standalone
    • only choice for platforms other than NixOS and Darwin
    • when installed on NixOS, allows for independent management of the home directory to the system
  • module within NixOS system configuration

home manager can also be installed with channels or with flakes

standalone installation

using flakes with the unstable version of nixpkgs

nix run home-manager/master -- init --switch

for nixpks version 24.05

nix run home-manager/release-24.05 -- init --switch

this will generate a flake.nix and a home.nix file in ~/.config/home-manager, creating the directory if it does not exist.

if you omit the —switch option then the activation will not happen. this is useful if you want to inspect and edit the configuration before activating it

after activation, rebuilding and activating the home manager configuration is done by

home-manager switch

using an existing config

if you already have a nix config in a repo, and don’t want to have the default config above created

configuration with flakes

# cd into wherever your config lives
cd ~/src/nixos-config
# run a shell so that you can use home manager
nix shell nixpkgs#home-manager
# run home manager with the flake config
home-manager switch --flake .

home manager is pretty good with most dotfiles config. if switching shells (e.g. from bash to zsh) however, you’ll have to manually choose a new one

echo ~/.nix-profile/bin/zsh | sudo tee -a /etc/shells
sudo usermod -s ~/.nix-profile/bin/zsh $USER