env/darwin/macstadium: rewrite setup notes

Generally clean up the notes:
- Restructure them so there's less bouncing around between preferences
  and Terminal and stuff
- include the stage0 script for non-VMs
- Remove obsolete Xcode instructions
- Convert to Markdown

For golang/go#49149.

Change-Id: I893ef85924fca552c8d179146f9db6b1b9b4912f
Reviewed-on: https://go-review.googlesource.com/c/build/+/402737
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Auto-Submit: Heschi Kreinick <heschi@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/env/darwin/macstadium/README.md b/env/darwin/macstadium/README.md
index 48f8894..28ef6f5 100644
--- a/env/darwin/macstadium/README.md
+++ b/env/darwin/macstadium/README.md
@@ -67,7 +67,7 @@
 * Clone the latest macOS version on vSphere and upgrade that version
   to the desired macOS version as per the [instructions](vmware-notes.md).
 
-* If a completely new image is required, follow the [images setup notes](image-setup-notes.txt)
+* If a completely new image is required, follow the [images setup notes](../setup-notes.md)
   in order to add a new image.
 
 ## Debugging
diff --git a/env/darwin/macstadium/image-setup-notes.txt b/env/darwin/macstadium/image-setup-notes.txt
deleted file mode 100644
index a643f6d..0000000
--- a/env/darwin/macstadium/image-setup-notes.txt
+++ /dev/null
@@ -1,66 +0,0 @@
-The Disk should be formatted with a case insensitive file system (default).
-
-Install VMWare tools daemon.
-
-  - The UI is supposed to be able to do this automatically, but it's broken as of writing.
-  - Instead, mount darwin.iso from ISO/VMWARE TOOLS and run the installer from there.
-  - open security preferences and click "Allow" on blocked software install from VMware
-  - reboot
-  - make sure you can run and see:
-
-    $ /Library/Application Support/VMware Tools/vmware-tools-daemon --cmd "info-get guestinfo.name"
-    No value found
-
-Download Go 1.13.4 or newer tarball via curl (bootstrap version of Go must be signed and notorized in macOS version >= 10.15).
-
-tar -xf <go.darwin-amd64.tar.gz>
-
-mv go $HOME/goboot
-
-System Preferences > Software Update > off
-
-System Preferences > Desktop & Screensaver > never screensaver
-
-System Preferences > Energy Saver > never sleep
-
-System Preferences > Sharing > enable ssh (enable for administrators)
-
-Create executable $HOME/stage0.sh with:
-
-   #!/bin/bash
-   while true; do (curl -v http://172.17.20.2:8713/stage0/$(sw_vers -productVersion) | sh); sleep 5; done
-
-chmod +x $HOME/stage0.sh
-
-Automator:
-
-    File > New > Application
-    [+] Run shell script
-    [ open -a Terminal.app $HOME/stage0.sh ]
-    Save to desktop as "run-builder"
-
-System Preferences > Users & Groups > auto-login "gopher" user, run Desktop/run-builder (automator app)
-
-passwordless sudo:
-
-   sudo visudo
-   Change line from:
-    %admin ALL=(ALL) ALL
-   to:
-    %admin ALL=(ALL) NOPASSWD: ALL
-
-install xcode
-  - Version < 10.9: search and install an older compatible version of Xcode.
-  - Versions 10.10, 10.9: running git first time will prompt for install.
-  - Version => 10.15: download Xcode from the Apple Developer site:
-    https://stackoverflow.com/questions/10335747/how-to-download-xcode-dmg-or-xip-file
-    (You don't want to log in to your account on the machine, so don't use the App Store.)
-    Extract it, move the resulting Xcode folder to Applications, and run xcode-select:
-    sudo xcode-select --switch /Applications/Xcode.app
-    Then run xcodebuild -version and wait for Xcode to be verified.
-    Finally, accept the license:
-    sudo xcodebuild -license accept
-
-verbose boot: (text instead of apple image)
-
-    sudo nvram boot-args="-v"
diff --git a/env/darwin/macstadium/vmware-notes.md b/env/darwin/macstadium/vmware-notes.md
index 6e35144..2618549 100644
--- a/env/darwin/macstadium/vmware-notes.md
+++ b/env/darwin/macstadium/vmware-notes.md
@@ -1,7 +1,7 @@
 * Create a new virtual machine stored in GGLGTM*, with the most recent 
   supported version of macOS as the guest OS. Configure it with 2 CPUs,
   4 GB RAM, 60+ GiB of disk, and mount the installer ISO from ISO/OSX.
-* Setup OS X following image-setup-notes.txt.
+* Setup OS X following setup-notes.md.
 * Shut it down.
 * Clone to Virtual Machine (convention: "osx_amd64_11_0_frozen" for macOS
   11.0")
diff --git a/env/darwin/setup-notes.md b/env/darwin/setup-notes.md
new file mode 100644
index 0000000..65a224c
--- /dev/null
+++ b/env/darwin/setup-notes.md
@@ -0,0 +1,94 @@
+# For VMs only #
+
+The Disk should be formatted with a case insensitive file system (default).
+
+Install VMWare tools daemon.
+
+  - The UI is supposed to be able to do this automatically, but it's broken as of writing.
+  - Instead, mount darwin.iso from ISO/VMWARE TOOLS and run the installer from there.
+  - open security preferences and click "Allow" on blocked software install from VMware
+  - reboot
+  - make sure you can run and see:
+
+    $ /Library/Application Support/VMware Tools/vmware-tools-daemon --cmd "info-get guestinfo.name"
+    No value found
+
+# For all machine types
+
+- Turn on the computer.
+- Click through setup, connect to wifi, etc.
+- Full name: Gopher Gopherson
+- Account name: gopher
+- Password: with an exclamation mark
+- Decline as much as possible.
+- Set time zone to NY.
+- Open a terminal.
+- `sudo visudo`
+
+  Change  `%admin ALL=(ALL) ALL` to `%admin ALL=(ALL) NOPASSWD: ALL`.
+
+- `sudo nvram boot-args="-v"`
+
+- Install Go: download the latest tarball from go.dev/dl.
+
+  `tar -xf Downloads/go*.darwin-*.tar`
+
+  `mv go $HOME/goboot`
+
+Create `$HOME/stage0.sh`.
+
+**For VMs**
+```
+#!/bin/bash
+while true; do (curl -v http://172.17.20.2:8713/stage0/$(sw_vers -productVersion) | sh); sleep 5; done
+```
+**For physical machines**
+```
+#!/bin/bash
+
+set -x
+
+mkdir -p ~/go/bin;
+while true; do
+  url="https://storage.googleapis.com/go-builder-data/buildlet.darwin-arm64"
+  while ! curl -f -o ~/go/bin/buildlet "$url"; do
+      echo
+      echo "curl failed to fetch $url"
+      echo "Sleeping before retrying..."
+      sleep 2
+  done
+  chmod +x ~/go/bin/buildlet
+
+  mkdir -p /tmp/buildlet
+  ~/go/bin/buildlet --coordinator=farmer.golang.org --reverse-type host-darwin-arm64-XX_0 --halt=false --workdir=/tmp/buildlet;
+   sleep 2;
+done
+```
+
+`chmod +x $HOME/stage0.sh`
+
+- Run Automator.
+- Create a new Application.
+- Add a "run shell script" item with the command: 
+  `open -a Terminal.app $HOME/stage0.sh`
+- Save it to the desktop as "run-builder".
+
+In System Preferences:
+- Software Update > Advanced > disable checking for updates
+- Desktop & Screensaver > uncheck show screensaver
+- Energy Saver > never turn off display, don't automatically sleep, start up after power failure
+- Sharing > enable ssh (leave the default administrators setting)
+- Users & Groups > Gopher Gopherson > Login Items > add run-builder
+- Users & Groups > Login Options > auto-login Gopher Gopherson
+
+Install XCode:
+- Download Xcode from the Apple Developer site:
+https://stackoverflow.com/questions/10335747/how-to-download-xcode-dmg-or-xip-file.
+https://developer.apple.com/support/xcode/ is a more authoritative list of versions.
+(You don't want to log in to your account on the machine, so don't use the App Store.)
+- Extract it and move the resulting Xcode folder to Applications
+- run xcode-select: `sudo xcode-select --switch /Applications/Xcode.app`
+- run `xcodebuild -version` and wait for Xcode to be verified, which will take a long time.
+- accept the license: `sudo xcodebuild -license accept`
+
+Put a builder key in the usual spot.
\ No newline at end of file