blueprint icon indicating copy to clipboard operation
blueprint copied to clipboard

Consider adding support for standalone home-manager configurations

Open adam-gaia opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

I have a home lab with multiple systems where one particular system does not run NixOS. I use home-manager to install user-level software on that device. Before using blueprint, I had a single flake that defined all the systems in my homelab and used home-manager.lib.homeManagerConfiguration {...} to create a standalone home-manager profile.

Describe the solution you'd like

I would like a blueprint flake to expose homeConfigurations.<name> in the flake outputs. These outputs would get picked up from a <repo>/homes* directory, in the same way hosts are picked up from the <repo>/hosts directory. e.g. <repo>/homes/agaia/home.nix would result in a flake output homeConfigurations.agaia for use with home-manager build --flake .#agaia

*Some bike shedding may need to happen. I don't know why, but calling the directory "homes" sounds a little awkward to me. "Home", singular, sounds better to me. At the end of the day, I don't really care what the directory is called though.

Describe alternatives you've considered

  • Using another flake without blueprint

adam-gaia avatar Aug 30 '24 22:08 adam-gaia

I gave it a shot at implementing this myself. I got close, but don't love how it turned out. See my notes on the PR #36.

I know I did the work before discussing and having this request accepted. I won't be upset if it doesn't get merged, I'm still learning nix and this was a great hands-on learning experience :)

adam-gaia avatar Aug 30 '24 23:08 adam-gaia

I've been thinking about this a little bit. Based on the way my config tends to be structured, I've ended up with each host having a "user" (though there may be more than one user in the future). These users (Home Manager configurations) all share a common base -- e.g. most of the packages that are installed -- but diverge on the specifics for different platforms.

My Mac mini uses nix-darwin, which in turn pulls in my Home Manager configuration. My MacBook Air config is a standalone HM config, because it's my partner's laptop :p Then there are the other configurations that aren't currently up to date but share the same structure (NixOS, NixOS on WSL, and standalone HM).

This is the structure that I'm going to play around with:

  • hosts/<machine>/{darwin-,}configuration.nix currently defines system configurations
  • hosts/<machine>/home/<username>.nix will be my standard location to define a home configuration for a user on a particular machine, and can optionally be used as a standalone home configuration
  • modules/home/<module>.nix currently defines Home Manager modules, which can be used for something like a common/shared configuration that each machine's HM config customizes

So my structure would look something like:

hosts/macmini/darwin-configuration.nix -- imports hosts/macmini/home/robert.nix ---- imports modules/home/robert.nix

hosts/macbook-air/home/robert.nix -- imports modules/home/robert.nix

hosts/wsl/configuration.nix -- imports hosts/wsl/home/robert.nix ---- imports modules/home/robert.nix

Each top level host configuration imports a slightly customized home manager configuration, which uses the home module for most of its settings.

Yet to look into this more deeply but this seems reasonable to experiment with.

clo4 avatar Jan 08 '25 13:01 clo4

Sounds good. In that case blueprint doesn't need to be changed. But it would be good to document the pattern.

zimbatm avatar Jan 08 '25 15:01 zimbatm

@clo4 Sounds good :) What's is your workflow to deploy the standalone home-manager config on the darwin system? i.e. this doesn't expose homeConfigurations.macbook-air-robert yet, or does it?

phaer avatar Jan 09 '25 09:01 phaer

@phaer Ideally there would be a small change to expose homeConfigurations."robert@macbook-air", but I haven't started writing this change yet :)

clo4 avatar Jan 10 '25 02:01 clo4