confOS/wsl.sh
2024-04-11 19:21:49 +02:00

124 lines
3.8 KiB
Bash

#!/usr/bin/env bash
set -o errexit # crash the script when a command crash
set -o pipefail # same as above for piped command
set -o nounset # crash when a variable doesnt exist
# TRACE=1 for debug
if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi
cd "$(dirname "$0")" # change script directory
function main {
# === Variables ==
local repo
repo=https://git.mylloon.fr/Anri/confOS/raw/branch/main
# === Init pacman ==
sudo pacman-key --init
sudo pacman-key --populate
sudo pacman -Sy --noconfirm archlinux-keyring
# === Update Arch ==
sudo pacman -Syyuu --noconfirm
# === Install packages ==
sudo pacman -S --noconfirm \
git wget zip openssh bat base-devel make python-pygments micro git-lfs npm \
sdl2_image nodejs fish autoconf valgrind automake python-virtualenv gdb \
tk sdl2_mixer eza fzf glu man-pages-fr uwufetch mdcat python-pip opam \
cpanminus unison timidity++ rebuild-detector difftastic sdl2_ttf rustup \
libsamplerate rsync doxygen otf-fira-sans ttf-fira-code texlive-binextra \
otf-fira-mono mingw-w64-gcc otf-font-awesome soundfont-fluid fluidsynth \
pulseaudio-alsa texlive-latexextra texlive-langfrench texlive-luatex \
noto-fonts jdk-openjdk texlive-fontsrecommended texlive-publishers sfml \
texlive-fontsextra perl-yaml-tiny perl-file-homedir perl-file-which \
man-pages bottom maven
# === Remove SU password ==
echo -e "\n# Disable password for specific user\n$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers > /dev/null
# === Global OS configuration set-up ==
curl ${repo}/meta.sh -s | bash -s -- ${repo}
# === AUR packages ==
paru -S --noconfirm \
otf-font-awesome
# === Set-up systemd ==
mkdir -p subsystemctl
cd subsystemctl || exit
curl -so PKGBUILD https://raw.githubusercontent.com/sorah/arch.sorah.jp/master/aur-sorah/PKGBUILDs/subsystemctl/PKGBUILD
makepkg -si --noconfirm
cd ..
rm -rf subsystemctl ||:
sudo subsystemctl start
# === Locales ==
sudo sed -i "s/#fr_FR.UTF-8 UTF-8/fr_FR.UTF8 UTF-8/g" /etc/locale.gen
sudo locale-gen
sudo subsystemctl stop; sudo subsystemctl start # fix weird bug
subsystemctl exec sudo localectl set-locale fr_FR.UTF-8
# === Shared folders ==
sudo mkdir -p /mnt/y
# === Fish ==
# Custom WSL configuration
curl -s ${repo}/.config/fish/config_wsl.fish >> "$HOME"/.config/fish/config.fish
curl -s ${repo}/.config/fish/conf.d/abbr_wsl.fish >> "$HOME"/.config/fish/conf.d/abbr.fish
curl -s ${repo}/.config/fish/conf.d/alias_wsl.fish >> "$HOME"/.config/fish/conf.d/alias.fish
# Specific WSL functions
#wget -q "${repo}"/.config/fish/functions/trash.fish -P "$HOME"/.config/fish/functions/
# === OCaml ==
# Fix dlllwt_unix_stubs.so shared object file
fish -c "set -Ux CAML_LD_LIBRARY_PATH $(opam var stublibs)"
# === Valgrind ==
fish -c "set -Ux DEBUGINFOD_URLS https://debuginfod.archlinux.org"
# === Unison ==
mkdir -p "$HOME"/.unison
wget -q ${repo}/.unison/default.prf -O "$HOME"/.unison/default.prf
# === Bash VSCode fix ==
curl -s ${repo}/dotfiles/.bashrc >> "$HOME"/.bashrc
# === Clear useless packages ==
fish -c "pacman-clean"
paru --noconfirm -Rsndd \
subsystemctl fakeroot-tcp
echo -e "\nInstallation terminée !\nIl faut redémarrer WSL (dans Powershell = wsl --shutdown)."
echo -e "---\nPense bien à paramétrer ton terminal, exemple avec Windows Terminal :"
echo "- Ligne de commande = wsl.exe -d Arch fish"
echo "- Profils par défaut => Apparence :"
echo " - Jeu de couleur = One Half Dark"
echo " - Type de police = Caskaydia Cove Nerd Font Complete Mono Windows Compatible"
echo " (à télécharger ici : https://www.nerdfonts.com/font-downloads)"
}
if grep "WSL2" /proc/version > /dev/null;
then
main "$@"
else
echo "Ce script ne fonctionne que sur ArchWSL." >&2
fi