Hi! I am using Home Manager as a NixOS module.
Owing to the need to prepare a system with multiple users, I used home-manager.sharedModules extensively and exclusively. I now wish to enable Home Manager for everyone, such that programs.home-manager.enable is true for all normal users. I first made the following attempt:
{
# Attempt 0
home-manager.sharedModules = [
{ programs.home-manager.enable = true; }
];
}
The evaluation appeared to complete but, judging by the content of my home directory, the program was not enabled. I checked the manual and could not find any information there. I then looked at the source code and found these lines of interests, which prompted me to try the following:
{
# Attempt 1
home-manager.sharedModules = [
({ config, ... }: {
home.packages = [ config.programs.home-manager.package ];
})
];
}
Unfortunately, the result was more or less the same. I was confused as to why and wrote this:
{
# Attempt 2
environment.systemPackages = [
pkgs.home-manager
];
}
… which may not be my proudest attempt but prompted me to start browsing Noogle. After a while, I ended up with this:
{
# Attempt 3
home-manager.users = lib.listToAttrs (
lib.map (name: {
inherit name;
value.programs.home-manager.enable = true;
}) (lib.attrNames config.users.users)
);
}
But that resulted in an infinite recursion error, presumably due to the use of config.
I am now lost. I had incorrectly assumed in the beginning that this would be a trivial task. Perhaps I am doing something horribly wrong? Any insight on the matter would be well appreciated!
Output of nix-info
- system:
"x86_64-linux" - host os:
Linux 7.2.9-zen1, NixOS, 26.11 (Zokor), 26.11.20261010.6510408 - multi-user?:
yes - sandbox:
yes - version:
nix-env (Nix) 2.34.8 - nixpkgs:
/nix/store/ghasbyyjrmlg6sl7v04hiq8n57kcy9a9-source
Configuration for home-manager
{
imports = [
inputs.home-manager-stable.nixosModules.home-manager
];
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = { inherit inputs neolib os; };
backupCommand = "${pkgs.trash-cli}/bin/trash-put";
};
}