Add input to flake.nix
:
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
Add the module to modules
list of nixosSystem
calls:
inputs.home-manager.nixosModules.home-manager
{
home-manager.sharedModules = [
<<home-manager-modules>>
];
}
Use the same package set and nixpkgs options (e.g. allowUnfree
) as NixOS. Also use the user packages profile of NixOS:
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
}
Make home-manager output show-up in result
of nixos-rebuild --build
{ lib, config, ... }:
{
system.extraSystemBuilderCmds = ''
mkdir -p $out/home-manager
${lib.concatStringsSep "\n" (
map (cfg: "ln -sn ${cfg.home.activationPackage} $out/home-manager/${cfg.home.username}") (
lib.attrValues config.home-manager.users
)
)}
'';
}
{
home.stateVersion = "24.11";
}