dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

Understanding the $HOME Warning

Open kriswill opened this issue 3 months ago • 0 comments

The warning is not caused by configuration - it's an expected behavior when using nix-darwin with modern versions of Nix (2.10.0+).

What's Happening

When nh darwin switch runs, it needs to execute certain commands with elevated privileges (via sudo). On macOS, sudo doesn't reset the $HOME environment variable by default, so:

  • Commands run as root (UID 0)
  • But $HOME still points to /Users/<username> (owned by the user, not root)

Starting in Nix 2.10.0, Nix added a check to verify that $HOME is owned by the current user. When it detects the mismatch, it issues this warning and falls back to using the home directory from the passwd file (/var/root for root).

Is It a Problem?

No. This warning is completely harmless and doesn't affect functionality. This warning is generated deep within the Nix core, not by nix-darwin itself.

  1. It's tracked as a known issue in the upstream Nix repository (https://github.com/NixOS/nix/issues/6834)
  2. The Nix commands being run (nix-env for setting the system profile) shouldn't actually care about $HOME at all
  3. The issue remains open and unresolved

kriswill avatar Oct 18 '25 02:10 kriswill