-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·339 lines (280 loc) · 9.83 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·339 lines (280 loc) · 9.83 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
#!/usr/bin/env bash
set -euo pipefail
DOTFILES_DIR="$HOME/.dotfiles"
DOTFILES_REPO="https://github.com/andreicek/dotfiles.git"
# Prompt for sudo upfront and keep it alive
sudo -v
while true; do sudo -n true; sleep 55; kill -0 "$$" || exit; done 2>/dev/null &
# --- Clone dotfiles repo if missing ---
if [ ! -d "$DOTFILES_DIR" ]; then
echo "Cloning dotfiles..."
git clone "$DOTFILES_REPO" "$DOTFILES_DIR"
fi
cd "$DOTFILES_DIR"
# --- Bootstrap gum (needed for all TUI output) ---
if ! command -v gum &>/dev/null; then
echo "Installing gum..."
GUM_VERSION=$(curl -fsSL https://api.github.com/repos/charmbracelet/gum/releases/latest | grep -oP '"tag_name": "v\K[^"]+')
curl -fsSL -o /tmp/gum.deb "https://github.com/charmbracelet/gum/releases/download/v${GUM_VERSION}/gum_${GUM_VERSION}_amd64.deb"
sudo dpkg -i /tmp/gum.deb
fi
# --- TUI helpers ---
info() { gum log --level info "$*"; }
success() { gum log --level info --prefix "✓" "$*"; }
warn() { gum log --level warn "$*"; }
TOTAL_STEPS=16
CURRENT_STEP=0
step() {
CURRENT_STEP=$((CURRENT_STEP + 1))
echo ""
gum style --bold --foreground 212 "[$CURRENT_STEP/$TOTAL_STEPS] $*"
}
# --- Styled banner ---
gum style \
--border double \
--border-foreground 212 \
--padding "1 3" \
--bold \
"dotfiles installer"
# --- Helpers ---
# Pre-accept Microsoft fonts EULA
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
apt_updated=false
ensure_apt_updated() {
if [ "$apt_updated" = false ]; then
gum spin --title "Updating apt package index..." -- sudo apt-get update -qq
apt_updated=true
fi
}
ensure_apt_pkg() {
local pkg="$1"
if dpkg -s "$pkg" &>/dev/null; then
success "$pkg already installed"
else
ensure_apt_updated
gum spin --title "Installing $pkg..." -- sudo apt-get install -y -qq "$pkg"
success "$pkg installed"
fi
}
ensure_command() {
local cmd="$1"
local install_fn="$2"
if command -v "$cmd" &>/dev/null; then
success "$cmd already available"
else
info "Installing $cmd..."
$install_fn
success "$cmd installed"
fi
}
# --- gum ---
step "gum"
success "gum already available"
# --- Machine profile ---
step "Machine profile"
MACHINE=$(gum choose --header "Select machine profile:" "workstation" "laptop")
# --- APT packages ---
step "APT packages"
apt_packages=(
# Core tools
git stow zsh curl unzip gnupg2
# Zsh plugins
zsh-autosuggestions zsh-syntax-highlighting
# CLI tools
bat eza fzf wl-clipboard zoxide
# Build deps (erlang via mise)
build-essential libssl-dev libncurses-dev
# Hyprland ecosystem
hyprland hyprpaper waybar mako-notifier wofi
blueman wireplumber grim slurp swappy pavucontrol cliphist wtype
# Fonts
fonts-ibm-plex ttf-mscorefonts-installer fonts-font-awesome
)
if [ "$MACHINE" = "laptop" ]; then
apt_packages+=(brightnessctl network-manager-gnome wireguard-tools python3-pip python3-build)
fi
for pkg in "${apt_packages[@]}"; do
ensure_apt_pkg "$pkg"
done
# --- Hyprlock ---
step "Hyprlock"
if dpkg -s hyprlock &>/dev/null; then
success "Hyprlock already installed"
else
info "Adding Hyprland PPA..."
if ! grep -q "cppiber/hyprland" /etc/apt/sources.list.d/*.list 2>/dev/null && \
! grep -q "cppiber/hyprland" /etc/apt/sources.list.d/*.sources 2>/dev/null; then
gum spin --title "Adding Hyprland PPA..." -- \
sudo add-apt-repository -y ppa:cppiber/hyprland
apt_updated=false
fi
ensure_apt_updated
gum spin --title "Installing Hyprlock..." -- \
sudo apt-get install -y -qq hyprlock
success "Hyprlock installed"
fi
# --- Ghostty ---
step "Ghostty"
if dpkg -s ghostty &>/dev/null; then
success "Ghostty already installed"
else
gum spin --title "Installing Ghostty via PPA..." -- \
bash -c 'curl -fsSL https://raw.githubusercontent.com/mkasberg/ghostty-ubuntu/HEAD/install.sh | bash'
success "Ghostty installed"
fi
# --- Docker ---
step "Docker"
if dpkg -s docker-ce &>/dev/null; then
success "Docker already installed"
else
info "Adding Docker repository..."
sudo install -m 0755 -d /etc/apt/keyrings
if [ ! -f /etc/apt/keyrings/docker.asc ]; then
gum spin --title "Downloading Docker GPG key..." -- \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /tmp/docker.asc
sudo install -m 0644 /tmp/docker.asc /etc/apt/keyrings/docker.asc
fi
if [ ! -f /etc/apt/sources.list.d/docker.list ] && [ ! -f /etc/apt/sources.list.d/docker.sources ]; then
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
fi
apt_updated=false
ensure_apt_updated
gum spin --title "Installing Docker..." -- \
sudo apt-get install -y -qq docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo usermod -aG docker "$USER"
success "Docker installed (log out and back in for group membership)"
fi
# --- Google Chrome ---
step "Google Chrome"
if dpkg -s google-chrome-stable &>/dev/null; then
success "Google Chrome already installed"
else
info "Adding Google Chrome repository..."
sudo install -m 0755 -d /etc/apt/keyrings
if [ ! -f /etc/apt/keyrings/google-chrome.asc ]; then
gum spin --title "Downloading Google Chrome GPG key..." -- \
curl -fsSL https://dl.google.com/linux/linux_signing_key.pub -o /tmp/google-chrome.asc
sudo install -m 0644 /tmp/google-chrome.asc /etc/apt/keyrings/google-chrome.asc
fi
if [ ! -f /etc/apt/sources.list.d/google-chrome.list ] && [ ! -f /etc/apt/sources.list.d/google-chrome.sources ]; then
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/google-chrome.asc] https://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list >/dev/null
fi
apt_updated=false
ensure_apt_updated
gum spin --title "Installing Google Chrome..." -- \
sudo apt-get install -y -qq google-chrome-stable
success "Google Chrome installed"
fi
# --- Tailscale ---
step "Tailscale"
if command -v tailscale &>/dev/null; then
success "Tailscale already installed"
else
gum spin --title "Installing Tailscale..." -- \
bash -c 'curl -fsSL https://tailscale.com/install.sh | sh'
sudo systemctl enable --now tailscaled
success "Tailscale installed (run 'tailscale up' to authenticate)"
fi
# --- Zellij ---
step "Zellij"
install_zellij() {
ZELLIJ_VERSION=$(curl -fsSL https://api.github.com/repos/zellij-org/zellij/releases/latest | grep -oP '"tag_name": "v\K[^"]+')
curl -fsSL -o /tmp/zellij.tar.gz "https://github.com/zellij-org/zellij/releases/download/v${ZELLIJ_VERSION}/zellij-x86_64-unknown-linux-musl.tar.gz"
tar -xzf /tmp/zellij.tar.gz -C /tmp
sudo install -m 0755 /tmp/zellij /usr/local/bin/zellij
rm -f /tmp/zellij.tar.gz /tmp/zellij
}
ensure_command zellij install_zellij
# --- mise ---
step "mise"
install_mise() {
gum spin --title "Installing mise..." -- \
bash -c 'curl -sSfL https://mise.jdx.dev/install.sh | sh'
}
ensure_command "$HOME/.local/bin/mise" install_mise
# --- Stow dotfiles ---
step "Stow dotfiles"
cd "$DOTFILES_DIR"
stow --restow git zsh bin nvim ghostty zellij mise claude opencode hyprland systemd helix
ln -sf "machines/${MACHINE}.conf" "$DOTFILES_DIR/hyprland/.config/hypr/machine.conf"
ln -sf "machines/${MACHINE}.hyprpaper.conf" "$DOTFILES_DIR/hyprland/.config/hypr/hyprpaper.conf"
ln -sf "machines/${MACHINE}.jsonc" "$DOTFILES_DIR/hyprland/.config/waybar/config.jsonc"
ln -sf "machines/${MACHINE}.hyprlock.conf" "$DOTFILES_DIR/hyprland/.config/hypr/hyprlock.conf"
success "All packages stowed ($MACHINE profile)"
# --- SSH directory ---
step "SSH directory"
mkdir -p "$HOME/.ssh"
chmod 700 "$HOME/.ssh"
success "~/.ssh directory ready"
# --- fw-fanctrl (laptop only) ---
step "fw-fanctrl"
if [ "$MACHINE" = "laptop" ]; then
if command -v fw-fanctrl &>/dev/null; then
success "fw-fanctrl already installed"
else
info "Installing fw-fanctrl..."
FWFAN_TMP=$(mktemp -d)
git clone --depth 1 https://github.com/TamtamHero/fw-fanctrl.git "$FWFAN_TMP"
gum spin --title "Installing fw-fanctrl..." -- \
bash -c "cd '$FWFAN_TMP' && sudo ./install.sh"
rm -rf "$FWFAN_TMP"
success "fw-fanctrl installed"
fi
sudo tee /etc/fw-fanctrl/config.json >/dev/null <<'FWCFG'
{
"defaultStrategy": "lazy",
"strategyOnDischarging": "lazy",
"strategies": {
"lazy": {
"fanSpeedUpdateFrequency": 5,
"movingAverageInterval": 30,
"speedCurve": [
{ "temp": 0, "speed": 0 },
{ "temp": 50, "speed": 0 },
{ "temp": 60, "speed": 25 },
{ "temp": 70, "speed": 50 },
{ "temp": 80, "speed": 100 }
]
}
}
}
FWCFG
sudo systemctl enable --now fw-fanctrl
success "fw-fanctrl configured with lazy fan curve"
else
info "Skipping fw-fanctrl (not a laptop)"
fi
# --- mise runtimes ---
step "mise runtimes"
export PATH="$HOME/.local/bin:$PATH"
gum spin --title "Installing runtimes from mise config (this may take a while)..." -- \
mise install -y
success "mise runtimes up to date"
# --- Meridian service ---
step "Meridian service"
systemctl --user daemon-reload
systemctl --user enable --now meridian.service
success "meridian.service enabled (Anthropic API proxy for OpenCode)"
# --- Default shell ---
step "Default shell"
zsh_path="$(which zsh)"
if [ "$SHELL" = "$zsh_path" ]; then
success "zsh is already the default shell"
else
info "Changing default shell to zsh..."
chsh -s "$zsh_path"
success "Default shell changed to zsh (takes effect on next login)"
fi
# --- Summary ---
echo ""
gum style \
--border rounded \
--border-foreground 77 \
--padding "1 3" \
--bold \
"All done!" \
"" \
"Manual steps remaining:" \
" - Launch nvim to bootstrap plugins (lazy.nvim auto-installs)" \
" - Run 'tailscale up' to authenticate with Tailscale" \
" - Run 'hx --health' to verify Helix language support"