Nixos HM generic image

NixOS is a Linux distribution that is built around the Nix package manager. More information is in my previous post(s). This post is about the way I added home-manager to my (modular) Nixos configuration.

Including home-manager Link to heading

First home-manager needs to be added to the normal Nixos configuration. This can be done by adding just a few lines of code. See how to do this in the example below:

{ config, pkgs, ... }:

  home-manager = builtins.fetchTarball "";
  imports =
    [ # Include the results of the hardware scan.





  # Home-manager profiles
  home-manager.users.patrick = import ./home/patrick-base-t14s.nix;



  • the lines between let and in at the top of the file,
  • the import line ("${home-manager}/nixos"), and
  • the added profile line (home-manager.users.patrick = ...).

Also notice that the home-manager profile actually imports a nix configuration. This nix configuration is specific per person (since it is the users personal home-manager setup) so each user can have this import line.

Home manager configuration Link to heading

The basic home-manager configuration file is personal per user. However, multiple users can share imports from within that personal configuration file.

For example, my personal home-manager configuration file looks as follows:

{ config, pkgs, lib, ... }:

  # Home Manager settings

  imports =

  # home-manager.useGlobalPkgs = true;  # Use the global pkgs that is configured via the system level nixpkgs options
  programs.home-manager.enable = true;  # Let Home Manager install and manage itself.

  home.username = "patrick";
  home.homeDirectory = "/home/patrick";

  # This value determines the Home Manager release that your
  # configuration is compatible with. This helps avoid breakage
  # when a new Home Manager release introduces backwards
  # incompatible changes.
  home.stateVersion = "22.11";

The home manager configuration is modularized in a similar fashion as my normal Nixos configuration. Therefore it shows files which are and are not prepaned with my username (patrick). Those with a username are for that user specifically.

Applying and updating the configuration Link to heading

This works in the same fashion as in my modular setup (see the previous blog post).