Skip to content

Commit

Permalink
Add -H to sudo nix-env [...] to deal with warning
Browse files Browse the repository at this point in the history
After NixOS/nix#6676, the following warning is displayed when running
`darwin-rebuild switch`:
  warning: $HOME ('/Users/jamie') is not owned by you, falling back to the
  one defined in the 'passwd' file.
  • Loading branch information
malob authored and Michael Utz committed Apr 19, 2023
1 parent ffc579d commit 1843d37
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkgs/nix-tools/darwin-rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ fi

if [ "$action" = list ] || [ "$action" = rollback ]; then
if [ "$USER" != root ] && [ ! -w $(dirname "$profile") ]; then
sudo nix-env -p "$profile" "${extraProfileFlags[@]}"
sudo -H nix-env -p "$profile" "${extraProfileFlags[@]}"
else
nix-env -p "$profile" "${extraProfileFlags[@]}"
fi
Expand All @@ -178,7 +178,7 @@ if [ -z "$systemConfig" ]; then exit 0; fi

if [ "$action" = switch ]; then
if [ "$USER" != root ] && [ ! -w $(dirname "$profile") ]; then
sudo nix-env -p "$profile" --set "$systemConfig"
sudo -H nix-env -p "$profile" --set "$systemConfig"
else
nix-env -p "$profile" --set "$systemConfig"
fi
Expand Down

0 comments on commit 1843d37

Please sign in to comment.