Home-manager useUserPackages useGlobalPkgs settings

Hah, just spotted two infoboxes in the manual that explain the options: https://nix-community.github.io/home-manager/index.html#sec-install-nixos-module

By default packages will be installed to $HOME/.nix-profile but they can be installed to /etc/profiles if

home-manager.useUserPackages = true;

is added to the system configuration. This is necessary if, for example, you wish to use nixos-rebuild build-vm. This option may become the default value in the future.

Fair enough, wonder why it’s necessary in that case, but I guess the user profiles don’t exist under all NixOS build targets. According to the manual this can cause breakage if your env setup scripts were written manually because it changes the path to source for the home env.

By default, Home Manager uses a private pkgs instance that is configured via the home-manager.users..nixpkgs options. To instead use the global pkgs that is configured via the system level nixpkgs options, set

home-manager.useGlobalPkgs = true;

This saves an extra Nixpkgs evaluation, adds consistency, and removes the dependency on NIX_PATH, which is otherwise used for importing Nixpkgs.

So pretty much what I said; however, I’m pretty sure since NixOS 20.09 the second paragraph no longer holds. Otherwise flakes wouldn’t work.

4 Likes