safeguard against running nixos-edit as root

This commit is contained in:
Daniella / Tove 2024-10-19 04:47:07 +02:00
parent c7cc2323e3
commit 9a4f3a2e74

View file

@ -66,6 +66,12 @@ pkgs.writeShellScriptBin "nixos-edit" ''
exit 0
fi
if [ "$(whoami)" = root ] ; then
echo "re-executing as tudbut"
sleep 2
exec sudo -iu tudbut nixos-edit $1 || exit 1
fi
cd /etc/nixos
if [ "$1" = "pull" ] ; then
git pull