From 9ee30f253432d3a059411d28aa05638a92ea8c71 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Tue, 22 Oct 2024 23:57:13 +1100 Subject: [PATCH] darwin-rebuild: add comments explaining the custom `sudo` logic --- pkgs/nix-tools/darwin-rebuild.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/nix-tools/darwin-rebuild.sh b/pkgs/nix-tools/darwin-rebuild.sh index aa066865..c0ea55b7 100644 --- a/pkgs/nix-tools/darwin-rebuild.sh +++ b/pkgs/nix-tools/darwin-rebuild.sh @@ -18,7 +18,11 @@ showSyntax() { } sudo() { + # REMOVEME when support for macOS 10.13 is dropped + # macOS 10.13 does not support sudo --preserve-env so we make this conditional if command sudo --help | grep -- --preserve-env= >/dev/null; then + # We use `env` before our command to ensure the preserved PATH gets checked + # when trying to resolve the command to execute command sudo -H --preserve-env=PATH env "$@" else command sudo -H "$@"