dotfiles
dotfiles copied to clipboard
Understanding the $HOME Warning
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
$HOMEstill 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.
- It's tracked as a known issue in the upstream Nix repository (https://github.com/NixOS/nix/issues/6834)
- The Nix commands being run (nix-env for setting the system profile) shouldn't actually care about
$HOMEat all - The issue remains open and unresolved