Repository navigation
Expand file tree
/
Copy pathgodark
More file actions
executable file
·53 lines (42 loc) · 2.5 KB
/
Copy pathgodark
File metadata and controls
executable file
·53 lines (42 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
set -euo pipefail
echo "[*] Godark – one-shot declarative macOS bootstrap"
REAL_USER=$(logname) # logged-in user
USER_HOME=$(dscl . -read /Users/$REAL_USER NFSHomeDirectory | awk '{print $2}')
FLAKE="$USER_HOME/mac-config#macbook"
#──────────────────────────────── 1. Nix ────────────────────────────
if ! command -v nix &>/dev/null; then
echo "[+] Installing Nix…"
/bin/bash -c "$(curl -L https://nixos.org/nix/install)" -- --daemon
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
else
echo "[✓] Nix present."
fi
#────────────────────────────── 2. Flakes ───────────────────────────
sudo mkdir -p /etc/nix
grep -q flakes /etc/nix/nix.conf 2>/dev/null || \
echo "experimental-features = nix-command flakes" | sudo tee -a /etc/nix/nix.conf >/dev/null
#────────────────────────── 3. nix-darwin ───────────────────────────
if ! command -v darwin-rebuild &>/dev/null; then
echo "[+] Installing nix-darwin…"
nix run github:lnl7/nix-darwin -- switch --flake "$FLAKE"
fi
#───────────────────────── 4. Homebrew ─────────────────────────────
if ! command -v brew &>/dev/null; then
echo "[+] Installing Homebrew (non-interactive)…"
NONINTERACTIVE=1 CI=1 /bin/bash -c \
"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
#── fix ~/.zprofile ownership & append brew shellenv ──────────────
sudo -u "$REAL_USER" bash -c '
touch ~/.zprofile
grep -q "brew shellenv" ~/.zprofile 2>/dev/null || \
echo "eval \"$(/opt/homebrew/bin/brew shellenv)\"" >> ~/.zprofile
'
eval "$(/opt/homebrew/bin/brew shellenv)"
echo "[✓] Homebrew ready: $(brew --version | head -n1)"
#────────────────────── 5. Switch system state ────────────────────
echo "[*] Running darwin-rebuild switch…"
sudo darwin-rebuild switch --flake "$FLAKE" --impure
echo "[✓] All done. Dock pruned, Brave + Proton VPN + UTM installed."
echo "↪ Re-open a new terminal or reboot to pick up PATH."