| 1 | #!/bin/sh |
| 2 | set -eu |
| 3 | |
| 4 | cd /Users/clo/config |
| 5 | |
| 6 | target_host="${1:-}" |
| 7 | if [ -z "$target_host" ]; then |
| 8 | if [ -f .hostname ]; then |
| 9 | target_host="$(cat .hostname)" |
| 10 | else |
| 11 | target_host="$(hostname)" |
| 12 | fi |
| 13 | fi |
| 14 | |
| 15 | case "$target_host" in |
| 16 | '' | *[!A-Za-z0-9._-]*) |
| 17 | printf 'invalid host: %s\n' "$target_host" >&2 |
| 18 | exit 2 |
| 19 | ;; |
| 20 | esac |
| 21 | |
| 22 | if [ "$(uname -s)" != Darwin ]; then |
| 23 | exec ./switch "$target_host" |
| 24 | fi |
| 25 | |
| 26 | exec osascript -e "do shell script \"cd /Users/clo/config && HOME=/var/root XDG_CACHE_HOME=/var/root/.cache /nix/var/nix/profiles/default/bin/nix run .#darwin-rebuild -- switch --flake .#$target_host\" with administrator privileges" |