nixos-install: add root directory ownership check

Prevents installation when mount point is not owned by root:root, which can cause systemd warnings and session failures.

Fixes #432261

authored by adeci and committed by Masum Reza aa822ab6 4320adea

+8
+8
pkgs/by-name/ni/nixos-install/nixos-install.sh
··· 122 122 checkPath="$(dirname "$checkPath")" 123 123 done 124 124 125 + # Check if the mount point root directory is owned by root 126 + if [[ "$(stat -c '%u:%g' "$mountPoint")" != "0:0" ]]; then 127 + echo "$0: $mountPoint is not owned by root:root (owned by $(stat -c '%U:%G' "$mountPoint"))" 128 + echo "$0: installation root directory must be owned by root to avoid system issues" 129 + echo "$0: run 'sudo chown root:root $mountPoint' to fix this" 130 + exit 1 131 + fi 132 + 125 133 # Verify that user is not trying to use attribute building and flake 126 134 # at the same time 127 135 if [[ -z $buildingAttribute && -n $flake ]]; then