nlewo / comin

GitOps For NixOS Machines
MIT License
234 stars 11 forks source link

[Feature Request] Home Manager support #11

Open Pablo1107 opened 4 months ago

Pablo1107 commented 4 months ago

It would be nice if this could also export a HM module to pull the config and switch to it.

nlewo commented 3 months ago

Yes, i think it could be a good idea. We however have to ensure this would not add too much complexity to comin...

I think we should consider adding configuration to allow comin running a Home Manager switch to configuration instead of NixOS switch to configuration. This implies a comin instance would not be able to support both NixOS and Home manager simultaneously.

We should however hit some issues with the model since a Generation is currently, for instance, getting the machine-id during the evaluation phase. This part should not be executed for a Home Manager deployment.

It would be nice to have an idea of the comin NixOS module interface also, because we would have to modify it i think.

Pablo1107 commented 3 months ago

I'm not super familiar with the activation process on NixOS, I just read a little bit the comin codebase and I saw that you use some nixos-rebuild internal script called switch-to-configuration instead of just using the nixos-rebuild switch command. Seems this script responsability is to check for stateful things that might be carried from generation to generation?

Home Manager on the other hand seems to just do a nix build followed by a $generation/activate. So probably it's a little bit of a simpler process than NixOS.

nlewo commented 3 months ago

I saw that you use some nixos-rebuild internal script called switch-to-configuration instead of just using the nixos-rebuild switch command.

I think nixos-rebuild is basically a wrapper around nix build and the switch-to-configuration script.

The NixOS deployment and Home Manager deployment should be pretty similar:

However, regarding NixOS, comin is switching but it also does some other small tasks such as:

I think these tasks should not be executed if the Home Manager context.

How would you plan to run comin to support deploy Home Manager?

Pablo1107 commented 3 months ago

How would you plan to run comin to support deploy Home Manager?

  • As user or root?
  • As a Home Manager module?

Ideally the Nix interface should be mostly the same, meaning it should be a HM module that you call a as a service that creates a systemctl --user service with your comin bin. That should run as a user. And this is important as most HM rely on not necessarily having root access.

However, regarding NixOS, comin is switching but it also does some other small tasks such as:

  • comparing some machine id to ensure the deployment is expected
  • restarting comin if required
  • rebooting if required (not implemented yet but planned)

I think these tasks should not be executed if the Home Manager context.

Maybe there is a case (env vars) that may need a re-login tho.