-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·1226 lines (1076 loc) · 52.2 KB
/
install.sh
File metadata and controls
executable file
·1226 lines (1076 loc) · 52.2 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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
set -Eeo pipefail
################################################################################
# Global variables
################################################################################
SCRIPT_START_TIME=$(date +%s)
export SCRIPT_START_TIME
################################################################################
# Load utility functions
################################################################################
# Try to load from local zsh/core first
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)" || SCRIPT_DIR=""
# If core not available locally, download temporarily
if [ -z "$SCRIPT_DIR" ] || [ ! -f "$SCRIPT_DIR/zsh/core" ]; then
# Running via curl | bash - download core to temp location
TEMP_UTILITIES=$(mktemp)
trap 'rm -f "$TEMP_UTILITIES"' EXIT
if curl -fsSL --connect-timeout 10 --max-time 60 https://raw.githubusercontent.com/gufranco/dotfiles/master/zsh/core -o "$TEMP_UTILITIES" 2>/dev/null; then
# shellcheck source=/dev/null
source "$TEMP_UTILITIES"
rm -f "$TEMP_UTILITIES"
trap - EXIT
else
echo "ERROR: Could not download utility functions"
exit 1
fi
else
# Load from local file
# shellcheck source=/dev/null
source "$SCRIPT_DIR/zsh/core"
fi
################################################################################
# Wrapper functions (remove __ prefix for install.sh)
################################################################################
log_info() { __log_info "$@"; }
log_success() { __log_success "$@"; }
log_warning() { __log_warning "$@"; }
log_error() { __log_error "$@"; }
log_skip() { __log_skip "$@"; }
cmd_exists() { __cmd_exists "$@"; }
pkg_installed() { __pkg_installed "$@"; }
snap_installed() { __snap_installed "$@"; }
safe_link() { __safe_link "$@"; }
git_sync() { __git_sync "$@"; }
apt_install_if_missing() { __apt_install_if_missing "$@"; }
apt_add_key_and_repo() { __apt_add_key_and_repo "$@"; }
brew_install_if_missing() { __brew_install_if_missing "$@"; }
brew_install_cask_if_missing() { __brew_install_cask_if_missing "$@"; }
github_repo_sync() {
local https_url="$1"
local target_dir="$2"
local label="$3"
local ssh_url="${https_url/https:\/\/github.com\//git@github.com:}"
log_info "Setting up ${label}..."
if [ -d "$target_dir/.git" ]; then
git -C "$target_dir" remote set-url origin "$https_url" 2>/dev/null || true
git -C "$target_dir" pull --no-edit 2>/dev/null || log_warning "Failed to pull ${label}"
git -C "$target_dir" remote set-url origin "$ssh_url" 2>/dev/null || true
git -C "$target_dir" submodule update --init --recursive 2>/dev/null || log_warning "Submodule update failed"
log_success "${label} updated"
else
git clone --recursive "$https_url" "$target_dir"
git -C "$target_dir" remote set-url origin "$ssh_url" 2>/dev/null || true
log_success "${label} cloned"
fi
}
################################################################################
# Error handling
################################################################################
trap 'log_error "Installation failed at line $LINENO"' ERR
################################################################################
# Installation
################################################################################
echo ""
log_info "==============================================================="
log_info "Dotfiles Installation Script"
log_info "==============================================================="
echo ""
################################################################################
# User confirmation (skip in CI)
################################################################################
if [[ -z "$CI" ]]; then
echo ""
log_warning "This script will install/update dotfiles and may overwrite existing configurations."
read -p "Continue? (Y/n) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]] && [[ -n "$REPLY" ]]; then
log_info "Installation cancelled."
exit 0
fi
else
log_info "Running in CI environment - skipping user interaction."
fi
################################################################################
# OS-specific installation
################################################################################
case "$(uname)" in
"Linux")
log_info "System: Linux (Ubuntu/Debian)"
export DEBIAN_FRONTEND=noninteractive
export GIT_TERMINAL_PROMPT=0
############################################################################
# System update
############################################################################
log_info "Updating system..."
sudo add-apt-repository -y universe >/dev/null 2>&1 || true
sudo apt update -qq
sudo apt dist-upgrade -y -qq
log_success "System updated"
############################################################################
# Third-party repositories (latest versions from maintainers)
############################################################################
log_info "Adding third-party repositories..."
sudo add-apt-repository -y ppa:git-core/ppa >/dev/null 2>&1 || true
sudo add-apt-repository -y ppa:neovim-ppa/stable >/dev/null 2>&1 || true
sudo apt update -qq
log_success "Repositories configured"
############################################################################
# Basic packages
############################################################################
log_info "Installing basic packages..."
echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | sudo debconf-set-selections
BASIC_PKGS=(
# Build essentials
build-essential ca-certificates cmake curl
git gnupg software-properties-common autoconf automake libtool gettext
# Compression
exfatprogs p7zip-full unrar unzip zip zlib1g-dev
# Shell & Terminal
bash tmux snapd trash-cli xsel bc
# Text & Search
vim neovim ripgrep fd-find jq moreutils patchutils urlview
# Network
wget rsync rclone nmap mtr telnet httpie
# System monitoring
htop
# Development
shellcheck ruby ruby-dev python3-pygments
# Misc
ubuntu-restricted-extras
)
for pkg in "${BASIC_PKGS[@]}"; do
apt_install_if_missing "$pkg"
done
log_success "Basic packages installed"
############################################################################
# Dotfiles repository
############################################################################
github_repo_sync "https://github.com/gufranco/dotfiles.git" "$HOME/.dotfiles" "dotfiles"
############################################################################
# Zsh
############################################################################
log_info "Installing Zsh..."
apt_install_if_missing zsh
apt_install_if_missing zsh-syntax-highlighting
if ! grep -q "$(command -v zsh)" /etc/shells 2>/dev/null; then
command -v zsh | sudo tee -a /etc/shells >/dev/null
fi
if [ "$SHELL" != "$(command -v zsh)" ]; then
sudo chsh "$USER" -s "$(command -v zsh)" 2>/dev/null || true
log_success "Shell changed to Zsh"
else
log_skip "Shell already Zsh"
fi
############################################################################
# Docker
############################################################################
if ! cmd_exists docker; then
log_info "Installing Docker..."
apt_add_key_and_repo \
"https://download.docker.com/linux/ubuntu/gpg" \
"/etc/apt/keyrings/docker.gpg" \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
"/etc/apt/sources.list.d/docker.list" \
"docker-ce"
log_success "Docker installed"
else
log_skip "Docker already installed"
fi
if ! groups "$USER" | grep -q docker; then
sudo usermod -a -G docker "$USER"
log_success "User added to docker group"
fi
############################################################################
# Node.js 24
############################################################################
if ! cmd_exists node || [ "$(node --version | cut -d. -f1 | tr -d v)" -lt 24 ]; then
log_info "Installing Node.js 24..."
sudo mkdir -p /etc/apt/keyrings
curl -fsSL --connect-timeout 10 --max-time 30 https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor --yes -o /etc/apt/keyrings/nodesource.gpg 2>/dev/null || true
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_24.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list >/dev/null
sudo apt update -qq
sudo apt install -y -qq nodejs
log_success "Node.js installed"
else
log_skip "Node.js 24+ already installed"
fi
############################################################################
# Python (latest from deadsnakes)
############################################################################
log_info "Setting up Python..."
sudo add-apt-repository -y ppa:deadsnakes/ppa >/dev/null 2>&1 || true
sudo apt update -qq
PYTHON_LATEST=$(apt-cache pkgnames python3. 2>/dev/null | grep -E '^python3\.[0-9]+$' | sort -t. -k2 -n | tail -1)
if [ -n "$PYTHON_LATEST" ]; then
if ! cmd_exists "$PYTHON_LATEST"; then
log_info "Installing ${PYTHON_LATEST}..."
sudo apt install -y -qq "$PYTHON_LATEST"
log_success "${PYTHON_LATEST} installed"
else
log_skip "${PYTHON_LATEST} already installed"
fi
else
log_warning "Could not determine latest Python version from deadsnakes"
fi
############################################################################
# Applications
############################################################################
APPS=(
# File managers & Cloud
nautilus-dropbox
# Search & Navigation
fzf universal-ctags
# Email & Web
neomutt lynx
# Media
vlc cmus asciinema
# Desktop
conky-all kitty fonts-hack-ttf transmission caffeine flameshot
# Dev tools
hyperfine tokei tty-clock
)
for app in "${APPS[@]}"; do
if ! pkg_installed "$app"; then
log_info "Installing $app..."
sudo apt install -y -qq "$app" 2>/dev/null || log_warning "Failed: $app"
fi
done
############################################################################
# GitHub CLI
############################################################################
if ! cmd_exists gh; then
log_info "Installing GitHub CLI..."
sudo mkdir -p /etc/apt/keyrings
curl -fsSL --connect-timeout 10 --max-time 30 https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli.gpg >/dev/null
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list >/dev/null
sudo apt update -qq
sudo apt install -y -qq gh
log_success "GitHub CLI installed"
else
log_skip "GitHub CLI already installed"
fi
############################################################################
# Bat (cat replacement)
############################################################################
if ! cmd_exists bat && ! cmd_exists batcat; then
log_info "Installing bat..."
sudo apt install -y -qq bat 2>/dev/null || true
# Ubuntu uses 'batcat' instead of 'bat'
if cmd_exists batcat && ! cmd_exists bat; then
sudo ln -sf "$(command -v batcat)" /usr/local/bin/bat
fi
log_success "Bat installed"
else
log_skip "Bat already installed"
fi
############################################################################
# eza (ls replacement)
############################################################################
if ! cmd_exists eza; then
log_info "Installing eza..."
sudo mkdir -p /etc/apt/keyrings
curl -fsSL --connect-timeout 10 --max-time 30 https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg 2>/dev/null || true
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list >/dev/null
sudo apt update -qq
sudo apt install -y -qq eza
log_success "eza installed"
else
log_skip "eza already installed"
fi
############################################################################
# Delta (git diff)
############################################################################
apt_install_if_missing git-delta
############################################################################
# Starship prompt
############################################################################
if ! cmd_exists starship; then
log_info "Installing Starship..."
curl -sS --connect-timeout 10 --max-time 120 https://starship.rs/install.sh | sh -s -- --yes
log_success "Starship installed"
else
log_skip "Starship already installed"
fi
############################################################################
# Zoxide (smart cd)
############################################################################
if ! cmd_exists zoxide; then
log_info "Installing zoxide..."
curl -sS --connect-timeout 10 --max-time 120 https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash
log_success "zoxide installed"
else
log_skip "zoxide already installed"
fi
############################################################################
# Atuin (shell history)
############################################################################
if ! cmd_exists atuin; then
log_info "Installing atuin..."
curl -sS --connect-timeout 10 --max-time 120 https://setup.atuin.sh | bash -s -- --non-interactive
log_success "atuin installed"
else
log_skip "atuin already installed"
fi
############################################################################
# Golang
############################################################################
if ! cmd_exists go; then
log_info "Installing Go..."
sudo add-apt-repository -y ppa:longsleep/golang-backports >/dev/null 2>&1 || true
sudo apt update -qq
sudo apt install -y -qq golang-go
log_success "Go installed"
else
log_skip "Go already installed"
fi
############################################################################
# Rust
############################################################################
if ! cmd_exists rustc; then
log_info "Installing Rust..."
if snap_installed rustup; then
log_skip "rustup snap already installed"
else
sudo snap install rustup --classic 2>/dev/null || true
fi
if cmd_exists rustup; then
rustup default stable >/dev/null 2>&1
log_success "Rust installed"
else
log_warning "Rust not available via snap"
fi
else
log_skip "Rust already installed"
fi
############################################################################
# mise
############################################################################
if ! cmd_exists mise; then
log_info "Installing mise..."
apt_add_key_and_repo \
"https://mise.jdx.dev/gpg-key.pub" \
"/etc/apt/keyrings/mise-archive-keyring.gpg" \
"deb [signed-by=/etc/apt/keyrings/mise-archive-keyring.gpg arch=$(dpkg --print-architecture)] https://mise.jdx.dev/deb stable main" \
"/etc/apt/sources.list.d/mise.list" \
"mise"
log_success "mise installed"
else
log_skip "mise already installed"
fi
############################################################################
# Desktop apps (skip in CI - no GUI available)
############################################################################
if [[ -z "$CI" ]]; then
# Spotify
if ! pkg_installed spotify-client; then
log_info "Installing Spotify..."
sudo mkdir -p /etc/apt/keyrings
curl -fsSL --connect-timeout 10 --max-time 30 https://download.spotify.com/debian/pubkey_5384CE82BA52C83A.asc | sudo gpg --dearmor --yes -o /etc/apt/keyrings/spotify.gpg 2>/dev/null || true
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/spotify.gpg] https://repository.spotify.com stable non-free" | sudo tee /etc/apt/sources.list.d/spotify.list >/dev/null
sudo apt update -qq
sudo apt install -y -qq spotify-client
log_success "Spotify installed"
else
log_skip "Spotify already installed"
fi
# Google Chrome
if ! pkg_installed google-chrome-stable; then
log_info "Installing Google Chrome..."
sudo mkdir -p /etc/apt/keyrings
curl -fsSL --connect-timeout 10 --max-time 30 https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor --yes -o /etc/apt/keyrings/google-chrome.gpg 2>/dev/null || true
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list >/dev/null
sudo apt update -qq
sudo apt install -y -qq google-chrome-stable
log_success "Chrome installed"
else
log_skip "Chrome already installed"
fi
# DBeaver
if ! pkg_installed dbeaver-ce; then
log_info "Installing DBeaver..."
sudo add-apt-repository -y ppa:serge-rider/dbeaver-ce >/dev/null 2>&1 || true
sudo apt update -qq
sudo apt install -y -qq dbeaver-ce
log_success "DBeaver installed"
else
log_skip "DBeaver already installed"
fi
# Visual Studio Code
if ! pkg_installed code; then
log_info "Installing VS Code..."
sudo mkdir -p /etc/apt/keyrings
curl -fsSL --connect-timeout 10 --max-time 30 https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /etc/apt/keyrings/visual_studio.gpg 2>/dev/null || true
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/visual_studio.gpg] https://packages.microsoft.com/repos/vscode stable main" | sudo tee /etc/apt/sources.list.d/vscode.list >/dev/null
sudo apt update -qq
sudo apt install -y -qq code
log_success "VS Code installed"
else
log_skip "VS Code already installed"
fi
# Snap packages
if cmd_exists snap; then
snap_installed beekeeper-studio || { log_info "Installing Beekeeper Studio..."; sudo snap install beekeeper-studio 2>/dev/null || true; }
snap_installed postman || { log_info "Installing Postman..."; sudo snap install postman 2>/dev/null || true; }
snap_installed slack || { log_info "Installing Slack..."; sudo snap install slack 2>/dev/null || true; }
snap_installed discord || { log_info "Installing Discord..."; sudo snap install discord 2>/dev/null || true; }
snap_installed sublime-text || { log_info "Installing Sublime Text..."; sudo snap install sublime-text --classic 2>/dev/null || true; }
snap_installed insomnia || { log_info "Installing Insomnia..."; sudo snap install insomnia 2>/dev/null || true; }
fi
else
log_skip "Desktop apps (CI environment)"
fi
############################################################################
# GPG
############################################################################
apt_install_if_missing gpg
apt_install_if_missing pinentry-curses
############################################################################
# Nerd Fonts (no apt/snap package available, direct download required)
############################################################################
log_info "Installing Nerd Fonts..."
mkdir -p "$HOME/.local/share/fonts"
NERD_FONTS_VERSION=$(curl -s --connect-timeout 10 --max-time 30 https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest | grep tag_name | cut -d '"' -f 4)
NERD_FONTS_VERSION="${NERD_FONTS_VERSION:-v3.3.0}"
if [ ! -f "$HOME/.local/share/fonts/HackNerdFont-Regular.ttf" ]; then
curl -#fLo "$HOME/.local/share/fonts/HackNerdFont-Regular.ttf" --connect-timeout 10 --max-time 120 \
"https://github.com/ryanoasis/nerd-fonts/raw/${NERD_FONTS_VERSION}/patched-fonts/Hack/Regular/HackNerdFont-Regular.ttf"
fi
if [ ! -f "$HOME/.local/share/fonts/JetBrainsMonoNerdFont-Regular.ttf" ]; then
curl -#fLo "$HOME/.local/share/fonts/JetBrainsMonoNerdFont-Regular.ttf" --connect-timeout 10 --max-time 120 \
"https://github.com/ryanoasis/nerd-fonts/raw/${NERD_FONTS_VERSION}/patched-fonts/JetBrainsMono/Ligatures/Regular/JetBrainsMonoNerdFont-Regular.ttf"
fi
sudo fc-cache -fv >/dev/null 2>&1
log_success "Fonts installed"
############################################################################
# Conky
############################################################################
safe_link "$HOME/.dotfiles/conky/.conkyrc" "$HOME/.conkyrc"
############################################################################
# Tilix
############################################################################
safe_link "$HOME/.dotfiles/tilix/tokyonight-night-tilix.json" "$HOME/.config/tilix/schemes/tokyonight-night.json"
############################################################################
# GPU drivers and gaming (x86_64 only)
############################################################################
if [ "$(dpkg --print-architecture)" = "amd64" ]; then
# Enable 32-bit architecture (required for Steam, Proton, and 32-bit drivers)
sudo dpkg --add-architecture i386
sudo apt update -qq
sudo apt -y upgrade -qq
# NVIDIA drivers (auto-detect best driver for installed GPU)
log_info "Installing NVIDIA drivers..."
apt_install_if_missing ubuntu-drivers-common
sudo ubuntu-drivers autoinstall 2>/dev/null || log_warning "NVIDIA auto-install had warnings"
log_success "NVIDIA drivers configured"
# NVIDIA Prime (hybrid GPU switching for laptops with iGPU + dGPU)
apt_install_if_missing nvidia-prime
# Blacklist Nouveau to prevent conflicts with proprietary NVIDIA driver
NOUVEAU_BLACKLIST="/etc/modprobe.d/blacklist-nouveau.conf"
if [ ! -f "$NOUVEAU_BLACKLIST" ]; then
log_info "Blacklisting Nouveau..."
printf 'blacklist nouveau\noptions nouveau modeset=0\n' | sudo tee "$NOUVEAU_BLACKLIST" >/dev/null
log_success "Nouveau blacklisted"
else
log_skip "Nouveau already blacklisted"
fi
# NVIDIA DRM modesetting (required for Wayland, PRIME sync, suspend/resume)
GRUB_FILE="/etc/default/grub"
if [ -f "$GRUB_FILE" ] && ! grep -q "nvidia-drm.modeset=1" "$GRUB_FILE"; then
log_info "Enabling NVIDIA DRM modesetting..."
sudo sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="\(.*\)"/GRUB_CMDLINE_LINUX_DEFAULT="\1 nvidia-drm.modeset=1"/' "$GRUB_FILE"
sudo update-grub 2>/dev/null || log_warning "update-grub had warnings"
log_success "NVIDIA DRM modesetting enabled"
else
log_skip "NVIDIA DRM modesetting already configured"
fi
# NVIDIA dynamic power management (dGPU powers down when idle, saves battery)
NVIDIA_POWER="/etc/modprobe.d/nvidia-power.conf"
if [ ! -f "$NVIDIA_POWER" ]; then
log_info "Configuring NVIDIA power management..."
echo 'options nvidia NVreg_DynamicPowerManagement=0x02' | sudo tee "$NVIDIA_POWER" >/dev/null
log_success "NVIDIA power management configured"
else
log_skip "NVIDIA power management already configured"
fi
# Mesa drivers (bleeding edge, includes RADV for AMD iGPU Vulkan)
log_info "Installing Mesa drivers..."
sudo add-apt-repository -y ppa:oibaf/graphics-drivers >/dev/null 2>&1 || true
sudo apt update -qq
sudo apt -y upgrade -qq
log_success "Mesa drivers configured"
# Vulkan support (64-bit + 32-bit for both NVIDIA and AMD GPUs)
log_info "Installing Vulkan support..."
VULKAN_PKGS=(
vulkan-tools
libvulkan1
"libvulkan1:i386"
mesa-vulkan-drivers
"mesa-vulkan-drivers:i386"
"libgl1-mesa-dri:i386"
)
for pkg in "${VULKAN_PKGS[@]}"; do
apt_install_if_missing "$pkg"
done
log_success "Vulkan support installed"
# Kernel parameters for gaming (SteamOS-aligned values)
GAMING_SYSCTL="/etc/sysctl.d/99-gaming.conf"
if [ ! -f "$GAMING_SYSCTL" ]; then
log_info "Configuring gaming kernel parameters..."
sudo tee "$GAMING_SYSCTL" >/dev/null <<'SYSCTL'
# Memory map limit for large games (Unity, Unreal Engine)
vm.max_map_count=2147483642
# Prefer keeping game data in RAM (default 60, lower = less swap)
vm.swappiness=10
# Disable proactive memory compaction (reduces random latency spikes)
vm.compaction_proactiveness=0
# Reduce dirty page ratios to prevent I/O stuttering during gameplay
vm.dirty_ratio=5
vm.dirty_background_ratio=5
# Disable split-lock mitigation (causes severe perf loss in some Proton games)
kernel.split_lock_mitigate=0
SYSCTL
sudo sysctl --system >/dev/null 2>&1
log_success "Gaming kernel parameters configured"
else
log_skip "Gaming kernel parameters already configured"
fi
# Raise file descriptor limits (Wine/Proton can exceed default 1024)
GAMING_LIMITS="/etc/security/limits.d/99-gaming.conf"
if [ ! -f "$GAMING_LIMITS" ]; then
log_info "Configuring file descriptor limits..."
printf '* soft nofile 1048576\n* hard nofile 1048576\n' | sudo tee "$GAMING_LIMITS" >/dev/null
log_success "File descriptor limits configured"
else
log_skip "File descriptor limits already configured"
fi
# Controller support (udev rules for PS4, PS5, Switch, Steam Controller)
apt_install_if_missing steam-devices
# Add user to input group for controller access
if ! groups "$USER" | grep -qw input; then
sudo usermod -a -G input "$USER"
log_success "User added to input group"
fi
# Desktop-only gaming packages (skip in CI)
if [[ -z "$CI" ]]; then
# Gaming performance tools
log_info "Installing gaming tools..."
apt_install_if_missing gamemode
apt_install_if_missing "libgamemodeauto0:i386"
apt_install_if_missing mangohud
apt_install_if_missing gamescope
apt_install_if_missing protontricks
log_success "Gaming tools installed"
# Steam (from Valve's official repository)
if ! pkg_installed steam-launcher; then
log_info "Installing Steam..."
echo "steam steam/question select I AGREE" | sudo debconf-set-selections
echo "steam steam/license note ''" | sudo debconf-set-selections
apt_add_key_and_repo \
"https://repo.steampowered.com/steam/archive/stable/steam.gpg" \
"/etc/apt/keyrings/steam.gpg" \
"deb [arch=amd64,i386 signed-by=/etc/apt/keyrings/steam.gpg] https://repo.steampowered.com/steam/ stable steam" \
"/etc/apt/sources.list.d/steam-stable.list" \
"steam-launcher"
log_success "Steam installed"
else
log_skip "Steam already installed"
fi
# ProtonUp-Qt (manages GE-Proton custom builds for better game compatibility)
apt_install_if_missing flatpak
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo 2>/dev/null || true
if ! flatpak list 2>/dev/null | grep -q "net.davidotek.pupgui2"; then
log_info "Installing ProtonUp-Qt..."
flatpak install -y --noninteractive flathub net.davidotek.pupgui2 2>/dev/null || log_warning "ProtonUp-Qt install had warnings"
log_success "ProtonUp-Qt installed"
else
log_skip "ProtonUp-Qt already installed"
fi
# GE-Proton (custom Proton with extra game patches, auto-download latest)
PROTON_GE_DIR="$HOME/.steam/steam/compatibilitytools.d"
mkdir -p "$PROTON_GE_DIR"
if [ -z "$(command ls -A "$PROTON_GE_DIR" 2>/dev/null)" ]; then
log_info "Installing latest GE-Proton..."
GE_LATEST=$(curl -sL --connect-timeout 10 --max-time 30 \
https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases/latest \
| grep tag_name | cut -d '"' -f 4)
if [ -n "$GE_LATEST" ]; then
curl -#fLo "/tmp/${GE_LATEST}.tar.gz" --connect-timeout 10 --max-time 300 \
"https://github.com/GloriousEggroll/proton-ge-custom/releases/download/${GE_LATEST}/${GE_LATEST}.tar.gz"
tar -xzf "/tmp/${GE_LATEST}.tar.gz" -C "$PROTON_GE_DIR"
rm -f "/tmp/${GE_LATEST}.tar.gz"
log_success "GE-Proton ${GE_LATEST} installed"
else
log_warning "Could not determine latest GE-Proton version"
fi
else
log_skip "GE-Proton already installed"
fi
else
log_skip "Gaming tools and Steam (CI environment)"
fi
else
log_skip "GPU drivers and gaming (not supported on $(dpkg --print-architecture))"
fi
;;
"Darwin")
log_info "System: macOS ($(uname -m))"
############################################################################
# Rosetta 2 (Apple Silicon)
############################################################################
if [ "$(uname -m)" = "arm64" ] && ! /usr/bin/pgrep oahd >/dev/null 2>&1; then
log_info "Installing Rosetta 2..."
/usr/sbin/softwareupdate --install-rosetta --agree-to-license 2>/dev/null || true
log_success "Rosetta 2 installed"
fi
############################################################################
# Homebrew
############################################################################
if ! cmd_exists brew; then
log_info "Installing Homebrew..."
CI=1 /bin/bash -c "$(curl -fsSL --connect-timeout 10 --max-time 120 https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
log_success "Homebrew installed"
else
log_skip "Homebrew already installed"
fi
case "$(uname -m)" in
"arm64") __setup_homebrew "/opt/homebrew" ;;
"x86_64") __setup_homebrew "/usr/local" ;;
esac
############################################################################
# Dotfiles repository
############################################################################
github_repo_sync "https://github.com/gufranco/dotfiles.git" "$HOME/.dotfiles" "dotfiles"
############################################################################
# Homebrew packages
############################################################################
log_info "Installing Homebrew packages..."
brew update
brew bundle --file "$HOME/.dotfiles/Brewfile" || log_warning "Brewfile sync had failures"
brew bundle cleanup --force --file "$HOME/.dotfiles/Brewfile" || true
brew upgrade --greedy --force || log_warning "Brew upgrade had failures"
brew cleanup -s || true
log_success "Homebrew packages updated"
############################################################################
# torrentzip (Go, not in Homebrew)
############################################################################
if ! cmd_exists torrentzip; then
log_info "Installing torrentzip..."
if cmd_exists go; then
go install github.com/uwedeportivo/torrentzip/cmd/torrentzip@latest
log_success "torrentzip installed"
else
log_warning "Go not found, skipping torrentzip"
fi
else
log_skip "torrentzip already installed"
fi
############################################################################
# pipx CLI tools (Pipxfile)
############################################################################
if cmd_exists pipx && [ -f "$HOME/.dotfiles/Pipxfile" ]; then
log_info "Installing pipx tools..."
pipx_ok=0
pipx_skip=0
pipx_fail=0
while IFS= read -r pkg || [ -n "$pkg" ]; do
[[ -z "$pkg" || "$pkg" == \#* ]] && continue
if pipx list --short 2>/dev/null | awk '{print $1}' | grep -qx "$pkg"; then
((pipx_skip++)) || true
else
if pipx install "$pkg" --quiet 2>/dev/null; then
((pipx_ok++)) || true
else
log_warning "Failed to install pipx package: $pkg"
((pipx_fail++)) || true
fi
fi
done < "$HOME/.dotfiles/Pipxfile"
if [ "$pipx_fail" -eq 0 ]; then
log_success "pipx tools installed (new: $pipx_ok, already present: $pipx_skip)"
else
log_warning "pipx tools installed with $pipx_fail failure(s)"
fi
else
log_skip "pipx not found or Pipxfile missing, skipping pipx tools"
fi
############################################################################
# Bash
############################################################################
if ! grep -q "$HOMEBREW_PREFIX/bin/bash" /etc/shells 2>/dev/null; then
log_info "Adding Homebrew bash to /etc/shells..."
echo "$HOMEBREW_PREFIX/bin/bash" | sudo tee -a /etc/shells >/dev/null
log_success "Bash added to /etc/shells"
fi
############################################################################
# Zsh
############################################################################
if ! grep -q "$HOMEBREW_PREFIX/bin/zsh" /etc/shells 2>/dev/null; then
log_info "Adding Homebrew zsh to /etc/shells..."
echo "$HOMEBREW_PREFIX/bin/zsh" | sudo tee -a /etc/shells >/dev/null
log_success "Zsh added to /etc/shells"
fi
if [ "$SHELL" != "$HOMEBREW_PREFIX/bin/zsh" ]; then
chsh -s "$HOMEBREW_PREFIX/bin/zsh" || true
log_success "Shell changed to Zsh"
else
log_skip "Shell already Zsh"
fi
;;
esac
############################################################################
# Universal configurations (Linux + macOS)
############################################################################
############################################################################
# Node.js
############################################################################
log_info "Setting up Node.js configs..."
safe_link "$HOME/.dotfiles/nodejs/.npmrc" "$HOME/.npmrc"
safe_link "$HOME/.dotfiles/nodejs/.yarnrc.yml" "$HOME/.yarnrc.yml"
safe_link "$HOME/.dotfiles/nodejs/.pnpmrc" "$HOME/.pnpmrc"
############################################################################
# mise
############################################################################
log_info "Setting up mise..."
mkdir -p "$HOME/.config/mise"
safe_link "$HOME/.dotfiles/mise/config.toml" "$HOME/.config/mise/config.toml"
if cmd_exists mise; then
mise trust "$HOME/.dotfiles/mise/config.toml" >/dev/null 2>&1 || true
if mise install --yes 2>/dev/null; then
log_success "mise runtimes installed"
else
log_warning "mise install had warnings"
fi
fi
############################################################################
# Oh My Zsh
############################################################################
log_info "Setting up Oh My Zsh..."
safe_link "$HOME/.dotfiles/zsh/.zshrc" "$HOME/.zshrc"
github_repo_sync "https://github.com/robbyrussell/oh-my-zsh.git" "$HOME/.oh-my-zsh" "Oh My Zsh"
github_repo_sync "https://github.com/zsh-users/zsh-autosuggestions.git" "$HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions" "zsh-autosuggestions"
github_repo_sync "https://github.com/zsh-users/zsh-syntax-highlighting.git" "$HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting" "zsh-syntax-highlighting"
github_repo_sync "https://github.com/zsh-users/zsh-completions.git" "$HOME/.oh-my-zsh/custom/plugins/zsh-completions" "zsh-completions"
github_repo_sync "https://github.com/Aloxaf/fzf-tab.git" "$HOME/.oh-my-zsh/custom/plugins/fzf-tab" "fzf-tab"
github_repo_sync "https://github.com/denysdovhan/spaceship-prompt.git" "$HOME/.oh-my-zsh/custom/themes/spaceship-prompt" "spaceship-prompt"
safe_link "$HOME/.oh-my-zsh/custom/themes/spaceship-prompt/spaceship.zsh-theme" "$HOME/.oh-my-zsh/custom/themes/spaceship.zsh-theme"
############################################################################
# Git
############################################################################
log_info "Setting up Git..."
safe_link "$HOME/.dotfiles/git/.gitconfig" "$HOME/.gitconfig"
############################################################################
# Vim & Neovim (shared config)
############################################################################
log_info "Setting up Vim & Neovim..."
safe_link "$HOME/.dotfiles/nvim" "$HOME/.vim"
safe_link "$HOME/.dotfiles/nvim/init.vim" "$HOME/.vimrc"
safe_link "$HOME/.dotfiles/nvim" "$HOME/.config/nvim"
############################################################################
# GPG
############################################################################
log_info "Setting up GPG..."
safe_link "$HOME/.dotfiles/gnupg" "$HOME/.gnupg"
chmod 700 "$HOME/.gnupg" 2>/dev/null || log_warning "Failed to set gnupg permissions"
chmod 400 "$HOME/.gnupg/keys/"* 2>/dev/null || true
case "$(uname)" in
"Linux")
safe_link "$HOME/.dotfiles/gnupg/gpg-agent-linux.conf" "$HOME/.gnupg/gpg-agent.conf"
;;
"Darwin")
safe_link "$HOME/.dotfiles/gnupg/gpg-agent-macos-$(uname -m).conf" "$HOME/.gnupg/gpg-agent.conf"
;;
esac
# Import GPG keys (idempotent - import is safe to repeat)
for key in "$HOME/.gnupg/keys/"*.pgp; do
[ -f "$key" ] && { gpg --batch --yes --quiet --import "$key" 2>/dev/null || log_warning "Failed to import GPG key: $(basename "$key")"; }
done
############################################################################
# SSH
############################################################################
log_info "Setting up SSH..."
safe_link "$HOME/.dotfiles/ssh" "$HOME/.ssh"
chmod 700 "$HOME/.ssh" 2>/dev/null || log_warning "Failed to set ssh permissions"
chmod 600 "$HOME/.ssh/config" 2>/dev/null || true
chmod 400 "$HOME/.ssh/id_"* 2>/dev/null || true
chmod 644 "$HOME/.ssh/"*.pub 2>/dev/null || true
############################################################################
# Neomutt
############################################################################
log_info "Setting up Neomutt..."
safe_link "$HOME/.dotfiles/mutt/.muttrc" "$HOME/.muttrc"
safe_link "$HOME/.dotfiles/mutt" "$HOME/.mutt"
safe_link "$HOME/.dotfiles/mailcap/.mailcap" "$HOME/.mailcap"
############################################################################
# Tmux
############################################################################
log_info "Setting up Tmux..."
safe_link "$HOME/.dotfiles/tmux/.tmux.conf" "$HOME/.tmux.conf"
safe_link "$HOME/.dotfiles/tmux" "$HOME/.tmux"
############################################################################
# Curl
############################################################################
log_info "Setting up Curl..."
safe_link "$HOME/.dotfiles/curl/.curlrc" "$HOME/.curlrc"
############################################################################
# Wget
############################################################################
log_info "Setting up Wget..."
safe_link "$HOME/.dotfiles/wget/.wgetrc" "$HOME/.wgetrc"
############################################################################
# Readline
############################################################################
log_info "Setting up Readline..."
safe_link "$HOME/.dotfiles/readline/.inputrc" "$HOME/.inputrc"
############################################################################
# htop
############################################################################
log_info "Setting up htop..."
safe_link "$HOME/.dotfiles/htop/htoprc" "$HOME/.config/htop/htoprc"
############################################################################
# Ripgrep
############################################################################
log_info "Setting up Ripgrep..."
safe_link "$HOME/.dotfiles/ripgrep/.ripgreprc" "$HOME/.ripgreprc"
############################################################################
# fd
############################################################################
log_info "Setting up fd..."
safe_link "$HOME/.dotfiles/fd/.fdrc" "$HOME/.fdrc"
############################################################################
# Telnet
############################################################################
log_info "Setting up Telnet..."
safe_link "$HOME/.dotfiles/telnet/.telnetrc" "$HOME/.telnetrc"
############################################################################
# Kitty
############################################################################
log_info "Setting up Kitty..."
safe_link "$HOME/.dotfiles/kitty/kitty.conf" "$HOME/.config/kitty/kitty.conf"
safe_link "$HOME/.dotfiles/kitty/themes" "$HOME/.config/kitty/themes"
############################################################################
# Ghostty
############################################################################
log_info "Setting up Ghostty..."
safe_link "$HOME/.dotfiles/ghostty" "$HOME/.config/ghostty"
if [ "$(uname)" = "Darwin" ]; then
mkdir -p "$HOME/Library/Application Support/com.mitchellh.ghostty"
safe_link "$HOME/.config/ghostty/config" "$HOME/Library/Application Support/com.mitchellh.ghostty/config"
fi
############################################################################
# Bat
############################################################################
log_info "Setting up Bat..."
safe_link "$HOME/.dotfiles/bat/config" "$HOME/.config/bat/config"
safe_link "$HOME/.dotfiles/bat/themes" "$HOME/.config/bat/themes"
if cmd_exists bat; then bat cache --build >/dev/null 2>&1 || true; fi
############################################################################
# eza
############################################################################
log_info "Setting up eza..."
safe_link "$HOME/.dotfiles/eza" "$HOME/.config/eza"
############################################################################
# cmus
############################################################################
log_info "Setting up cmus..."
safe_link "$HOME/.dotfiles/cmus/rc" "$HOME/.config/cmus/rc"
############################################################################
# GitHub CLI