mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
Merge pull request #831 from rkitover/high-sierra-fix
darwin-rebuild: fix sudo invocation on High Sierra
This commit is contained in:
commit
010a625bd7
1 changed files with 11 additions and 3 deletions
|
@ -16,6 +16,14 @@ showSyntax() {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sudo() {
|
||||||
|
if command sudo --help | grep -- --preserve-env= >/dev/null; then
|
||||||
|
command sudo -H --preserve-env=PATH env "$@"
|
||||||
|
else
|
||||||
|
command sudo -H "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Parse the command line.
|
# Parse the command line.
|
||||||
origArgs=("$@")
|
origArgs=("$@")
|
||||||
extraMetadataFlags=()
|
extraMetadataFlags=()
|
||||||
|
@ -187,7 +195,7 @@ fi
|
||||||
|
|
||||||
if [ "$action" = list ] || [ "$action" = rollback ]; then
|
if [ "$action" = list ] || [ "$action" = rollback ]; then
|
||||||
if [ "$USER" != root ] && [ ! -w $(dirname "$profile") ]; then
|
if [ "$USER" != root ] && [ ! -w $(dirname "$profile") ]; then
|
||||||
sudo -H --preserve-env=PATH env nix-env -p "$profile" "${extraProfileFlags[@]}"
|
sudo nix-env -p "$profile" "${extraProfileFlags[@]}"
|
||||||
else
|
else
|
||||||
nix-env -p "$profile" "${extraProfileFlags[@]}"
|
nix-env -p "$profile" "${extraProfileFlags[@]}"
|
||||||
fi
|
fi
|
||||||
|
@ -205,7 +213,7 @@ if [ -z "$systemConfig" ]; then exit 0; fi
|
||||||
|
|
||||||
if [ "$action" = switch ]; then
|
if [ "$action" = switch ]; then
|
||||||
if [ "$USER" != root ] && [ ! -w $(dirname "$profile") ]; then
|
if [ "$USER" != root ] && [ ! -w $(dirname "$profile") ]; then
|
||||||
sudo -H --preserve-env=PATH env nix-env -p "$profile" --set "$systemConfig"
|
sudo nix-env -p "$profile" --set "$systemConfig"
|
||||||
else
|
else
|
||||||
nix-env -p "$profile" --set "$systemConfig"
|
nix-env -p "$profile" --set "$systemConfig"
|
||||||
fi
|
fi
|
||||||
|
@ -215,7 +223,7 @@ if [ "$action" = switch ] || [ "$action" = activate ] || [ "$action" = rollback
|
||||||
"$systemConfig/activate-user"
|
"$systemConfig/activate-user"
|
||||||
|
|
||||||
if [ "$USER" != root ]; then
|
if [ "$USER" != root ]; then
|
||||||
sudo -H --preserve-env=PATH "$systemConfig/activate"
|
sudo "$systemConfig/activate"
|
||||||
else
|
else
|
||||||
"$systemConfig/activate"
|
"$systemConfig/activate"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue