profile
viewpoint

Ask questionsNix daemon fails to start on macOS 10.15 Catalina

Describe the bug The Nix daemon does not start after boot for multi-user installations on macOS 10.15 (Catalina).

To Reproduce

  1. Prepare macOS 10.15 (Catalina) for Nix:

    1. echo 'nix' | sudo tee -a /etc/synthetic.conf

    2. Reboot

    3. Create the Nix volume:

      sudo diskutil apfs addVolume disk1 APFSX Nix -mountpoint /nix
      sudo diskutil enableOwnership /nix
      sudo chflags hidden /nix
      echo "LABEL=Nix /nix apfs rw" | sudo tee -a /etc/fstab
      
  2. Install Nix with sh <(curl https://nixos.org/nix/install) --daemon

  3. Reboot

Observed behavior

Nix stops working after reboot; commands fail with:

error: cannot connect to daemon at `/nix/var/nix/daemon-socket/socket': Connection refused

Similarly, the Nix daemon is not seen by launchd: launchctl list | grep nix finds nothing.

Root Cause

Nix installs /Library/LaunchDaemons/org.nixos.nix-daemon.plist as a symlink into the Nix store.

At boot, launchd sees this as a dangling symlink as the Nix volume is not mounted early enough. Thus, it is unable to load the plist, and the nix daemon does not start.

Workaround

You can manually start the daemon after each boot with launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist && launchctl start org.nixos.nix-daemon.

Alternatively, manually copy the plist into /Library/LaunchDaemons, replacing the symlink with an actual copy of the file.

If you do the latter, you may want to adjust the paths inside the plist to point to /nix/var/nix/profiles/default/bin/nix-daemon rather than a specific derivation inside the Nix store.

Metadata

  • system: "x86_64-darwin"
  • host os: Darwin 19.0.0, macOS 10.15
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 2.3
  • channels(root): "nixpkgs-20.03pre194957.bef773ed53f"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixpkgs
NixOS/nix

Answer questions mroi

Damn. Thanks for clearing this up.

useful!
source:https://uonfu.com/
Github User Rank List