I am trying to rebuild/(install?) home-manager in macOS but am encoutering the error in the subject of this post (detailed below).
How I broke home-manager: I changed my home-manager flake.nix by moving the home-manager config from home.nix into the flake within modules (you can see the commented out reference to home.nix in my flake below), which built via:
home-manager switch --flake .
without any visible errors, but now I can nolonger use home-manager from the cli - the command is no longer found by zsh.
Before building, I removed home.nix and flake.nix from git and added the updated flake.nix,
Now, rightly or wrongly(?), I am trying to rebuild/install(?) home-manager via:
warning: Git tree '/Users/me/.config/nixpkgs' is dirty
error: flake 'git+file:///Users/me/.config/nixpkgs' does not provide attribute 'packages.x86_64-darwin.homeManagerConfigurations.me.activationPackage', 'legacyPackages.x86_64-darwin.homeManagerConfigurations.me.activationPackage' or 'homeManagerConfigurations.me.activationPackage'
I can still nolonger use home-manager from the cli, which I guess is because I have removed the above line?
I am trying to move it around within the homeConfigurations and modules blocks but so far am getting the following error when building with it in any of those blocks:
This suggests you probably put it outside the modules section.
Your indentation threw me the first time I looked at this, but this is wrong. You’re setting home.programs.home-manager.enable, which is a non-existent option. You need to move that setting outside the home = { block.
I have again learned from you, but after moving programs.home-manager.enable = true; outside the home = { block, and the flake being built, I am still having no joy getting home-manager to run as a command from zsh (after originally having it working as described above).
Here is where I put programs.home-manager.enable = true; - the only place where nix would allow the flake to be built:
in {
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.${system};
modules = [
{
home = {
inherit username;
homeDirectory = "/Users/${username}";
stateVersion = "22.11";
};
}
# ./home.nix
];
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
};
programs.home-manager.enable = true;
};
Side question: If this is the correct place (I’m guessing not because home-manager command is still not available in the cli) - is this where I would add the following if not putting them in separate modules (like home.nix, emacs.nix, etc)?
That builds, but I am still not able to use the home-manager command from the cli, which (obviously) means I cannot use home-manager switch to rebuild the flake after modifying it eg adding a module/program.
Any thoughts on how to debug this and what could be wrong with my setup eg a path issue?
All I can find (so far) to debug is:
nix flake show
that returns:
warning: Git tree '/Users/me/.config/nixpkgs' is dirty
git+file:///Users/me/.config/nixpkgs
└───homeConfigurations: unknown
and unknown appears to be normal (not an error) due to the experimental status of flakes.