nix-deamon fails to start after clean install on macOS #77
Labels
No labels
Compat/Breaking
Context/drive-by
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status/Fixed On Main
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lix-project/lix-installer#77
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I uninstalled my previous installation of nix successfully and ran the current version of the lix-installer via curl. The installation itself was successful, the nix command is in my PATH, but the daemon doesn't start automatically. I can start it manually, but that's suboptimal.
Error
Running
/nix/nix-installer self-testInstaller sets up LaunchDaemon on macOS improperly, causing nix-deamon to not startto nix-deamon fails to start after clean install on macOSOkay, I found what the issue was; the smoking gun was in the system logs:
disposition=[enabled, disallowed, notified]means that the Launch Item has been enabled but not whitelisted by the user. I don't know why that happened, but it can be adjusted in the settings UI, see screenshot. Because the executable of our LaunchDaemon is /bin/sh, that's what it shows as the name and icon. I'll see if anything can be done about these issues.Okay, it seems like this was something that I changed at some point in the past on my machine, not knowing what it was. In theory, these services should be activated by default. Not an issue for regular users. There was a command in the past to change put a service on the allowlist (
sfltool add-item), but this was removed for security reasons, so we might have to add something to the troubleshooting docs.It's unfortunate that the custom service just has the name
shthough, andnix-darwinactually has the exact same issue: https://github.com/nix-darwin/nix-darwin/issues/1678The solution is to change the plist to something like this:
Where
/opt/nix/bin/nix-daemoncontains the shell-script to delay launching the actual executable from the nix-store until it is mounted:There's actually a solution for this class of issues already implemented in the installer, but not currently enabled by default. That's the "daemon stub" that the installer has the ability to download and install; it's a static binary we build that finds the right daemon and
execs it.Certain hardened mac setups have an issue where they require explicit user permission for {launch daemons, access to the full disk} via a popup on first exec, but three annoying things happen:
The solution I came up with for this was the "stub daemon" (see the bin folder in the installer), which is a small binary designed to remain unchanged after install, which then loads the main daemon from either the
systemordefaultnix profile.Right now, we only install the stub daemon when we know the user is going to run into the "full disk access" issue; but we can turn it on for the general case.
The issue right now is that
nix-darwinreplaces the launchd configuration each time anyway, replacing thecommandwith a hardcoded path to the daemon. We need to work with the nix-darwin maintainer to have that not happen if the stub daemon is present, but I haven't gotten around to making a case for it, yet.(Given this new case, it prolly makes sense to add the wait-for-store into the stub daemon as well; it wasn't necesarry for the full disk access case.)
In case it helps anyone in the interim, the Nix config to set the daemon command on
nix-darwinto e.g. your shell script is:You can then point your script to
/nix/var/nix/profiles/system/sw/bin/nix-daemoninstead of a specific daemon, which should always be the most recent daemon installed by nix-darwin.Hope that helps, and thanks for the report!