nix-darwin icon indicating copy to clipboard operation
nix-darwin copied to clipboard

Nix complains about $HOME being retained by sudo

Open Sciencentistguy opened this issue 1 year ago • 3 comments

Ever since this (https://github.com/NixOS/nix/pull/6676) change in nix, it checks that $HOME is owned by the current user.

When using darwin-rebuild, this check is tripped, causing a warning to be printed:

warning: $HOME ('/Users/jamie') is not owned by you, falling back to the one defined in the 'passwd' file.

As far as I can tell, this occurs during this invokation of nix-env: https://github.com/LnL7/nix-darwin/blob/54a24f042f93c79f5679f133faddedec61955cf2/pkgs/nix-tools/darwin-rebuild.sh#L181

This happens because nix-env is executing as UID 0, however $HOME still points to /Users/jamie (sudo on macos does not clear $HOME)

This does not appear to be actually causing any issues, but thought I'd report it here anyway, in case this is fixable from this end.

Sciencentistguy avatar Jul 17 '22 14:07 Sciencentistguy

Ah, thanks for tracking this down. I was searching high and low where this was suddenly coming from! I've not noticed any bad side effects either.

joscha avatar Jul 19 '22 23:07 joscha

I think I've got into some troubles due to that change. My account is not present in /etc/passwd file (I think is manages like NSS on linux) I get this warning and all applications seem to think that my home directory is located in /var/empty is this possible?

FlakM avatar Jul 20 '22 05:07 FlakM

all applications seem to think that my home directory is located in /var/empty is this possible?

ah, I noticed that too. I fixed it via:

users.users."joscha".home = "/Users/joscha";

but that's very possibly a side-effect of that warning.

joscha avatar Jul 20 '22 06:07 joscha

Setting users.users.USER.home doesn't fix this for me. Just noticed this warning today after bumping nixpkgs. Nix-darwin with home-manager as a module.

supermarin avatar Aug 14 '22 02:08 supermarin

I still face this issue,

warning: $HOME ('/Users/kkharji') is not owned by you, falling back to the one defined in the 'passwd' file ('/var/root')

Using nix flake, info

├───nix-darwin: github:lnl7/nix-darwin/6349b99bc2b96ded34d068a88c7c5ced406b7f7f
│   └───nixpkgs follows input 'nixpkgs'

kkharji avatar Dec 03 '22 04:12 kkharji