1#!/bin/sh
2set -eu
3
4cd /Users/clo/config
5
6target_host="${1:-}"
7if [ -z "$target_host" ]; then
8 if [ -f .hostname ]; then
9 target_host="$(cat .hostname)"
10 else
11 target_host="$(hostname)"
12 fi
13fi
14
15case "$target_host" in
16 '' | *[!A-Za-z0-9._-]*)
17 printf 'invalid host: %s\n' "$target_host" >&2
18 exit 2
19 ;;
20esac
21
22if [ "$(uname -s)" != Darwin ]; then
23 exec ./switch "$target_host"
24fi
25
26exec 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"