base 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. #!/usr/bin/env bash
  2. # NAME: Install base system packages with hardware detection
  3. set -euo pipefail
  4. # Source common functions
  5. source "$(dirname "$0")/../common.sh" || {
  6. echo "[ERROR] Could not source common.sh" >&2
  7. exit 1
  8. }
  9. # Global variables for hardware detection
  10. MICROCODE=""
  11. GPU_PACKAGES=""
  12. check_requirements() {
  13. if ! command_exists paru; then
  14. log_error "paru not found. Install it first"
  15. exit 1
  16. fi
  17. # Check if running with sudo
  18. if [[ $EUID -ne 0 ]]; then
  19. log_error "This script must be run with sudo privileges"
  20. exit 1
  21. fi
  22. }
  23. detect_hardware() {
  24. local cpu_vendor gpu_info
  25. cpu_vendor=$(lscpu | grep "Vendor ID" | awk '{print $3}')
  26. gpu_info=$(lspci | grep -i vga)
  27. log_info "Detected CPU: $cpu_vendor"
  28. log_info "Detected GPU: $gpu_info"
  29. # Determine microcode package
  30. case "$cpu_vendor" in
  31. "GenuineIntel")
  32. MICROCODE="intel-ucode"
  33. log_info "Using Intel microcode"
  34. ;;
  35. "AuthenticAMD")
  36. MICROCODE="amd-ucode"
  37. log_info "Using AMD microcode"
  38. ;;
  39. *)
  40. MICROCODE=""
  41. log_warn "Unknown CPU vendor, skipping microcode"
  42. ;;
  43. esac
  44. # Determine GPU drivers
  45. if echo "$gpu_info" | grep -qi "amd\|radeon"; then
  46. GPU_PACKAGES="xf86-video-amdgpu vulkan-radeon lib32-vulkan-radeon opencl-mesa lib32-opencl-mesa"
  47. log_info "Using AMD GPU drivers"
  48. elif echo "$gpu_info" | grep -qi "intel"; then
  49. GPU_PACKAGES="xf86-video-intel vulkan-intel lib32-vulkan-intel intel-media-driver"
  50. log_info "Using Intel GPU drivers"
  51. elif echo "$gpu_info" | grep -qi "nvidia"; then
  52. GPU_PACKAGES="nvidia nvidia-utils lib32-nvidia-utils nvidia-settings"
  53. log_info "Using NVIDIA drivers"
  54. else
  55. GPU_PACKAGES=""
  56. log_warn "Unknown GPU, using generic drivers"
  57. fi
  58. }
  59. install_base_system() {
  60. log_info "Installing system base packages"
  61. local base_packages="base base-devel sudo stow linux-cachyos linux-cachyos-headers linux-firmware efibootmgr efitools mkinitcpio grub systemd-boot-manager"
  62. if [[ -n "$MICROCODE" ]]; then
  63. base_packages="$base_packages $MICROCODE"
  64. fi
  65. paru -S --needed --overwrite="*" $base_packages
  66. }
  67. install_networking() {
  68. log_info "Installing networking packages"
  69. paru -S --needed \
  70. networkmanager networkmanager-openvpn network-manager-applet \
  71. dhclient dnsmasq iptables-nft iwd wpa_supplicant wireless-regdb \
  72. bluez-libs blueman openssh
  73. }
  74. install_audio_video() {
  75. log_info "Installing audio and video packages"
  76. paru -S --needed \
  77. pipewire pipewire-alsa pipewire-pulse wireplumber \
  78. pavucontrol alsa-firmware alsa-plugins alsa-utils \
  79. gst-libav gst-plugin-pipewire gst-plugins-bad gst-plugins-ugly \
  80. mpv ffmpegthumbnailer easyeffects lsp-plugins-lv2
  81. }
  82. install_fonts_themes() {
  83. log_info "Installing fonts and themes"
  84. paru -S --needed \
  85. adobe-source-han-sans-cn-fonts adobe-source-han-sans-jp-fonts \
  86. adobe-source-han-sans-kr-fonts adobe-source-serif-fonts \
  87. awesome-terminal-fonts inter-font noto-fonts noto-fonts-cjk noto-fonts-emoji \
  88. ttf-bitstream-vera ttf-dejavu ttf-fantasque-nerd ttf-fira-code ttf-fira-mono \
  89. ttf-fira-sans ttf-font-awesome-5 ttf-liberation ttf-linux-libertine \
  90. ttf-meslo-nerd ttf-opensans otf-font-awesome-5 otf-libertinus \
  91. papirus-icon-theme rose-pine-gtk-theme
  92. }
  93. install_development() {
  94. log_info "Installing development tools"
  95. paru -S --needed \
  96. git git-lfs git-crypt github-cli lazygit \
  97. go go-task python python-defusedxml python-packaging \
  98. python-protobuf python-pynvim python-pywlroots lua luarocks \
  99. ccls cmake ninja neovim-nightly-bin
  100. }
  101. install_cli_utilities() {
  102. log_info "Installing CLI utilities"
  103. paru -S --needed \
  104. bat btop duf dysk dust eza fd fzf glances glow httpie ncdu \
  105. plocate ripgrep tealdeer the_silver_searcher tmux wget \
  106. xdg-user-dirs zoxide yazi yq zsh
  107. }
  108. install_window_managers() {
  109. log_info "Installing window managers and desktop environment"
  110. paru -S --needed \
  111. swaybg swayfx swayidle swaylock-effects waybar \
  112. wlogout wdisplays wl-clipboard rofi-lbonn-wayland-git
  113. }
  114. install_gui_applications() {
  115. log_info "Installing GUI applications"
  116. paru -S --needed \
  117. chromium zen-browser-bin \
  118. legcord-bin slack-desktop teams-for-linux-bin \
  119. obs-studio obsidian sublime-merge dbeaver \
  120. libreoffice-fresh kitty nemo nemo-fileroller
  121. }
  122. install_system_utilities() {
  123. log_info "Installing system utilities"
  124. paru -S --needed \
  125. brightnessctl cronie cups cups-pdf gamemode gvfs gvfs-afc gvfs-google \
  126. gvfs-gphoto2 gvfs-mtp gvfs-nfs gvfs-smb haveged hdparm less lvm2 \
  127. man-db man-pages meld modemmanager mtools mupdf netctl nss-mdns \
  128. ntfs-3g ntp nvme-cli opencl-mesa pacman-contrib pass pika-backup \
  129. pkgfile power-profiles-daemon pv reflector remmina rsync rtkit \
  130. samba seahorse sg3_utils smartmontools snapper solaar steam \
  131. steam-native-runtime syncthing localsend system-config-printer \
  132. transmission-qt ufw unrar unzip upower usb_modeswitch usbutils \
  133. vi vorta w3m which xdg-desktop-portal xdg-desktop-portal-gnome \
  134. xdg-desktop-portal-gtk xdg-desktop-portal-wlr yad zenity
  135. }
  136. install_gaming_graphics() {
  137. log_info "Installing gaming and graphics packages"
  138. local gaming_base="lib32-alsa-lib lib32-alsa-plugins lib32-gamemode lib32-libpulse lib32-mesa lib32-openal
  139. lib32-vkd3d lib32-vulkan-mesa-layers vkd3d vulkan-mesa-layers vulkan-tools vulkan-validation-layers
  140. wine protonup-qt"
  141. if [[ -n "$GPU_PACKAGES" ]]; then
  142. paru -S --needed $gaming_base $GPU_PACKAGES
  143. else
  144. paru -S --needed $gaming_base
  145. fi
  146. }
  147. install_hardware_support() {
  148. log_info "Installing hardware support"
  149. paru -S --needed \
  150. sof-firmware xf86-input-libinput xfsprogs \
  151. xorg-server xorg-xdpyinfo xorg-xhost xorg-xinit xorg-xinput \
  152. xorg-xkill xorg-xrandr xorg-xwayland
  153. }
  154. install_cloud_devops() {
  155. log_info "Installing cloud and DevOps tools"
  156. paru -S --needed \
  157. aws-cli aws-session-manager-plugin insomnia-bin \
  158. kubectl kubectx kubefwd-bin ngrok postgresql
  159. }
  160. install_document_tools() {
  161. log_info "Installing document and productivity tools"
  162. paru -S --needed \
  163. pandoc-cli texinfo wkhtmltopdf-bin zathura zathura-pdf-mupdf \
  164. swappy wf-recorder
  165. }
  166. install_security_tools() {
  167. log_info "Installing security tools"
  168. paru -S --needed \
  169. yubico-authenticator-bin yubikey-manager-qt
  170. }
  171. install_misc_packages() {
  172. log_info "Installing miscellaneous packages"
  173. paru -S --needed \
  174. pyenv watchman-bin wimlib \
  175. slurp grim swaync gum nwg-look lxsession colordiff
  176. log_info "Updating tldr database"
  177. tldr --update
  178. }
  179. main() {
  180. init_script
  181. check_requirements
  182. detect_hardware
  183. install_base_system
  184. install_networking
  185. install_audio_video
  186. install_fonts_themes
  187. install_development
  188. install_cli_utilities
  189. install_window_managers
  190. install_gui_applications
  191. install_system_utilities
  192. install_gaming_graphics
  193. install_hardware_support
  194. install_cloud_devops
  195. install_document_tools
  196. install_security_tools
  197. install_misc_packages
  198. finish_script 0
  199. }
  200. main "$@"