-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc.sh
executable file
·1532 lines (1196 loc) · 52.8 KB
/
misc.sh
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/bash
################################################
##### Applications
################################################
# Joplin
flatpak install -y flathub net.cozic.joplin_desktop
curl https://raw.githubusercontent.com/gjpin/fedora-workstation/main/configs/flatpak/net.cozic.joplin_desktop -o ${HOME}/.local/share/flatpak/overrides/net.cozic.joplin_desktop
# Install OpenLens
flatpak install -y flathub dev.k8slens.OpenLens
curl https://raw.githubusercontent.com/gjpin/fedora-workstation/main/configs/flatpak/dev.k8slens.OpenLens -o ${HOME}/.local/share/flatpak/overrides/dev.k8slens.OpenLens
################################################
##### Sunshine (Native)
################################################
# References:
# https://docs.lizardbyte.dev/projects/sunshine/en/latest/about/installation.html#rpm-package
# https://docs.lizardbyte.dev/projects/sunshine/en/latest/about/usage.html#linux
# https://github.com/LizardByte/Sunshine/blob/master/sunshine.service.in
# https://github.com/LizardByte/Sunshine
# Download Sunshine
curl https://github.com/LizardByte/Sunshine/releases/download/nightly-dev/sunshine-fedora-$(rpm -E %fedora)-amd64.rpm -L -O
# Install Sunshine
sudo dnf install -y sunshine-fedora-$(rpm -E %fedora)-amd64.rpm
# Clean rpm
rm -f sunshine-fedora-$(rpm -E %fedora)-amd64.rpm
# Allow Sunshine Virtual Input
echo 'KERNEL=="uinput", SUBSYSTEM=="misc", OPTIONS+="static_node=uinput", TAG+="uaccess"' | sudo tee /etc/udev/rules.d/85-sunshine-input.rules
# Create Sunshine service
tee ${HOME}/.config/systemd/user/sunshine.service << EOF
[Unit]
Description=Sunshine self-hosted game stream host for Moonlight.
StartLimitIntervalSec=500
StartLimitBurst=5
[Service]
ExecStart=/usr/bin/sunshine
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=graphical-session.target
EOF
# Fix Sunshine service in Gnome
if [ ${DESKTOP_ENVIRONMENT} = "gnome" ]; then
sed -i '3 i [email protected]' ${HOME}/.config/systemd/user/sunshine.service
fi
# Enable Sunshine service
systemctl --user enable sunshine.service
# Allow Sunshine to use KMS
sudo setcap cap_sys_admin+p $(readlink -f $(which sunshine))
# Import configs
mkdir -p ${HOME}/.config/sunshine
curl https://raw.githubusercontent.com/gjpin/fedora-workstation/main/configs/sunshine/sunshine.conf -o ${HOME}/.config/sunshine/sunshine.conf
if [ ${DESKTOP_ENVIRONMENT} == "gnome" ]; then
curl https://raw.githubusercontent.com/gjpin/fedora-workstation/main/configs/sunshine/apps-gnome.json -o ${HOME}/.config/sunshine/apps.json
elif [ ${DESKTOP_ENVIRONMENT} == "plasma" ]; then
curl https://raw.githubusercontent.com/gjpin/fedora-workstation/main/configs/sunshine/apps-plasma.json -o ${HOME}/.config/sunshine/apps.json
fi
# Sunshine updater
tee -a ${HOME}/.local/bin/update-all << 'EOF'
################################################
##### Sunshine
################################################
# Update Sunshine
curl https://github.com/LizardByte/Sunshine/releases/download/nightly-dev/sunshine-fedora-$(rpm -E %fedora)-amd64.rpm -L -O
sudo dnf reinstall -y sunshine-fedora-$(rpm -E %fedora)-amd64.rpm
rm -f sunshine-fedora-$(rpm -E %fedora)-amd64.rpm
systemctl --user restart sunshine.service
EOF
################################################
##### Firefox (Flatpak)
################################################
# Remove native firefox
sudo dnf remove -y firefox
rm -rf ${HOME}/.mozilla
# Install Firefox from Flathub
flatpak install -y flathub org.mozilla.firefox
# Set Firefox Flatpak as default browser and handler for https(s)
xdg-settings set default-web-browser org.mozilla.firefox.desktop
xdg-mime default org.mozilla.firefox.desktop x-scheme-handler/http
xdg-mime default org.mozilla.firefox.desktop x-scheme-handler/https
# Temporarily open Firefox to create profiles
timeout 5 flatpak run org.mozilla.firefox --headless
# Set Firefox profile path
FIREFOX_PROFILE_PATH=$(realpath ${HOME}/.var/app/org.mozilla.firefox/.mozilla/firefox/*.default-release)
################################################
##### Tweaks
################################################
# References:
# https://github.com/CryoByte33/steam-deck-utilities/blob/main/docs/tweak-explanation.md
# https://wiki.cachyos.org/configuration/general_system_tweaks/
# https://gitlab.com/cscs/maxperfwiz/-/blob/master/maxperfwiz?ref_type=heads
# https://wiki.archlinux.org/title/swap#Swappiness
# https://wiki.archlinux.org/title/Improving_performance#zram_or_zswap
# Sysctl tweaks
COMPUTER_MEMORY=$(echo $(vmstat -sS M | head -n1 | awk '{print $1;}'))
MEMORY_BY_CORE=$(echo $(( $(vmstat -s | head -n1 | awk '{print $1;}')/$(nproc) )))
BEST_KEEP_FREE=$(echo "scale=0; "$MEMORY_BY_CORE"*0.058" | bc | awk '{printf "%.0f\n", $1}')
sudo tee /etc/sysctl.d/99-performance-tweaks.conf << EOF
vm.page-cluster=0 # default: 3
vm.swappiness=10 # default: 60
vm.vfs_cache_pressure=50 # default: 100
kernel.nmi_watchdog=0 # default: 0
kernel.split_lock_mitigate=0 # default: 1
vm.compaction_proactiveness=0 # default: 20
vm.page_lock_unfairness=1 # default: 5
$(if [[ ${COMPUTER_MEMORY} > 13900 ]]; then echo "vm.dirty_bytes=419430400"; fi) # default: 0
$(if [[ ${COMPUTER_MEMORY} > 13900 ]]; then echo "vm.dirty_background_bytes=209715200"; fi) # default: 0
$(if [[ $(cat /sys/block/*/queue/rotational) == 0 ]]; then echo "vm.dirty_expire_centisecs=500"; else echo "vm.dirty_expire_centisecs=3000"; fi) # default: 3000
$(if [[ $(cat /sys/block/*/queue/rotational) == 0 ]]; then echo "vm.dirty_writeback_centisecs=250"; else echo "vm.dirty_writeback_centisecs=1500"; fi) # default: 500
vm.min_free_kbytes=${BEST_KEEP_FREE} # default: 67584
EOF
# Udev tweaks
sudo tee /etc/udev/rules.d/99-performance-tweaks.rules << 'EOF'
ACTION=="add|change", KERNEL=="nvme[0-9]*", ATTR{queue/scheduler}="none"
ACTION=="add|change", KERNEL=="sd[a-z]|mmcblk[0-9]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler} "mq-deadline"
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler} "bfq"
EOF
# Hugepage Defragmentation - default: 1
# Transparent Hugepages - default: always
# Shared Memory in Transparent Hugepages - default: never
sudo tee /etc/systemd/system/kernel-tweaks.service << 'EOF'
[Unit]
Description=Set kernel tweaks
After=multi-user.target
StartLimitBurst=0
[Service]
Type=oneshot
Restart=on-failure
ExecStart=/usr/bin/bash -c 'echo always > /sys/kernel/mm/transparent_hugepage/enabled'
ExecStart=/usr/bin/bash -c 'echo advise > /sys/kernel/mm/transparent_hugepage/shmem_enabled'
ExecStart=/usr/bin/bash -c 'echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag'
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable kernel-tweaks.service
# Disable watchdog timer drivers
# sudo dmesg | grep -e sp5100 -e iTCO -e wdt -e tco
sudo tee /etc/modprobe.d/disable-watchdog-drivers.conf << 'EOF'
blacklist sp5100_tco
blacklist iTCO_wdt
blacklist iTCO_vendor_support
EOF
# Disable broadcast messages
sudo tee /etc/systemd/system/disable-broadcast-messages.service << 'EOF'
[Unit]
Description=Disable broadcast messages
After=multi-user.target
StartLimitBurst=0
[Service]
Type=oneshot
Restart=on-failure
ExecStart=/usr/bin/busctl set-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager EnableWallMessages b false
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable disable-broadcast-messages.service
################################################
##### VSCode (Adwaita theme)
################################################
# References:
# https://github.com/piousdeer/vscode-adwaita
# Install VSCode Gnome theme
code --install-extension piousdeer.adwaita-theme
# Change VSCode config to use theme
sed -i '2 i \ \ \ \ "workbench.preferredDarkColorTheme": "Adwaita Dark",' ${HOME}/.config/Code/User/settings.json
sed -i '2 i \ \ \ \ "workbench.preferredLightColorTheme": "Adwaita Light",' ${HOME}/.config/Code/User/settings.json
sed -i '2 i \ \ \ \ "workbench.colorTheme": "Adwaita Dark & default syntax highlighting",' ${HOME}/.config/Code/User/settings.json
################################################
##### lazyvim
################################################
# Install LazyVim
# https://www.lazyvim.org/installation
git clone https://github.com/LazyVim/starter ${HOME}/.config/nvim
rm -rf ${HOME}/.config/nvim/.git
# Install arctic.nvim (Dark Modern) color scheme in neovim
# https://github.com/rockyzhang24/arctic.nvim/tree/v2
# https://www.lazyvim.org/plugins/colorscheme
tee ${HOME}/.config/nvim/lua/plugins/colorscheme.lua << 'EOF'
return {
{
"gjpin/arctic.nvim",
branch = "v2",
dependencies = { "rktjmp/lush.nvim" }
},
{
"LazyVim/LazyVim",
opts = {
colorscheme = "arctic",
}
}
}
EOF
################################################
##### Terraform
################################################
# Install Terraform
LATEST_VERSION=$(curl -s https://api.github.com/repos/hashicorp/terraform/releases/latest | awk -F\" '/tag_name/{print $(NF-1)}' | sed 's/[^0-9.]*//g')
curl -s -o terraform.zip https://releases.hashicorp.com/terraform/${LATEST_VERSION}/terraform_${LATEST_VERSION}_linux_amd64.zip
unzip terraform.zip
sudo mv terraform /usr/local/bin/terraform
rm -f terraform.zip
# Terraform updater
tee -a ${HOME}/.local/bin/update-all << 'EOF'
# Update Terraform
LATEST_VERSION=$(curl -s https://api.github.com/repos/hashicorp/terraform/releases/latest | awk -F\" '/tag_name/{print $(NF-1)}' | sed 's/[^0-9.]*//g')
INSTALLED_VERSION=$(terraform --version --json | jq -r .terraform_version)
if [[ "${INSTALLED_VERSION}" != *"${LATEST_VERSION}"* ]]; then
curl -s -o terraform.zip https://releases.hashicorp.com/terraform/${LATEST_VERSION}/terraform_${LATEST_VERSION}_linux_amd64.zip
unzip terraform.zip
sudo mv terraform /usr/local/bin/terraform
rm -f terraform.zip
fi
EOF
# Cleanup
rm -f ${HOME}/LICENSE.txt
################################################
##### Cloud / Kubernetes
################################################
# Install kubectl
curl -sLO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/kubectl
# kubectl updater
tee -a ${HOME}/.local/bin/update-all << 'EOF'
# Update kubectl
LATEST_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
INSTALLED_VERSION=$(kubectl version --client --output=json | jq -r .clientVersion.gitVersion)
if [[ "${INSTALLED_VERSION}" != *"${LATEST_VERSION}"* ]]; then
curl -sLO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/kubectl
fi
EOF
# Install Helm
LATEST_VERSION=$(curl -s https://api.github.com/repos/helm/helm/releases/latest | awk -F\" '/tag_name/{print $(NF-1)}')
curl -s -Lo helm.tar.gz https://get.helm.sh/helm-${LATEST_VERSION}-linux-amd64.tar.gz
sudo tar -xzf helm.tar.gz -C /usr/local/bin linux-amd64/helm --strip-components 1
rm -f helm.tar.gz
# Helm updater
tee -a ${HOME}/.local/bin/update-all << 'EOF'
# Update Helm
LATEST_VERSION=$(curl -s https://api.github.com/repos/helm/helm/releases/latest | awk -F\" '/tag_name/{print $(NF-1)}')
INSTALLED_VERSION=$(helm version --template='{{.Version}}')
if [[ "${INSTALLED_VERSION}" != *"${LATEST_VERSION}"* ]]; then
curl -s -Lo helm.tar.gz https://get.helm.sh/helm-${LATEST_VERSION}-linux-amd64.tar.gz
sudo tar -xzf helm.tar.gz -C /usr/local/bin linux-amd64/helm --strip-components 1
rm -f helm.tar.gz
fi
EOF
# Install Cilium
LATEST_VERSION=$(curl -s https://api.github.com/repos/cilium/cilium-cli/releases/latest | awk -F\" '/tag_name/{print $(NF-1)}')
curl -s -Lo cilium.tar.gz https://github.com/cilium/cilium-cli/releases/download/${LATEST_VERSION}/cilium-linux-amd64.tar.gz
sudo tar -xzf cilium.tar.gz -C /usr/local/bin
rm -f cilium.tar.gz
# Cilium updater
tee -a ${HOME}/.local/bin/update-all << 'EOF'
# Update Cilium
LATEST_VERSION=$(curl -s https://api.github.com/repos/cilium/cilium-cli/releases/latest | awk -F\" '/tag_name/{print $(NF-1)}')
INSTALLED_VERSION=$(cilium version --client | grep -o -P '(?<=cilium-cli: ).*(?= compiled)')
if [[ "${INSTALLED_VERSION}" != *"${LATEST_VERSION}"* ]]; then
curl -s -Lo cilium.tar.gz https://github.com/cilium/cilium-cli/releases/download/${LATEST_VERSION}/cilium-linux-amd64.tar.gz
sudo tar -xzf cilium.tar.gz -C /usr/local/bin
rm -f cilium.tar.gz
fi
EOF
################################################
##### Disable unneeded services
################################################
# Disable tracker services
systemctl --user mask \
tracker-extract-3.service \
tracker-miner-fs-control-3.service \
tracker-writeback-3.service \
tracker-miner-fs-3.service \
tracker-miner-rss-3.service \
tracker-xdg-portal-3.service
################################################
##### Bottles
################################################
# Install Bottles
flatpak install -y flathub com.usebottles.bottles
curl https://raw.githubusercontent.com/gjpin/fedora-workstation/main/configs/flatpak/com.usebottles.bottles -o ${HOME}/.local/share/flatpak/overrides/com.usebottles.bottles
# Configure MangoHud
mkdir -p ${HOME}/.var/app/com.usebottles.bottles/config/MangoHud
curl -sSL https://raw.githubusercontent.com/gjpin/fedora-workstation/main/configs/mangohud/MangoHud.conf -o ${HOME}/.var/app/com.usebottles.bottles/config/MangoHud
# Create folder for Bottles repos
mkdir -p ${HOME}/src/bottles
# Clone Bottles dependencies repo
git clone https://github.com/bottlesdevs/dependencies.git ${HOME}/src/bottles/dependencies
# Alias for bottles with local dependencies
tee ${HOME}/.zshrc.d/bottles << EOF
# Set bottles alias
alias bottles_local="LOCAL_DEPENDENCIES=${HOME}/src/bottles/dependencies flatpak run com.usebottles.bottles"
EOF
################################################
##### Remove unneeded services
################################################
# Disable ABRT service
sudo systemctl mask abrtd.service
# Disable mobile broadband modem management service
sudo systemctl mask ModemManager.service
# Disable PC/SC Smart Card service
sudo systemctl mask pcscd.service
sudo systemctl mask pcscd.socket
# Disable location lookup service
sudo systemctl mask geoclue.service
################################################
##### Node.js
################################################
# References:
# https://github.com/nvm-sh/nvm#manual-install
# Install NVM
git clone https://github.com/nvm-sh/nvm.git ${HOME}/.devtools/nvm
cd ${HOME}/.devtools/nvm
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
cd
# Source NVM temporarily
export NVM_DIR="$HOME/.devtools/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# Source NVM permanently
tee ${HOME}/.zshrc.d/nvm << 'EOF'
export NVM_DIR="$HOME/.devtools/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
EOF
# NVM updater
tee -a ${HOME}/.local/bin/update-all << 'EOF'
# Update NVM
cd ${HOME}/.devtools/nvm
git fetch --tags origin
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
cd
EOF
# Node updater
tee -a ${HOME}/.local/bin/update-all << 'EOF'
# Source NVM and update Node
export NVM_DIR="$HOME/.devtools/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install --lts
nvm install-latest-npm
EOF
# Install Node LTS and latest supported NPM version
nvm install --lts
nvm install-latest-npm
################################################
##### ROCm
################################################
# Install ROCm packages
if lspci | grep "VGA" | grep "AMD" > /dev/null; then
sudo usermod -a -G video ${USER}
sudo usermod -a -G render ${USER}
sudo dnf install -y \
rocminfo rocm-clinfo \
rocm-opencl rocm-opencl-devel \
rocm-hip rocm-hip-devel \
rocm-runtime rocm-runtime-devel \
rocm-smi rocm-smi-devel \
rocm-cmake rocm-comgr rocm-comgr-devel rocm-device-libs
tee ${HOME}/.zshrc.d/rocm << EOF
# Confirm "Node:" of GPU with rocminfo
export HIP_VISIBLE_DEVICES=1
# If GPU is not officially supported, pretend to be 6900xt
export HSA_OVERRIDE_GFX_VERSION=10.3.0
export HCC_AMDGPU_TARGET=gfx1030
EOF
fi
# Install CLBlast packages
sudo dnf install -y clblast clblast-devel clblast-tuners
################################################
##### PyTorch
################################################
# References:
# Check supported python version at (eg. cp311 for python 3.11): https://download.pytorch.org/whl/rocm5.6/torch/
# Install Python 3.11
sudo dnf install -y python3.11
# Create venv for pytorch
python3.11 -m venv ${HOME}/.python/pytorch
tee -a ${HOME}/.zshrc.d/python << 'EOF'
alias pytorch="source ${HOME}/.python/pytorch/bin/activate"
EOF
# Enable pytorch venv
source ${HOME}/.python/pytorch/bin/activate
# Install pytorch
if lspci | grep "VGA" | grep "AMD" > /dev/null; then
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.6
fi
# Deactivate pytorch venv
deactivate
################################################
##### Minikube (kubernetes)
################################################
# Install minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-latest.x86_64.rpm
sudo rpm -Uvh minikube-latest.x86_64.rpm
# todo: add auto updater
# check current and latest versions: minikube update-check
# if they are different, then download latest rpm, install it and remove rpm file
# Set minikube default settings
minikube config set driver kvm2
minikube config set container-runtime containerd
minikube config set memory 8192
minikube config set cpus 4
# Enable minikube ingress addon
minikube addons enable ingress
################################################
##### Kind (kubernetes)
################################################
# Install kind
# https://kind.sigs.k8s.io/docs/user/rootless/
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
tee ${HOME}/.zshrc.d/kind << 'EOF'
# Enable podman backend in Kind
KIND_EXPERIMENTAL_PROVIDER=podman
# Alias
alias kind-single-node="kind create cluster --name single-node"
alias kind-multi-node="kind create cluster --name multi-node --config ${HOME}/.kind/kind-multi-node.yaml"
EOF
echo "source <(kind completion bash)" >> ${HOME}/.zshrc.d/kind
mkdir -p ${HOME}/.kind
tee ${HOME}/.kind/kind-multi-node.yaml << 'EOF'
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker
EOF
# todo: add auto updater
# check current and latest versions
# if they are different, then download latest version
################################################
##### Icon theme
################################################
# References:
# https://github.com/somepaulo/MoreWaita
# Create MoreWaita directory
mkdir -p ${HOME}/.local/share/icons/MoreWaita
# Install MoreWaita icon theme
git clone https://github.com/somepaulo/MoreWaita.git ${HOME}/.local/share/icons/MoreWaita
# Update icon theme cache
gtk-update-icon-cache -f -t ${HOME}/.local/share/icons/MoreWaita
xdg-desktop-menu forceupdate
# Set MoreWaita icon theme
gsettings set org.gnome.desktop.interface icon-theme 'MoreWaita'
# MoreWaita icon theme updater
tee -a ${HOME}/.local/bin/update-all << 'EOF'
# Update MoreWaita icon theme
git -C ${HOME}/.local/share/icons/MoreWaita pull
# Update Icon theme cache
gtk-update-icon-cache -f -t ${HOME}/.local/share/icons/MoreWaita
xdg-desktop-menu forceupdate
EOF
################################################
##### VSCode (Flatpak)
################################################
# References:
# https://github.com/David-VTUK/turing-pi-ansible/blob/main/.devcontainer/devcontainer.json#L19
# Install Flatpak development runtimes
flatpak install -y flathub org.freedesktop.Sdk//23.08
flatpak install -y flathub org.freedesktop.Sdk.Extension.golang//23.08
flatpak install -y flathub org.freedesktop.Sdk.Extension.node20//23.08
flatpak install -y flathub org.freedesktop.Sdk.Extension.typescript//23.08
flatpak install -y flathub org.freedesktop.Sdk.Extension.llvm18//23.08
flatpak install -y flathub org.freedesktop.Sdk.Extension.rust-stable//23.08
flatpak install -y flathub org.freedesktop.Sdk.Extension.openjdk17//23.08
flatpak install -y flathub org.freedesktop.Sdk.Extension.openjdk21//23.08
# Install VSCode
flatpak install -y flathub com.visualstudio.code
curl https://raw.githubusercontent.com/gjpin/fedora-workstation/main/configs/flatpak/com.visualstudio.code -o ${HOME}/.local/share/flatpak/overrides/com.visualstudio.code
# Install extensions
flatpak run com.visualstudio.code --install-extension golang.Go
flatpak run com.visualstudio.code --install-extension ms-python.python
flatpak run com.visualstudio.code --install-extension redhat.vscode-yaml
flatpak run com.visualstudio.code --install-extension hashicorp.terraform
# Configure VSCode
mkdir -p ${HOME}/.var/app/com.visualstudio.code/config/Code/User
curl https://raw.githubusercontent.com/gjpin/fedora-workstation/main/configs/vscode/settings.json -o ${HOME}/.var/app/com.visualstudio.code/config/Code/User/settings.json
# Create alias
tee ${HOME}/.zshrc.d/vscode << EOF
alias code="flatpak run com.visualstudio.code"
EOF
################################################
##### Cockpit
################################################
# References:
# https://cockpit-project.org/running.html#fedora
# Install cockpit
sudo dnf install -y cockpit
# Enable cockpit
sudo systemctl enable cockpit.socket
################################################
##### Development
################################################
# References:
# https://developer.fedoraproject.org/tech/languages/rust/rust-installation.html
# https://docs.fedoraproject.org/en-US/quick-docs/installing-java/
# Install cfssl
sudo dnf install -y golang-github-cloudflare-cfssl
# mitmproxy
mkdir -p ${HOME}/.mitmproxy
tee ${HOME}/.zshrc.d/mitmproxy << 'EOF'
alias mitmproxy='podman run -it --rm --name=mitmproxy -v "$HOME"/.mitmproxy:/home/mitmproxy/.mitmproxy:Z -p 8080:8080 docker.io/mitmproxy/mitmproxy:latest'
alias mitmdump='podman run -it --rm --name=mitmdump -v "$HOME"/.mitmproxy:/home/mitmproxy/.mitmproxy:Z -p 8080:8080 docker.io/mitmproxy/mitmproxy:latest mitmdump'
alias mitmweb='podman run -it --rm --name=mitmweb -v "$HOME"/.mitmproxy:/home/mitmproxy/.mitmproxy:Z -p 8080:8080 -p 127.0.0.1:8081:8081 docker.io/mitmproxy/mitmproxy:latest mitmweb --web-host 0.0.0.0'
EOF
# Install OpenJDK
sudo dnf install -y \
java-latest-openjdk \
java-latest-openjdk-devel
################################################
##### IntelliJ IDEA Community
################################################
# Install IntelliJ IDEA Community
flatpak install -y flathub com.jetbrains.IntelliJ-IDEA-Community
# Create required folders
mkdir -p \
${HOME}/.java \
${HOME}/.gradle
# Allow IntelliJ access to required folders
flatpak override --user --filesystem=home/.java com.jetbrains.IntelliJ-IDEA-Community
flatpak override --user --filesystem=home/.gradle com.jetbrains.IntelliJ-IDEA-Community
# Allow IntelliJ access to src folder
flatpak override --user --filesystem=home/src com.jetbrains.IntelliJ-IDEA-Community
# Allow IntelliJ access to .ssh folder
flatpak override --user --filesystem=home/.ssh:ro com.jetbrains.IntelliJ-IDEA-Community
# Allow IntelliJ access to .gitconfig file
flatpak override --user --filesystem=home/.gitconfig:ro com.jetbrains.IntelliJ-IDEA-Community
# Allow IntelliJ to read /etc (/etc/shells is required)
flatpak override --user --filesystem=host-etc:ro com.jetbrains.IntelliJ-IDEA-Community
# Enable support for additional languages
flatpak override --user --env='FLATPAK_ENABLE_SDK_EXT=openjdk,openjdk17' com.jetbrains.IntelliJ-IDEA-Community
################################################
##### Android Studio
################################################
# References:
# https://github.com/flathub/com.google.AndroidStudio/issues/81
# https://issuetracker.google.com/issues/117641628
# Install Android Studio
flatpak install -y flathub com.google.AndroidStudio
curl https://raw.githubusercontent.com/gjpin/fedora-workstation/main/configs/flatpak/com.google.AndroidStudio -o ${HOME}/.local/share/flatpak/overrides/com.google.AndroidStudio
# Workaround for incompatibility with BTRFS copy-on-write (see issue in references)
mkdir -p ${HOME}/.android
tee ${HOME}/.android/advancedFeatures.ini << EOF
QuickbootFileBacked = off
EOF
################################################
##### Android SDK tools
################################################
# References:
# https://developer.android.com/tools
# https://developer.android.com/studio/emulator_archive
# https://dl.google.com/android/repository/repository2-1.xml
# Set Android SDK directory
ANDROID_SDK_PATH=${HOME}/.android-sdk
# Create Android SDK directory
mkdir -p ${ANDROID_SDK_PATH}
# Download and install Android SDK command line tools
LATEST_CMDLINE_TOOLS_VERSION=$(curl -s https://formulae.brew.sh/api/cask/android-commandlinetools.json | jq -r .version)
wget https://dl.google.com/android/repository/commandlinetools-linux-${LATEST_CMDLINE_TOOLS_VERSION}_latest.zip
unzip commandlinetools-linux-*_latest.zip -d ${ANDROID_SDK_PATH}/cmdline-tools
mv ${ANDROID_SDK_PATH}/cmdline-tools/* ${ANDROID_SDK_PATH}/cmdline-tools/latest
rm -f commandlinetools-linux-*.zip
# Android SDK build tools
LATEST_BUILD_TOOLS_VERSION=$(curl -s https://aur.archlinux.org/rpc/v5/info/android-sdk-build-tools | jq -r .results[0].Version | awk -F[.] '{print $1}')
wget https://dl.google.com/android/repository/build-tools_${LATEST_BUILD_TOOLS_VERSION}-linux.zip
unzip build-tools_r*-linux.zip -d ${ANDROID_SDK_PATH}/build-tools
mv ${ANDROID_SDK_PATH}/build-tools/* ${ANDROID_SDK_PATH}/build-tools/latest
rm -f build-tools_r*-linux.zip
# Android SDK platform tools
LATEST_PLATFORM_TOOLS_VERSION=$(curl -s https://formulae.brew.sh/api/cask/android-platform-tools.json | jq -r .version)
wget https://dl.google.com/android/repository/platform-tools_r${LATEST_PLATFORM_TOOLS_VERSION}-linux.zip
unzip platform-tools_r*-linux.zip -d ${ANDROID_SDK_PATH}
rm -f platform-tools_r*-linux.zip
# Android emulator
wget https://dl.google.com/android/repository/emulator-linux_x64-11150993.zip
unzip emulator-linux_x64-*.zip -d ${ANDROID_SDK_PATH}
rm -f emulator-linux_x64-*.zip
# Set env vars
tee ${HOME}/.zshrc.d/android << EOF
export ANDROID_HOME='${ANDROID_SDK_PATH}'
export PATH="\${PATH}:\${ANDROID_HOME}/build-tools/latest"
export PATH="\${PATH}:\${ANDROID_HOME}/cmdline-tools/latest/bin"
export PATH="\${PATH}:\${ANDROID_HOME}/platform-tools"
export PATH="\${PATH}:\${ANDROID_HOME}/emulator"
EOF
################################################
##### Deno
################################################
# Install deno
mkdir -p ${HOME}/.deno/bin
curl https://github.com/denoland/deno/releases/latest/download/deno-x86_64-unknown-linux-gnu.zip -L -O
unzip -o deno-x86_64-unknown-linux-gnu.zip -d ${HOME}/.deno/bin
rm -f deno-x86_64-unknown-linux-gnu.zip
# Add Deno to path
tee ${HOME}/.zshrc.d/deno << 'EOF'
export DENO_INSTALL=${HOME}/.deno
export PATH="$PATH:$DENO_INSTALL/bin"
EOF
# Add Deno updater to main updater
tee -a ${HOME}/.local/bin/update-all << EOF
# Update Deno
deno upgrade
EOF
# Install Deno VSCode extension
code --install-extension denoland.vscode-deno
################################################
##### Lutris
################################################
# Install Lutris
flatpak install -y flathub net.lutris.Lutris
# Allow Lutris to create application shortcuts
flatpak override --user --filesystem=xdg-data/applications net.lutris.Lutris
# Allow Lutris access to its folder
flatpak override --user --filesystem=/data/games/lutris net.lutris.Lutris
# Allow Lutris access to Steam (Lutris expects to find Steam at ~/.steam)
ln -s ${HOME}/.var/app/com.valvesoftware.Steam/.steam ${HOME}/.steam
flatpak override --user --filesystem=home/.var/app/com.valvesoftware.Steam/data/Steam net.lutris.Lutris
# Deny Lutris talk
flatpak override --user --no-talk-name=org.freedesktop.Flatpak net.lutris.Lutris
# Configure MangoHud for Lutris
mkdir -p ${HOME}/.var/app/net.lutris.Lutris/config/MangoHud
tee ${HOME}/.var/app/net.lutris.Lutris/config/MangoHud/MangoHud.conf << EOF
legacy_layout=0
horizontal
gpu_stats
cpu_stats
ram
fps
frametime=0
hud_no_margin
table_columns=14
frame_timing=1
engine_version
vulkan_driver
EOF
################################################
##### Wine
################################################
# References:
# https://github.com/Winetricks/winetricks/blob/master/files/verbs/download.txt
# https://github.com/FanderWasTaken/wine-dependency-hell-solver
# https://github.com/Matoking/protontricks
# Install Wine and dependencies
flatpak install -y flathub app/org.winehq.Wine/x86_64/stable-23.08
flatpak install -y flathub runtime/org.winehq.Wine.gecko/x86_64/stable-23.08
flatpak install -y flathub runtime/org.winehq.Wine.mono/x86_64/stable-23.08
# Deny Wine internet access
flatpak override --user --unshare=network org.winehq.Wine
# Prevent installing Mono/Gecko
flatpak override --user --env='WINEDLLOVERRIDES=mscoree=d;mshtml=d' org.winehq.Wine
# Set wine alias
tee ${HOME}/.zshrc.d/wine << 'EOF'
alias wine="flatpak run org.winehq.Wine"
alias wineuninstaller="flatpak run org.winehq.Wine uninstaller"
alias winecfg="flatpak run --command=winecfg org.winehq.Wine"
alias winetricks="flatpak run --command=winetricks org.winehq.Wine"
alias winemango="flatpak run --command=mangohud org.winehq.Wine wine"
alias winegamescope="flatpak run --command=gamescope org.winehq.Wine -f -- wine"
EOF
# Disable Large Address Aware
flatpak override --user --env='WINE_LARGE_ADDRESS_AWARE=0' org.winehq.Wine
# Install dependencies
flatpak run --command=winetricks org.winehq.Wine --unattended --force vcrun2022
sleep 5
flatpak run --command=winetricks org.winehq.Wine --unattended --force faudio
sleep 5
# Create wine directories
mkdir -p ${HOME}/.var/app/org.winehq.Wine/data/wine/drive_c/windows/system32
mkdir -p ${HOME}/.var/app/org.winehq.Wine/data/wine/drive_c/windows/syswow64
# Install DXVK
LATEST_DXVK_VERSION=$(curl -s https://api.github.com/repos/doitsujin/dxvk/releases/latest | awk -F\" '/tag_name/{print $(NF-1)}' | sed 's/^.//')
curl https://github.com/doitsujin/dxvk/releases/latest/download/dxvk-${LATEST_DXVK_VERSION}.tar.gz -L -O
tar -xzf dxvk-${LATEST_DXVK_VERSION}.tar.gz -C ${HOME}/.var/app/org.winehq.Wine/data/wine/drive_c/windows/system32 dxvk-${LATEST_DXVK_VERSION}/x64/* --strip-components 2
tar -xzf dxvk-${LATEST_DXVK_VERSION}.tar.gz -C ${HOME}/.var/app/org.winehq.Wine/data/wine/drive_c/windows/syswow64 dxvk-${LATEST_DXVK_VERSION}/x32/* --strip-components 2
rm -f tar -xzf dxvk-${LATEST_DXVK_VERSION}.tar.gz
flatpak run org.winehq.Wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v d3d11 /d native /f
sleep 5
flatpak run org.winehq.Wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v d3d10core /d native /f
sleep 5
flatpak run org.winehq.Wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v dxgi /d native /f
sleep 5
flatpak run org.winehq.Wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v d3d9 /d native /f
sleep 5
# Install VKD3D
LATEST_VKD3D_VERSION=$(curl -s https://api.github.com/repos/HansKristian-Work/vkd3d-proton/releases/latest | awk -F\" '/tag_name/{print $(NF-1)}' | sed 's/^.//')
curl https://github.com/HansKristian-Work/vkd3d-proton/releases/latest/download/vkd3d-proton-${LATEST_VKD3D_VERSION}.tar.zst -L -O
tar -xf vkd3d-proton-${LATEST_VKD3D_VERSION}.tar.zst -C ${HOME}/.var/app/org.winehq.Wine/data/wine/drive_c/windows/system32 vkd3d-proton-${LATEST_VKD3D_VERSION}/x64/* --strip-components 2
tar -xf vkd3d-proton-${LATEST_VKD3D_VERSION}.tar.zst -C ${HOME}/.var/app/org.winehq.Wine/data/wine/drive_c/windows/syswow64 vkd3d-proton-${LATEST_VKD3D_VERSION}/x86/* --strip-components 2
rm -f vkd3d-proton-${LATEST_VKD3D_VERSION}.tar.zst
flatpak run org.winehq.Wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v d3d12 /d native /f
sleep 5
flatpak run org.winehq.Wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v d3d12core /d native /f
sleep 5
# Install and configure MangoHud and Gamescope
flatpak install -y flathub org.freedesktop.Platform.VulkanLayer.MangoHud//23.08
flatpak install -y flathub org.freedesktop.Platform.VulkanLayer.gamescope//23.08
flatpak override --user --env='PATH=/app/bin:/usr/bin:/usr/lib/extensions/vulkan/MangoHud/bin:/usr/lib/extensions/vulkan/gamescope/bin' org.winehq.Wine
mkdir -p ${HOME}/.var/app/org.winehq.Wine/config/MangoHud
tee ${HOME}/.var/app/org.winehq.Wine/config/MangoHud/MangoHud.conf << EOF
legacy_layout=0
horizontal
gpu_stats
cpu_stats
ram
fps
frametime=0
hud_no_margin
table_columns=14
frame_timing=1
engine_version
vulkan_driver
EOF
# flatpak run --command=winetricks org.winehq.Wine --unattended --force d3dx9
# flatpak run --command=winetricks org.winehq.Wine --unattended --force d3dx10
# flatpak run --command=winetricks org.winehq.Wine --unattended --force d3dx11_43
# flatpak run --command=winetricks org.winehq.Wine --unattended --force d3dcompiler_42
# flatpak run --command=winetricks org.winehq.Wine --unattended --force d3dcompiler_43
# flatpak run --command=winetricks org.winehq.Wine --unattended --force d3dcompiler_46
# flatpak run --command=winetricks org.winehq.Wine --unattended --force d3dcompiler_47
# flatpak run --command=winetricks org.winehq.Wine --unattended --force dotnet40
# flatpak run --command=winetricks org.winehq.Wine --unattended --force dotnet40_kb2468871
# flatpak run --command=winetricks org.winehq.Wine --unattended --force dotnet48
# flatpak run --command=winetricks org.winehq.Wine --unattended --force dotnetdesktop6
# flatpak run --command=winetricks org.winehq.Wine --unattended --force xna40
# flatpak run --command=winetricks org.winehq.Wine --unattended --force faudio
# flatpak run --command=winetricks org.winehq.Wine --unattended --force corefonts
# flatpak run --command=winetricks org.winehq.Wine --unattended --force physx
# flatpak run --command=winetricks org.winehq.Wine --unattended --force dxvk
# flatpak run --command=winetricks org.winehq.Wine --unattended --force vkd3d
# flatpak run --command=winetricks org.winehq.Wine --unattended --force mf
################################################
##### MangoHud (native)
################################################
# Install MangoHud
sudo dnf install -y mangohud
# Configure MangoHud
mkdir -p ${HOME}/.config/MangoHud
tee ${HOME}/.config/MangoHud/MangoHud.conf << EOF
legacy_layout=0
horizontal
gpu_stats
cpu_stats
ram
fps
frametime=0
hud_no_margin
table_columns=14
frame_timing=1
engine_version
vulkan_driver
EOF
################################################
##### Gnome Shell Extensions
################################################
# Rounded Window Corners
# https://extensions.gnome.org/extension/5237/rounded-window-corners/
curl -sSL https://extensions.gnome.org/extension-data/rounded-window-cornersyilozt.v11.shell-extension.zip -O
gnome-extensions install *.shell-extension.zip
rm -f *.shell-extension.zip
# GSConnect
# https://extensions.gnome.org/extension/1319/gsconnect/
sudo dnf install -y openssl
curl -sSL https://extensions.gnome.org/extension-data/gsconnectandyholmes.github.io.v55.shell-extension.zip -O
gnome-extensions install *.shell-extension.zip
rm -f *.shell-extension.zip
# Dark Variant
# https://extensions.gnome.org/extension/4488/dark-variant/
sudo dnf install -y xprop
curl -sSL https://extensions.gnome.org/extension-data/dark-varianthardpixel.eu.v9.shell-extension.zip -O
gnome-extensions install *.shell-extension.zip
rm -f *.shell-extension.zip
gsettings --schemadir ~/.local/share/gnome-shell/extensions/[email protected]/schemas set org.gnome.shell.extensions.dark-variant applications "['code.desktop', 'com.visualstudio.code.desktop', 'rest.insomnia.Insomnia.desktop', 'com.spotify.Client.desktop', 'md.obsidian.Obsidian.desktop', 'org.gimp.GIMP.desktop', 'org.blender.Blender.desktop', 'org.godotengine.Godot.desktop', 'com.valvesoftware.Steam.desktop', 'com.heroicgameslauncher.hgl.desktop', 'org.duckstation.DuckStation.desktop', 'net.pcsx2.PCSX2.desktop', 'org.ppsspp.PPSSPP.desktop', 'app.xemu.xemu.desktop']"
# Enable extensions
gsettings set org.gnome.shell enabled-extensions "['rounded-window-corners@yilozt', '[email protected]', '[email protected]', '[email protected]', '[email protected]', 'rounded-window-corners@yilozt', '[email protected]']"
################################################
##### Fonts
################################################
# Ubuntu fonts
curl -sSL https://assets.ubuntu.com/v1/0cef8205-ubuntu-font-family-0.83.zip -o ubuntu-font.zip
unzip -j ubuntu-font.zip ubuntu-font-family-0.83/*.ttf -d ${HOME}/.local/share/fonts
rm -f ubuntu-font.zip
fc-cache ${HOME}/.local/share/fonts
################################################
##### Mounts
################################################
# Enable additional BTRFS options and change ZSTD compression level