-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·61 lines (51 loc) · 1.76 KB
/
bootstrap.sh
File metadata and controls
executable file
·61 lines (51 loc) · 1.76 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
53
54
55
56
57
58
59
60
61
#!/bin/bash
set -e
echo "=== psteinroe dotfiles bootstrap ==="
# Install Xcode CLI tools (needed for git)
if ! xcode-select -p &>/dev/null; then
echo "Installing Xcode Command Line Tools..."
xcode-select --install
echo "Press enter after Xcode tools are installed..."
read
fi
# Generate SSH key if missing
if [[ ! -f ~/.ssh/id_ed25519 ]]; then
echo "Generating SSH key..."
mkdir -p ~/.ssh
ssh-keygen -t ed25519 -C "philipp@steinroetter.com" -N "" -f ~/.ssh/id_ed25519
fi
# Install Nix
if ! command -v nix &>/dev/null; then
echo "Installing Nix..."
curl --proto '=https' --tlsv1.2 -sSf -L \
https://install.determinate.systems/nix | sh -s -- install
# Source nix in current shell
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
fi
# Setup GitHub auth and SSH keys (use nix run since gh not installed yet)
mkdir -p ~/.config/gh
if ! nix run nixpkgs#gh -- auth status &>/dev/null 2>&1; then
echo "Authenticating with GitHub..."
nix run nixpkgs#gh -- auth login -p ssh -w
echo "Adding SSH key to GitHub..."
nix run nixpkgs#gh -- ssh-key add ~/.ssh/id_ed25519.pub --type authentication --title "$(hostname)"
nix run nixpkgs#gh -- ssh-key add ~/.ssh/id_ed25519.pub --type signing --title "$(hostname) signing"
fi
# Clone or update dotfiles
DOTFILES="$HOME/Developer/dotfiles"
if [ ! -d "$DOTFILES" ]; then
echo "Cloning dotfiles..."
mkdir -p "$HOME/Developer"
git clone git@github.com:psteinroe/dotfiles.git "$DOTFILES"
else
echo "Updating dotfiles..."
git -C "$DOTFILES" pull
fi
# First run of nix-darwin (bootstraps itself)
echo "Building system configuration..."
sudo HOME="$HOME" nix run nix-darwin -- switch --flake "$DOTFILES#psteinroe"
echo ""
echo "=== Done! ==="
echo "Your system is configured. Restart your terminal."
echo ""
echo "Future updates: rebuild"