-
-
Notifications
You must be signed in to change notification settings - Fork 196
Expand file tree
/
Copy pathinstall
More file actions
executable file
·2433 lines (1930 loc) · 73.1 KB
/
install
File metadata and controls
executable file
·2433 lines (1930 loc) · 73.1 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
# Install these dotfiles, run: ./install --help for help and examples.
set -o errexit
# Figure out the dotfiles path and the state of the system.
FIRST_RUN=
DOTFILES_PATH_CONFIGURED="${DOTFILES_PATH:-}"
[ -z "${DOTFILES_PATH}" ] && FIRST_RUN=1
DOTFILES_PATH="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
# shellcheck disable=SC1091
. "${DOTFILES_PATH}/bootstrap"
# shellcheck disable=SC1091
. "${DOTFILES_PATH}/install-config"
# Only run these when calling the script, not sourcing it.
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
# shellcheck disable=SC1091
. "${DOTFILES_PATH}/_install/default/packages/arch"
# shellcheck disable=SC1091
. "${DOTFILES_PATH}/_install/default/packages/debian"
# shellcheck disable=SC1091
. "${DOTFILES_PATH}/_install/default/packages/darwin"
# shellcheck disable=SC1091
. "${DOTFILES_PATH}/_install/default/mise_languages"
# shellcheck disable=SC1091
. "${DOTFILES_PATH}/_install/default/scripts"
# shellcheck disable=SC1091
. "${DOTFILES_PATH}/_install/default/config_install"
# shellcheck disable=SC1091
. "${DOTFILES_PATH}/_install/default/sudoers_entries"
# shellcheck disable=SC1091
. "${DOTFILES_PATH}/_install/default/systemd_services"
# This will get optionally populated later, it essentially does a git pull
# to pull in the latest changes locally.
PULL=
# This will get optionally populated later, it combines pulling in the latest
# updates and running the install script.
PULL_UPDATE=
# This will get optionally populated later.
SKIP_SYSTEM_PACKAGES=
DOTFILES_CLONE_URL="${DOTFILES_CLONE_URL:-https://github.com/nickjj/dotfiles}"
DOTFILES_UPSTREAM_URL="${DOTFILES_UPSTREAM_URL:-https://github.com/nickjj/dotfiles}"
DOTFILES_BRANCH="${DOTFILES_BRANCH:-master}"
YOUR_NAME="${YOUR_NAME:-}"
YOUR_EMAIL="${YOUR_EMAIL:-}"
# Do we want to auto confirm installing config files during installation?
CONFIG_INSTALL_AUTO_CONFIRM="${CONFIG_INSTALL_AUTO_CONFIRM:-}"
# Do we want to auto confirm packages during installation?
PACKAGES_AUTO_CONFIRM="${PACKAGES_AUTO_CONFIRM:-}"
# Is the variable defined as an array or string? -z doesn't reliably work
# on arrays since it only looks at the first element.
if [[ "${PACKAGES_PACMAN+x}" ]]; then
# If the variable is defined with an empty value, the intent is to
# override the defaults with nothing.
[ -z "${PACKAGES_PACMAN}" ] && PACKAGES_PACMAN=()
else
PACKAGES_PACMAN=("${DEFAULT_PACKAGES_PACMAN[@]}")
fi
if [[ "${PACKAGES_PACMAN_EXTRAS+x}" ]]; then
[ -z "${PACKAGES_PACMAN_EXTRAS}" ] && PACKAGES_PACMAN_EXTRAS=()
else
PACKAGES_PACMAN_EXTRAS=()
fi
if [[ "${PACKAGES_PACMAN_SKIP+x}" ]]; then
[ -z "${PACKAGES_PACMAN_SKIP}" ] && PACKAGES_PACMAN_SKIP=()
else
PACKAGES_PACMAN_SKIP=()
fi
if [[ "${PACKAGES_PACMAN_GUI+x}" ]]; then
[ -z "${PACKAGES_PACMAN_GUI}" ] && PACKAGES_PACMAN_GUI=()
else
PACKAGES_PACMAN_GUI=("${DEFAULT_PACKAGES_PACMAN_GUI[@]}")
fi
if [[ "${PACKAGES_PACMAN_GUI_EXTRAS+x}" ]]; then
[ -z "${PACKAGES_PACMAN_GUI_EXTRAS}" ] && PACKAGES_PACMAN_GUI_EXTRAS=()
else
PACKAGES_PACMAN_GUI_EXTRAS=()
fi
if [[ "${PACKAGES_PACMAN_GUI_SKIP+x}" ]]; then
[ -z "${PACKAGES_PACMAN_GUI_SKIP}" ] && PACKAGES_PACMAN_GUI_SKIP=()
else
PACKAGES_PACMAN_GUI_SKIP=()
fi
if [[ "${PACKAGES_AUR+x}" ]]; then
[ -z "${PACKAGES_AUR}" ] && PACKAGES_AUR=()
else
PACKAGES_AUR=()
fi
if [[ "${PACKAGES_AUR_EXTRAS+x}" ]]; then
[ -z "${PACKAGES_AUR_EXTRAS}" ] && PACKAGES_AUR_EXTRAS=()
else
PACKAGES_AUR_EXTRAS=()
fi
if [[ "${PACKAGES_AUR_SKIP+x}" ]]; then
[ -z "${PACKAGES_AUR_SKIP}" ] && PACKAGES_AUR_SKIP=()
else
PACKAGES_AUR_SKIP=()
fi
if [[ "${PACKAGES_AUR_GUI+x}" ]]; then
[ -z "${PACKAGES_AUR_GUI}" ] && PACKAGES_AUR_GUI=()
else
PACKAGES_AUR_GUI=("${DEFAULT_PACKAGES_AUR_GUI[@]}")
fi
if [[ "${PACKAGES_AUR_GUI_EXTRAS+x}" ]]; then
[ -z "${PACKAGES_AUR_GUI_EXTRAS}" ] && PACKAGES_AUR_GUI_EXTRAS=()
else
PACKAGES_AUR_GUI_EXTRAS=()
fi
if [[ "${PACKAGES_AUR_GUI_SKIP+x}" ]]; then
[ -z "${PACKAGES_AUR_GUI_SKIP}" ] && PACKAGES_AUR_GUI_SKIP=()
else
PACKAGES_AUR_GUI_SKIP=()
fi
if [[ "${PACKAGES_APT+x}" ]]; then
[ -z "${PACKAGES_APT}" ] && PACKAGES_APT=()
else
PACKAGES_APT=("${DEFAULT_PACKAGES_APT[@]}")
fi
if [[ "${PACKAGES_APT_EXTRAS+x}" ]]; then
[ -z "${PACKAGES_APT_EXTRAS}" ] && PACKAGES_APT_EXTRAS=()
else
PACKAGES_APT_EXTRAS=()
fi
if [[ "${PACKAGES_APT_SKIP+x}" ]]; then
[ -z "${PACKAGES_APT_SKIP}" ] && PACKAGES_APT_SKIP=()
else
PACKAGES_APT_SKIP=()
fi
if [[ "${PACKAGES_BREW+x}" ]]; then
[ -z "${PACKAGES_BREW}" ] && PACKAGES_BREW=()
else
PACKAGES_BREW=("${DEFAULT_PACKAGES_BREW[@]}")
fi
if [[ "${PACKAGES_BREW_EXTRAS+x}" ]]; then
[ -z "${PACKAGES_BREW_EXTRAS}" ] && PACKAGES_BREW_EXTRAS=()
else
PACKAGES_BREW_EXTRAS=()
fi
if [[ "${PACKAGES_BREW_SKIP+x}" ]]; then
[ -z "${PACKAGES_BREW_SKIP}" ] && PACKAGES_BREW_SKIP=()
else
PACKAGES_BREW_SKIP=()
fi
if [[ "${PACKAGES_BREW_CASK+x}" ]]; then
[ -z "${PACKAGES_BREW_CASK}" ] && PACKAGES_BREW_CASK=()
else
PACKAGES_BREW_CASK=("${DEFAULT_PACKAGES_BREW_CASK[@]}")
fi
if [[ "${PACKAGES_BREW_CASK_EXTRAS+x}" ]]; then
[ -z "${PACKAGES_BREW_CASK_EXTRAS}" ] && PACKAGES_BREW_CASK_EXTRAS=()
else
PACKAGES_BREW_CASK_EXTRAS=()
fi
if [[ "${PACKAGES_BREW_CASK_SKIP+x}" ]]; then
[ -z "${PACKAGES_BREW_CASK_SKIP}" ] && PACKAGES_BREW_CASK_SKIP=()
else
PACKAGES_BREW_CASK_SKIP=()
fi
if [[ "${MISE_ARCH+x}" ]]; then
[ -z "${MISE_ARCH}" ] && MISE_ARCH=()
else
MISE_ARCH=("${DEFAULT_MISE_ARCH[@]}")
fi
if [[ "${MISE_ARCH_EXTRAS+x}" ]]; then
[ -z "${MISE_ARCH_EXTRAS}" ] && MISE_ARCH_EXTRAS=()
else
MISE_ARCH_EXTRAS=()
fi
if [[ "${MISE_ARCH_SKIP+x}" ]]; then
[ -z "${MISE_ARCH_SKIP}" ] && MISE_ARCH_SKIP=()
else
MISE_ARCH_SKIP=()
fi
if [[ "${MISE_DEBIAN+x}" ]]; then
[ -z "${MISE_DEBIAN}" ] && MISE_DEBIAN=()
else
MISE_DEBIAN=("${DEFAULT_MISE_DEBIAN[@]}")
fi
if [[ "${MISE_DEBIAN_EXTRAS+x}" ]]; then
[ -z "${MISE_DEBIAN_EXTRAS}" ] && MISE_DEBIAN_EXTRAS=()
else
MISE_DEBIAN_EXTRAS=()
fi
if [[ "${MISE_DEBIAN_SKIP+x}" ]]; then
[ -z "${MISE_DEBIAN_SKIP}" ] && MISE_DEBIAN_SKIP=()
else
MISE_DEBIAN_SKIP=()
fi
if [[ "${MISE_DARWIN+x}" ]]; then
[ -z "${MISE_DARWIN}" ] && MISE_DARWIN=()
else
MISE_DARWIN=("${DEFAULT_MISE_DARWIN[@]}")
fi
if [[ "${MISE_DARWIN_EXTRAS+x}" ]]; then
[ -z "${MISE_DARWIN_EXTRAS}" ] && MISE_DARWIN_EXTRAS=()
else
MISE_DARWIN_EXTRAS=()
fi
if [[ "${MISE_DARWIN_SKIP+x}" ]]; then
[ -z "${MISE_DARWIN_SKIP}" ] && MISE_DARWIN_SKIP=()
else
MISE_DARWIN_SKIP=()
fi
if [[ ! "${MISE_LANGUAGES+x}" ]]; then
unset MISE_LANGUAGES
declare -n MISE_LANGUAGES=DEFAULT_MISE_LANGUAGES
fi
if [[ ! "${MISE_LANGUAGES_EXTRAS+x}" ]]; then
declare -A MISE_LANGUAGES_EXTRAS
fi
if [[ "${SCRIPTS_INSTALL+x}" ]]; then
[ -z "${SCRIPTS_INSTALL}" ] && SCRIPTS_INSTALL=()
else
SCRIPTS_INSTALL=("${DEFAULT_SCRIPTS_INSTALL[@]}")
fi
if [[ "${SCRIPTS_INSTALL_EXTRAS+x}" ]]; then
[ -z "${SCRIPTS_INSTALL_EXTRAS}" ] && SCRIPTS_INSTALL_EXTRAS=()
else
SCRIPTS_INSTALL_EXTRAS=()
fi
if [[ "${SCRIPTS_INSTALL_SKIP+x}" ]]; then
[ -z "${SCRIPTS_INSTALL_SKIP}" ] && SCRIPTS_INSTALL_SKIP=()
else
SCRIPTS_INSTALL_SKIP=()
fi
if [[ "${CONFIG_INSTALL+x}" ]]; then
[ -z "${CONFIG_INSTALL}" ] && CONFIG_INSTALL=()
else
CONFIG_INSTALL=("${DEFAULT_CONFIG_INSTALL[@]}")
fi
if [[ "${CONFIG_INSTALL_EXTRAS+x}" ]]; then
[ -z "${CONFIG_INSTALL_EXTRAS}" ] && CONFIG_INSTALL_EXTRAS=()
else
CONFIG_INSTALL_EXTRAS=()
fi
if [[ "${CONFIG_INSTALL_GUI_LINUX+x}" ]]; then
[ -z "${CONFIG_INSTALL_GUI_LINUX}" ] && CONFIG_INSTALL_GUI_LINUX=()
else
CONFIG_INSTALL_GUI_LINUX=("${DEFAULT_CONFIG_INSTALL_GUI_LINUX[@]}")
fi
if [[ "${CONFIG_INSTALL_GUI_LINUX_EXTRAS+x}" ]]; then
[ -z "${CONFIG_INSTALL_GUI_LINUX_EXTRAS}" ] && CONFIG_INSTALL_GUI_LINUX_EXTRAS=()
else
CONFIG_INSTALL_GUI_LINUX_EXTRAS=()
fi
if [[ "${CONFIG_INSTALL_ARCH+x}" ]]; then
[ -z "${CONFIG_INSTALL_ARCH}" ] && CONFIG_INSTALL_ARCH=()
else
CONFIG_INSTALL_ARCH=("${DEFAULT_CONFIG_INSTALL_ARCH[@]}")
fi
if [[ "${CONFIG_INSTALL_ARCH_EXTRAS+x}" ]]; then
[ -z "${CONFIG_INSTALL_ARCH_EXTRAS}" ] && CONFIG_INSTALL_ARCH_EXTRAS=()
else
CONFIG_INSTALL_ARCH_EXTRAS=()
fi
if [[ "${CONFIG_INSTALL_WSL+x}" ]]; then
[ -z "${CONFIG_INSTALL_WSL}" ] && CONFIG_INSTALL_WSL=()
else
CONFIG_INSTALL_WSL=("${DEFAULT_CONFIG_INSTALL_WSL[@]}")
fi
if [[ "${CONFIG_INSTALL_WSL_EXTRAS+x}" ]]; then
[ -z "${CONFIG_INSTALL_WSL_EXTRAS}" ] && CONFIG_INSTALL_WSL_EXTRAS=()
else
CONFIG_INSTALL_WSL_EXTRAS=()
fi
if [[ ! "${SUDOERS_ENTRIES+x}" ]]; then
unset SUDOERS_ENTRIES
declare -n SUDOERS_ENTRIES=DEFAULT_SUDOERS_ENTRIES
fi
if [[ ! "${SUDOERS_ENTRIES_EXTRAS+x}" ]]; then
declare -A SUDOERS_ENTRIES_EXTRAS
fi
if [[ "${SYSTEMD_ENABLED_SERVICES+x}" ]]; then
[ -z "${SYSTEMD_ENABLED_SERVICES}" ] && SYSTEMD_ENABLED_SERVICES=()
else
SYSTEMD_ENABLED_SERVICES=("${DEFAULT_SYSTEMD_ENABLED_SERVICES[@]}")
fi
if [[ "${SYSTEMD_ENABLED_SERVICES_EXTRAS+x}" ]]; then
[ -z "${SYSTEMD_ENABLED_SERVICES_EXTRAS}" ] && SYSTEMD_ENABLED_SERVICES_EXTRAS=()
else
SYSTEMD_ENABLED_SERVICES_EXTRAS=()
fi
fi
# -----------------------------------------------------------------------------
# Helper functions
# -----------------------------------------------------------------------------
_curl() {
# We can't depend on this being on the system path yet.
"${DOTFILES_PATH}/.local/bin/rcurl" "${@}"
}
_package_install() {
local manager="${1}"
shift
local packages=("${@}")
((${#packages[@]} == 0)) && return
local -A confirm_map=(
["pacman"]="--noconfirm"
["yay"]="--noconfirm"
["apt"]="--yes"
)
local -a confirm_flag=()
if [[ "${PACKAGES_AUTO_CONFIRM}" == "1" && -v confirm_map["${manager}"] ]]; then
confirm_flag+=("${confirm_map["${manager}"]}")
fi
case "${manager}" in
pacman)
if [ "${PACKAGES_AUTO_CONFIRM}" != "1" ]; then
printf "\n:: Arch news\n\n"
yay -Pwwq || true
cat <<EOF
---
View the official Arch news site: https://archlinux.org/news/
EOF
fi
sudo pacman -Syu "${confirm_flag[@]}" --needed "${packages[@]}"
;;
yay)
yay -S "${confirm_flag[@]}" --needed "${packages[@]}"
;;
apt)
sudo apt-get update && sudo apt-get install "${confirm_flag[@]}" --no-install-recommends "${packages[@]}"
;;
brew)
brew install "${packages[@]}"
;;
brew-cask)
brew install --cask "${packages[@]}"
;;
mise)
mise use --global "${packages[@]}"
;;
esac
}
_install_packages_arch() {
# Ensure GUI packages get skipped unless GUI is enabled.
if [ "${GUI_ENABLED}" != "1" ]; then
PACKAGES_PACMAN_GUI=()
PACKAGES_PACMAN_GUI_EXTRAS=()
PACKAGES_PACMAN_GUI_SKIP=()
PACKAGES_AUR_GUI=()
PACKAGES_AUR_GUI_EXTRAS=()
PACKAGES_AUR_GUI_SKIP=()
fi
# Install Arch packages.
_package_install pacman "${PACKAGES_PACMAN[@]}" "${PACKAGES_PACMAN_EXTRAS[@]}" "${PACKAGES_PACMAN_GUI[@]}" "${PACKAGES_PACMAN_GUI_EXTRAS[@]}"
# Install Yay (AUR) if needed.
local yay_local_version=
yay_local_version="$(yay --version 2>/dev/null | cut -d " " -f 2 || true)"
local yay_latest_version=
yay_latest_version="$(git ls-remote --tags https://github.com/Jguer/yay.git |
grep -Eo "v?[0-9]+(\.[0-9]+){1,2}$" |
sort --version-sort | tail -n 1)"
if [ "${yay_local_version}" != "${yay_latest_version}" ]; then
local yay_download_path="/tmp/yay-install"
rm -rf "${yay_download_path}"
git clone https://aur.archlinux.org/yay-bin.git "${yay_download_path}"
cd "${yay_download_path}" && makepkg --syncdeps --install --noconfirm && cd -
rm -rf "${yay_download_path}"
fi
# Install AUR packages.
_package_install yay "${PACKAGES_AUR[@]}" "${PACKAGES_AUR_EXTRAS[@]}" "${PACKAGES_AUR_GUI[@]}" "${PACKAGES_AUR_GUI_EXTRAS[@]}"
# Install Mise packages.
_package_install mise "${MISE_ARCH[@]}" "${MISE_ARCH_EXTRAS[@]}"
# Install packages manually since they don't exist elsewhere.
# GIMP plugin: GEGL effects.
if [ "${GUI_ENABLED}" == "1" ]; then
local gegl_plugins_path="${XDG_DATA_HOME}/gegl-0.4/plug-ins"
local gegl_zip_path="/tmp/gegl_effectd.zip"
if [ ! -f "${gegl_plugins_path}/gegleffectspending.so" ]; then
echo
rm -rf "${gegl_zip_path}"
_curl "https://github.com/LinuxBeaver/Gimp_Layer_Effects_Text_Styler_Plugin_GEGL_Effects/releases/download/Continual_July22_2023/gegl_effects_linux_binaries_gegl_plugin.zip" -o "${gegl_zip_path}"
mkdir -p "${gegl_plugins_path}"
unzip "${gegl_zip_path}" -d "${gegl_plugins_path}"
rm -rf "${gegl_zip_path}"
fi
fi
}
_install_packages_debian() {
# Install APT packages.
_package_install apt "${PACKAGES_APT[@]}" "${PACKAGES_APT_EXTRAS[@]}"
# Install Mise.
sudo install -dm 755 /etc/apt/keyrings
_curl https://mise.jdx.dev/gpg-key.pub | gpg --dearmor | sudo tee /etc/apt/keyrings/mise-archive-keyring.gpg 1>/dev/null
echo "deb [signed-by=/etc/apt/keyrings/mise-archive-keyring.gpg arch=amd64] https://mise.jdx.dev/deb stable main" | sudo tee /etc/apt/sources.list.d/mise.list
sudo apt-get update && sudo apt-get install --yes --no-install-recommends mise
# Install Mise packages.
_package_install mise "${MISE_DEBIAN[@]}" "${MISE_DEBIAN_EXTRAS[@]}"
}
_install_packages_macos() {
local prefix="/opt/homebrew"
[[ "${CPU_ARCH}" == "x86_64" ]] && prefix="/usr/local"
# Ensure brew's paths are available for this script.
eval "$(${prefix}/bin/brew shellenv)"
# This gets written to your zprofile later but let's set it here for this shell.
export HOMEBREW_NO_ANALYTICS="1"
# Install Brew packages.
_package_install brew "${PACKAGES_BREW[@]}" "${PACKAGES_BREW_EXTRAS[@]}"
_package_install brew-cask "${PACKAGES_BREW_CASK[@]}" "${PACKAGES_BREW_CASK_EXTRAS[@]}"
# Install Mise packages.
_package_install mise "${MISE_DARWIN[@]}" "${MISE_DARWIN_EXTRAS[@]}"
}
_package_display() {
local heading="${1}"
shift
local packages=("${@}")
printf "\n%b%s:%b\n" "${C_BLUE}" "${heading}" "${C_RESET}"
# Let's show something so it doesn't look like it was blindly skipped.
if ((${#packages[@]} == 0)); then
echo " - Skipping, since there's no packages defined"
return
fi
for item in "${packages[@]}"; do
echo " - ${item}"
done
}
_skip_packages() {
# -n creates a reference by name to the variable passed in (allows optional mutation).
local -n packages_default="${1}"
local -n packages_skip="${2}"
local packages_filtered=()
declare -A packages_skip_map
for item in "${packages_skip[@]}"; do
packages_skip_map["${item}"]=1
done
for item in "${packages_default[@]}"; do
# Avoid adding skipped packages to the new filtered packages.
if [[ -z "${packages_skip_map[${item}]+x}" ]]; then
packages_filtered+=("${item}")
fi
done
packages_default=("${packages_filtered[@]}")
}
_display_packages() {
if [ "${OS_TYPE}" == "linux" ]; then
if [ "${OS_DISTRO}" == "arch" ]; then
_package_display "Pacman (default)" "${PACKAGES_PACMAN[@]}"
_package_display "Pacman (extras)" "${PACKAGES_PACMAN_EXTRAS[@]}"
[ "${GUI_ENABLED}" == "1" ] && _package_display "Pacman GUI (default)" "${PACKAGES_PACMAN_GUI[@]}"
[ "${GUI_ENABLED}" == "1" ] && _package_display "Pacman GUI (extras)" "${PACKAGES_PACMAN_GUI_EXTRAS[@]}"
_package_display "AUR (default)" "${PACKAGES_AUR[@]}"
_package_display "AUR (extras)" "${PACKAGES_AUR_EXTRAS[@]}"
[ "${GUI_ENABLED}" == "1" ] && _package_display "AUR GUI (default)" "${PACKAGES_AUR_GUI[@]}"
[ "${GUI_ENABLED}" == "1" ] && _package_display "AUR GUI (extras)" "${PACKAGES_AUR_GUI_EXTRAS[@]}"
_package_display "Mise (default)" "${MISE_ARCH[@]}"
_package_display "Mise (extras)" "${MISE_ARCH_EXTRAS[@]}"
elif [ "${OS_DISTRO}" == "debian" ]; then
_package_display "APT (default)" "${PACKAGES_APT[@]}"
_package_display "APT (extras)" "${PACKAGES_APT_EXTRAS[@]}"
_package_display "Mise (default)" "${MISE_DEBIAN[@]}"
_package_display "Mise (extras)" "${MISE_DEBIAN_EXTRAS[@]}"
fi
else
_package_display "Brew (default)" "${PACKAGES_BREW[@]}"
_package_display "Brew (extras)" "${PACKAGES_BREW_EXTRAS[@]}"
_package_display "Brew Cask (default)" "${PACKAGES_BREW_CASK[@]}"
_package_display "Brew Cask (extras)" "${PACKAGES_BREW_CASK_EXTRAS[@]}"
_package_display "Mise (default)" "${MISE_DARWIN[@]}"
_package_display "Mise (extras)" "${MISE_DARWIN_EXTRAS[@]}"
fi
}
_config_install() {
local str_find="${1:-}"
local str_replace="${2:-}"
# This is a huge hack to detect if the first 2 args being passed in are
# strings to do a template-like replacement. It can be refactored if the
# use case ever changes.
#
# Basically this detects if %WindowsUser is passed in to chop out the first
# 2 arguments for the string replacement so they are not commands.
if [[ "${str_find}" == "%"* ]]; then
shift 2
else
str_find=""
str_replace=""
fi
local commands=("${@}")
((${#commands[@]} == 0)) && return
for item in "${commands[@]}"; do
# A special rule to avoid breaking DNS in WSL 2.
if [[ "${OS_IN_WSL}" == "1" && "${OS_DISTRO}" = "arch" ]]; then
[[ "${item}" == *"stub-resolv.conf"* ]] && continue
fi
eval "${item//${str_find}/${str_replace}}"
done
}
_config_install_display() {
local heading="${1}"
local str_find="${2:-}"
local str_replace="${3:-}"
if [[ "${str_find}" == "%"* ]]; then
shift 3
else
str_find=""
str_replace=""
shift
fi
local commands=("${@}")
printf "\n%b%s:%b\n" "${C_BLUE}" "${heading}" "${C_RESET}"
# Let's show something so it doesn't look like it was blindly skipped.
if ((${#commands[@]} == 0)); then
echo " - Skipping, since there's no config install commands defined"
return
fi
local private_warning_count=0
for item in "${commands[@]}"; do
# Swap out placeholders like %WindowsUser% or any others that exist.
local expanded_item="${item//${str_find}/${str_replace}}"
# Perform shell expansion for each item such as variables, ~, * and more.
# We want these paths to be fully evaluated. This only evals the paths.
eval "set -- ${expanded_item}"
# The destination will always be the last item in the list so store it.
local destination="${*: -1}"
local sources=()
# Use reduction to build up a list of sources. If the path exists and it's
# not the destination then we know it's not a command or flag.
for arg in "${@}"; do
[[ "${arg}" != "${destination}" && -e "${arg}" ]] && sources+=("${arg}")
done
for source in "${sources[@]}"; do
# Skip paths that might produce false warnings like system paths, or
# anything users might put into the config variables that are custom.
[[ "${source}" != *"${DOTFILES_PATH}"* ]] && continue
local target_path="${destination}"
# If a star is used, it's pretty much guaranteed to be in the source,
# this handles source paths like bin/* or applications/* by looking
# into these directories for each file.
if [[ "${expanded_item}" == *"*"* ]]; then
target_path="${destination%/}/${source##*/}"
fi
# If target is a real file it will be empty. We're avoiding realpath -m
# since -m doesn't work on macOS.
local target
target="$(readlink "${target_path}" 2>/dev/null || true)"
# We're only interested in paths that exist so skip invalid paths.
[[ ! -e "${target_path}" && ! -L "${target_path}" ]] && continue
# We're only interested in real non-symlinked files being overwritten in
# cases where a star (glob) is used.
[[ "${expanded_item}" == *"*"* && -d "${target_path}" && ! -L "${target_path}" ]] && continue
# If the target doesn't contain our path then we know it's not managed by
# these dotfiles which is grounds for a warning.
if [[ "${target}" != *"${DOTFILES_PATH}"* ]]; then
((private_warning_count += 1))
((warning_count += 1))
_warning "'${target_path}' is not managed by these dotfiles" " - "
fi
done
# A special rule to avoid breaking DNS in WSL 2.
if [[ "${OS_IN_WSL}" == "1" && "${OS_DISTRO}" = "arch" ]]; then
[[ "${item}" == *"stub-resolv.conf"* ]] && continue
fi
done
if ((private_warning_count == 0)); then
echo " - All paths are managed by these dotfiles and are safe to overwrite"
fi
}
_theme_download() {
local theme_name="${1}"
local url="${2}"
local internal_directory_name="${3}"
local zip_file_name=
zip_file_name="$(basename "${url}" .zip)"
local zip_path="/tmp/${theme_name}.zip"
local theme_path="${XDG_DATA_HOME}/themes/${theme_name}"
if [ -d "${theme_path}" ]; then
echo "Skipping, since '${theme_name}' is already installed, delete it to reinstall or update"
else
rm -rf "${zip_path}" "/tmp/${zip_file_name}"
_curl "${url}" -o "${zip_path}"
unzip -q "${zip_path}" -d "/tmp"
mv "/tmp/${zip_file_name}/${internal_directory_name}" "${theme_path}"
rm -rf "${zip_path}" "/tmp/${zip_file_name}"
echo "'${theme_name}' has been installed"
fi
}
# -----------------------------------------------------------------------------
# Main functions
# -----------------------------------------------------------------------------
verify_dotfiles_path() {
if [ ! -d "${DOTFILES_PATH}" ]; then
_error "Current directory is invalid or was deleted, please run: cd ${DOTFILES_PATH}, aborting!"
fi
# A user moved their dotfiles, so let's maybe adjust their symlinks.
if [[ "${FIRST_RUN}" != "1" && "${DOTFILES_PATH}" != "${DOTFILES_PATH_CONFIGURED}" ]]; then
cat <<EOF
${C_MAGENTA}It looks like you moved your dotfiles directory:${C_RESET}
${C_WHITE}# Determined by this install script when you ran it.${C_RESET}
DOTFILES_PATH="${DOTFILES_PATH}"
${C_WHITE}# Found in '${XDG_CONFIG_HOME}/zsh/.zprofile.local' due to
# these dotfiles writing this value out for you automatically.${C_RESET}
DOTFILES_PATH_CONFIGURED="${DOTFILES_PATH_CONFIGURED}"
Since your config files are symlinked to the 2nd value they will all be broken.
This is no problem and we can fix this right now in an automated way.
${C_YELLOW}Do you want '${DOTFILES_PATH}' to be your new dotfiles path?
1) Yes, have this script automatically update your symlinks now
2) No, this script will quit and you'll go back to the original path or update them manually${C_RESET}
EOF
while true; do
printf "\nWhich option number would you like to pick? "
read -r option
case "${option}" in
1)
break
;;
2)
exit
;;
*) _error "'${option}' isn't a valid choice, pick 1 or 2" "" ;;
esac
done
local zprofile_path="${DOTFILES_PATH}/.config/zsh/.zprofile.local"
perl -pi -e "s|DOTFILES_PATH=\".*\"|DOTFILES_PATH=\"${DOTFILES_PATH}\"|g" "${zprofile_path}"
install_configs 1
fi
}
detect_and_prepare_gpu() {
_info "DETECT AND PREPARE GPU"
if [[ "${GUI_ENABLED}" != "1" || "${SKIP_SYSTEM_PACKAGES}" == "1" ]]; then
echo "Skipping, since this only runs when GUI_LINUX=1 is set with packages"
return
fi
local kernel_package=
case "${OS_KERNEL}" in
*cachyos-lts*)
kernel_package="linux-cachyos-lts-headers"
;;
*cachyos*)
kernel_package="linux-cachyos-headers"
;;
*arch*)
kernel_package="linux-headers"
;;
*lts*)
kernel_package="linux-lts-headers"
;;
*zen*)
kernel_package="linux-zen-headers"
;;
*hardened*)
kernel_package="linux-hardened-headers"
;;
*)
cat <<EOF
'${OS_KERNEL}' Linux kernel was detected but this script doesn't automatically
support it because it can't determine which linux-*-headers package to install.
If you feel this is a bug please open an issue at: ${DOTFILES_CLONE_URL}
EOF
_error "Unsupported Linux Kernel detected, aborting!"
;;
esac
local lspci_output=
lspci_output="$(lspci)"
local gpu_line=
gpu_line="$(grep --ignore-case -E "VGA|3D controller" <<<"${lspci_output}" | head -n 1 || true)"
[ -z "${gpu_line}" ] && _error "No GPU detected, aborting!"
echo "${gpu_line}"
case "${gpu_line}" in
*NVIDIA*)
PACKAGES_PACMAN+=("${kernel_package}")
# Avoid recreating the file every time, if a user changes it manually then
# let's not clobber their changes.
if [ ! -f /etc/modprobe.d/nvidia.conf ]; then
# This is taken from: https://wiki.archlinux.org/title/NVIDIA
echo "options nvidia-drm modeset=1" | sudo tee /etc/modprobe.d/nvidia.conf >/dev/null
fi
# Without this, niri takes ~1 GB of GPU memory on boot. After this patch
# on my machine it only uses about 60 MB.
# This is taken from: https://github.com/YaLTeR/niri/wiki/Nvidia
if [ ! -f /etc/nvidia/nvidia-application-profiles-rc.d/50-limit-free-buffer-pool-in-wayland-compositors.json ]; then
sudo mkdir -p /etc/nvidia/nvidia-application-profiles-rc.d
cat <<EOF | sudo tee /etc/nvidia/nvidia-application-profiles-rc.d/50-limit-free-buffer-pool-in-wayland-compositors.json >/dev/null
{
"rules": [
{
"pattern": {
"feature": "procname",
"matches": "niri"
},
"profile": "Limit Free Buffer Pool On Wayland Compositors"
}
],
"profiles": [
{
"name": "Limit Free Buffer Pool On Wayland Compositors",
"settings": [
{
"key": "GLVidHeapReuseRatio",
"value": 0
}
]
}
]
}
EOF
fi
# Choose driver based on generation.
case "${gpu_line}" in
*RTX\ [2-9][0-9]* | *GTX\ 16*)
PACKAGES_PACMAN+=("nvidia-open-dkms" "nvidia-utils" "lib32-nvidia-utils")
;;
*GTX\ [7-9]* | *GTX\ 10*)
PACKAGES_AUR+=("nvidia-580xx-dkms" "nvidia-580xx-utils" "lib32-nvidia-580xx-utils")
;;
*)
cat <<EOF
See if your GPU is listed here: https://wiki.archlinux.org/title/NVIDIA
If you think it should work, please open an issue with the above device output.
EOF
_error "Unsupported NVIDIA GPU found, aborting!"
;;
esac
;;
*AMD*)
# AMD drivers are handled automatically by the Linux kernel but let's get
# the Vulkan drivers so Steam and gaming works. amdgpu_top is for monitoring.
PACKAGES_PACMAN+=("vulkan-radeon" "lib32-vulkan-radeon" "amdgpu_top")
;;
*Intel*)
# This is for monitoring.
PACKAGES_PACMAN+=("intel-gpu-tools")
# Choose driver based on generation.
case "${gpu_line}" in
*HD\ Graphics* | *Iris* | *Xe*)
PACKAGES_PACMAN+=("intel-media-driver")
;;
*2nd\ Generation* | *3rd\ Generation* | *GMA*)
PACKAGES_PACMAN+=("libva-intel-driver")
;;
*)
cat <<EOF
See if your GPU is listed here: https://wiki.archlinux.org/title/Intel_graphics
If you think it should work, please open an issue with the above device output.
EOF
_error "Unsupported Intel GPU found, aborting!"
;;
esac
;;
*Virtio* | *QXL*)
# The kernel already has drivers for these VM devices.
:
;;
*)
cat <<EOF
$(grep --ignore-case "VGA" <<<"${lspci_output}")
Most variants of NVIDIA, AMD and Intel GPUs should all be supported.
If you think it should work, please open an issue with the above device output.
EOF
_error "Unsupported GPU found, aborting!"
;;
esac
}
detect_and_prepare_network() {
_info "DETECT AND PREPARE NETWORK"
if [[ "${GUI_ENABLED}" != "1" || "${SKIP_SYSTEM_PACKAGES}" == "1" ]]; then
echo "Skipping, since this only runs when GUI_LINUX=1 is set with packages"
return
fi
if compgen -G "/sys/class/net/*/wireless" 1>/dev/null; then
PACKAGES_PACMAN+=("impala" "iwd")
SYSTEMD_ENABLED_SERVICES+=("iwd.service")
echo "Wi-Fi adapter found, iwd + impala packages will be installed"
else
echo "Ethernet adapter found, no preparation is necessary"
fi
}
detect_and_prepare_bluetooth() {
_info "DETECT AND PREPARE BLUETOOTH"
if [[ "${GUI_ENABLED}" != "1" || "${SKIP_SYSTEM_PACKAGES}" == "1" ]]; then
echo "Skipping, since this only runs when GUI_LINUX=1 is set with packages"
return
fi
if [ -d "/sys/class/bluetooth" ]; then
PACKAGES_PACMAN+=("bluetui" "bluez")
SYSTEMD_ENABLED_SERVICES+=("bluetooth.service")
echo "Compatible adapter found, bluez + bluetui packages will be installed"
else
echo "Skipping, since no Bluetooth adapter was found"
fi
}
create_initial_dirs() {
mkdir -p \
"${HOME}/.local/bin" \
"${XDG_CACHE_HOME}/zsh" \
"${XDG_CONFIG_HOME}/bat" \
"${XDG_CONFIG_HOME}/btop/themes" \
"${XDG_CONFIG_HOME}/fzf" \
"${XDG_CONFIG_HOME}/ghostty" \
"${XDG_CONFIG_HOME}/git" \
"${XDG_CONFIG_HOME}/gnupg" \
"${XDG_CONFIG_HOME}/tmux/plugins" \
"${XDG_CONFIG_HOME}/zsh" \
"${XDG_DATA_HOME}/fonts" \
"${XDG_STATE_HOME}"
if [ "${GUI_ENABLED}" == "1" ]; then
mkdir -p \
"${XDG_CACHE_HOME}/mpd" \
"${XDG_CONFIG_HOME}/fontconfig" \
"${XDG_CONFIG_HOME}/gtk-3.0" \
"${XDG_CONFIG_HOME}/gtk-4.0" \
"${XDG_CONFIG_HOME}/hypr" \
"${XDG_CONFIG_HOME}/mako" \
"${XDG_CONFIG_HOME}/mpd" \
"${XDG_CONFIG_HOME}/niri" \
"${XDG_CONFIG_HOME}/rmpc" \
"${XDG_CONFIG_HOME}/satty" \
"${XDG_CONFIG_HOME}/swayidle" \
"${XDG_CONFIG_HOME}/swaylock" \
"${XDG_CONFIG_HOME}/tumbler" \
"${XDG_CONFIG_HOME}/uwsm" \
"${XDG_CONFIG_HOME}/walker/themes/base" \
"${XDG_CONFIG_HOME}/wallpaper" \
"${XDG_CONFIG_HOME}/waybar" \
"${XDG_CONFIG_HOME}/xarchiver" \
"${XDG_CONFIG_HOME}/zathura" \
"${XDG_DATA_HOME}/applications" \
"${XDG_DATA_HOME}/themes" \
"${XDG_DESKTOP_DIR}" \
"${XDG_DOCUMENTS_DIR}" \
"${XDG_DOWNLOAD_DIR}" \
"${XDG_MUSIC_DIR}/playlists" \