Skip to content

Understanding the $HOME Warning #2

@kriswill

Description

@kriswill

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 (Running Nix with sudo on darwin now complains that /Users/lily isn't owned by me NixOS/nix#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions