forked from lix-project/lix
Don't prompt about using sudo if we're already root
This commit is contained in:
parent
88a0f3b6ba
commit
7bb1e913b3
|
@ -31,8 +31,8 @@ $ sh <(curl -L https://nixos.org/nix/install) --no-daemon
|
||||||
```
|
```
|
||||||
|
|
||||||
This will perform a single-user installation of Nix, meaning that `/nix`
|
This will perform a single-user installation of Nix, meaning that `/nix`
|
||||||
is owned by the invoking user. You should run this under your usual user
|
is owned by the invoking user. You can run this under your usual user
|
||||||
account, *not* as root. The script will invoke `sudo` to create `/nix`
|
account or root. The script will invoke `sudo` to create `/nix`
|
||||||
if it doesn’t already exist. If you don’t have `sudo`, you should
|
if it doesn’t already exist. If you don’t have `sudo`, you should
|
||||||
manually create `/nix` first as root, e.g.:
|
manually create `/nix` first as root, e.g.:
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ $ sh <(curl -L https://nixos.org/nix/install) --daemon
|
||||||
|
|
||||||
The multi-user installation of Nix will create build users between the
|
The multi-user installation of Nix will create build users between the
|
||||||
user IDs 30001 and 30032, and a group with the group ID 30000. You
|
user IDs 30001 and 30032, and a group with the group ID 30000. You
|
||||||
should run this under your usual user account, *not* as root. The script
|
can run this under your usual user account or root. The script
|
||||||
will invoke `sudo` as needed.
|
will invoke `sudo` as needed.
|
||||||
|
|
||||||
> **Note**
|
> **Note**
|
||||||
|
|
|
@ -337,10 +337,15 @@ __sudo() {
|
||||||
_sudo() {
|
_sudo() {
|
||||||
local expl="$1"
|
local expl="$1"
|
||||||
shift
|
shift
|
||||||
if ! headless; then
|
if ! headless || is_root; then
|
||||||
__sudo "$expl" "$*" >&2
|
__sudo "$expl" "$*" >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if is_root; then
|
||||||
|
env "$@"
|
||||||
|
else
|
||||||
sudo "$@"
|
sudo "$@"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -891,17 +896,6 @@ EOF
|
||||||
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
# TODO: I've moved this out of validate_starting_assumptions so we
|
|
||||||
# can fail faster in this case. Sourcing install-darwin... now runs
|
|
||||||
# `touch /` to detect Read-only root, but it could update times on
|
|
||||||
# pre-Catalina macOS if run as root user.
|
|
||||||
if is_root; then
|
|
||||||
failure <<EOF
|
|
||||||
Please do not run this script with root privileges. I will call sudo
|
|
||||||
when I need to.
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
|
|
||||||
check_selinux
|
check_selinux
|
||||||
|
|
||||||
if is_os_darwin; then
|
if is_os_darwin; then
|
||||||
|
@ -915,7 +909,10 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
welcome_to_nix
|
welcome_to_nix
|
||||||
|
|
||||||
|
if ! is_root; then
|
||||||
chat_about_sudo
|
chat_about_sudo
|
||||||
|
fi
|
||||||
|
|
||||||
cure_artifacts
|
cure_artifacts
|
||||||
# TODO: there's a tension between cure and validate. I moved the
|
# TODO: there's a tension between cure and validate. I moved the
|
||||||
|
|
Loading…
Reference in a new issue