nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
7.05k stars 1.82k forks source link

[bug] [darwin] Unable to launch agents using ssh #4413

Open michaelCTS opened 1 year ago

michaelCTS commented 1 year ago

Description

When launching agents over SSH after a home-manager switch this error pops up in the output

Bootstrap failed: 125: Domain does not support specified action

For people like mac-mini users, this is a limitation as they would have to use a remote desktop client like Remmina to connect to the mac box in order to switch the home-manager config.

Recreation

  1. connect to your mac box over ssh
  2. Add services.syncthing.enable = true; to your config
  3. home-manager switch

Context

Mac supports different domains for their agents. These are linked to session types and an agent can be restricted to session types (or as I understand it a domain).

When loading an agent, the session type can be specified.

load | unload [-wF] [-S sessiontype] [-D searchpath] paths ...
[...]
-S sessiontype
                       Some jobs only make sense in certain contexts. This
                       flag instructs launchctl to look for jobs in a differ-
                       ent location when using the -D flag, and allows
                       launchctl to restrict which jobs are loaded into which
                       session types. Sessions are only relevant for per-user
                       launchd contexts. Relevant sessions are Aqua (the
                       default), Background and LoginWindow.  Background
                       agents may be loaded independently of a GUI login. Aqua
                       agents are loaded only when a user has logged in at the
                       GUI. LoginWindow agents are loaded when the LoginWindow
                       UI is displaying and currently run as root.

home-manager only uses one domain - the gui/<uid> domain. https://github.com/nix-community/home-manager/blob/b22d7bab30076bbb73744867d6c5bf7d6380570c/modules/launchd/default.nix#L148

and thus only supports Aqua / GUI session types.

Proposed solution

Used LimitLoadToSessionType or another attribute in an agent.config attrset to define which sessiontype and domain to start with (probably user/uid).

As per documentation the attr should actually be a list of strings

https://github.com/nix-community/home-manager/blob/b22d7bab30076bbb73744867d6c5bf7d6380570c/modules/launchd/launchd.nix#L120-L127

stale[bot] commented 11 months ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.