confOS/arch_wsl.sh

240 lines
9.3 KiB
Bash
Raw Normal View History

2022-09-30 03:23:30 +02:00
#!/usr/bin/env bash
set -o errexit # crash the script when a command crash
2023-03-12 21:05:37 +01:00
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
main() {
2022-09-30 03:23:30 +02:00
# === Init pacman ==
2023-03-12 18:39:57 +01:00
sudo pacman-key --init
sudo pacman-key --populate
2023-03-12 21:05:37 +01:00
sudo pacman -Sy --noconfirm archlinux-keyring
# === Update Arch mirrors ==
sudo pacman -S --noconfirm pacman-contrib
curl -s "https://archlinux.org/mirrorlist/?country=FR&country=GB&protocol=https&use_mirror_status=on" | \
sed -e "s/^#Server/Server/" -e "/^#/d" | sudo bash -c "rankmirrors -n 7 - > /etc/pacman.d/mirrorlist"
2022-09-30 03:23:30 +02:00
# === Update Arch ==
2023-03-12 21:05:37 +01:00
sudo pacman -Syyuu --noconfirm
2022-09-30 03:23:30 +02:00
# === Install packages ==
2023-03-12 18:39:57 +01:00
sudo pacman -S --noconfirm git wget zip openssh bat base-devel make \
2022-11-15 20:05:20 +01:00
python-pygments micro git-lfs npm sdl2_image nodejs \
fish autoconf valgrind automake python-virtualenv gdb \
2023-09-07 17:24:42 +02:00
tk sdl2_mixer eza fzf glu man-pages-fr uwufetch mdcat \
2023-06-19 16:45:47 +02:00
python-pip opam cpanminus unison timidity++ \
rebuild-detector git-delta sdl2_ttf rustup libsamplerate \
2023-04-29 22:22:49 +02:00
rsync doxygen emacs-nox otf-fira-sans ttf-fira-code \
2023-05-17 20:39:41 +02:00
otf-fira-mono mingw-w64-gcc otf-font-awesome \
2023-06-19 16:45:47 +02:00
soundfont-fluid fluidsynth pulseaudio-alsa \
texlive-latexextra texlive-langfrench texlive-luatex \
noto-fonts
2023-06-19 16:45:47 +02:00
2022-09-30 03:23:30 +02:00
2023-03-12 21:15:38 +01:00
# === Rustup ==
2023-03-13 00:48:11 +01:00
# Init rustup
2023-03-12 21:15:38 +01:00
rustup default stable
2023-05-04 12:34:29 +02:00
# fish_add_path "$HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin"
# Dev tools
rustup component add rust-analysis rls
2023-03-12 21:15:38 +01:00
2022-09-30 03:23:30 +02:00
# === Colors package manager ==
2023-03-12 21:05:37 +01:00
sudo sed -i "s/#Color/Color/g" /etc/pacman.conf
sudo sed -i "s/#ParallelDownloads = 5/ParallelDownloads = 3/g" /etc/pacman.conf
2022-09-30 03:23:30 +02:00
# === Remove SU password ==
2023-03-12 21:05:37 +01:00
echo -e "# Disable password for specific user\nanri ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers > /dev/null
2022-09-30 03:23:30 +02:00
2023-05-07 12:12:26 +02:00
# === Paru ==
2023-05-17 21:04:49 +02:00
git clone https://aur.archlinux.org/paru.git
2023-05-07 12:12:26 +02:00
cd paru || exit
2022-09-30 03:23:30 +02:00
makepkg -si --noconfirm
# Remove folder
cd ..
2023-05-07 12:12:26 +02:00
rm -rf paru
2023-05-07 12:19:04 +02:00
paru --gendb
2023-05-07 12:12:26 +02:00
# Clean files used for compilation
sudo sed -i "s/#CleanAfter/CleanAfter/g" /etc/paru.conf
2022-09-30 03:23:30 +02:00
# === AUR packages ==
2023-06-19 16:45:47 +02:00
paru -S --noconfirm spim-svn cal8tor otf-font-awesome topgrade-bin \
texlive-latexindent-meta
2022-09-30 03:23:30 +02:00
# === Rust ==
# Add Cargo packages from Rust
2023-03-12 21:05:37 +01:00
mkdir -p "$HOME"/.cargo/bin
fish -c "fish_add_path $HOME/.cargo/bin"
2023-03-13 07:07:18 +01:00
# Add cargo packages
2023-03-13 07:09:20 +01:00
cargo install cargo-update cargo-cache
2022-09-30 03:23:30 +02:00
# === Set-up systemd
mkdir 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 ..
2023-03-12 21:05:37 +01:00
rm -rf subsystemctl
sudo subsystemctl start
2022-09-30 03:23:30 +02:00
# === Locales ==
2023-03-12 21:05:37 +01:00
sudo sed -i "s/#fr_FR.UTF-8 UTF-8/fr_FR.UTF8 UTF-8/g" /etc/locale.gen
sudo locale-gen
2022-09-30 03:23:30 +02:00
subsystemctl exec sudo localectl set-locale fr_FR.UTF-8
2023-03-12 21:05:37 +01:00
# === Shared folders ==
sudo mkdir /mnt/y
2022-09-30 03:23:30 +02:00
# === Fish ==
# Remove motd
fish -c "set -U fish_greeting"
# Reversed search
curl -sL https://git.io/fisher | fish -c "source && fisher install jorgebucaran/fisher"
fish -c "fisher install jethrokuan/fzf"
2022-10-18 13:52:10 +02:00
fish -c "fisher install jorgebucaran/autopair.fish"
2022-09-30 03:23:30 +02:00
# SSH
wget -q https://gitlab.com/kyb/fish_ssh_agent/raw/master/functions/fish_ssh_agent.fish -P "$HOME"/.config/fish/functions/
mkdir "$HOME"/.ssh
# Custom config.fish
2023-02-05 12:23:37 +01:00
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/config_wsl.fish -O "$HOME"/.config/fish/config.fish
2022-09-30 03:23:30 +02:00
# Custom prompt shell (based on https://github.com/fish-shell/fish-shell/blob/master/share/tools/web_config/themes/Base16%20Eighties.theme)
# Modifications: Changed comment color
2023-02-05 12:23:37 +01:00
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/functions/fish_prompt.fish -P "$HOME"/.config/fish/functions/
2023-03-13 15:47:21 +01:00
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/conf.d/promp_color.fish -O "$HOME"/.config/fish/conf.d/promp_color.fish
2023-09-07 17:24:42 +02:00
# EZA colors
2022-09-30 03:23:30 +02:00
fish -c "set -Ux EXA_COLORS 'di=1;36:da=35'"
2023-03-22 12:30:11 +01:00
# Add abbreviations
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/conf.d/abbr.fish -O "$HOME"/.config/fish/conf.d/abbr.fish
curl -s https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/conf.d/abbr_wsl.fish >> "$HOME"/.config/fish/conf.d/abbr.fish
2023-03-22 12:30:11 +01:00
# Add aliases
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/conf.d/alias.fish -O "$HOME"/.config/fish/conf.d/alias.fish
2022-09-30 03:23:30 +02:00
# === Micro configuration ==
mkdir "$HOME"/.config/micro
2023-02-05 12:23:37 +01:00
wget -q --show-progress https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/micro/settings.json -O "$HOME"/.config/micro/settings.json
2022-09-30 03:23:30 +02:00
micro -plugin install detectindent
# === GL4D ==
# Download, build and installation
git clone https://github.com/noalien/GL4Dummies.git
cd GL4Dummies || exit
make -f Makefile.autotools
./configure
make
2023-03-12 21:05:37 +01:00
sudo make install
2022-09-30 03:23:30 +02:00
cd ..
rm -rf GL4Dummies
# Fix for shared libraries (https://stackoverflow.com/a/9395355)
2023-03-12 21:05:37 +01:00
sudo ldconfig
2022-09-30 03:23:30 +02:00
# Add to path
2023-03-16 12:44:09 +01:00
fish -c "set -Uax LD_LIBRARY_PATH /usr/local/lib"
2022-09-30 03:23:30 +02:00
# === tldr ==
cargo install tealdeer
2023-03-12 21:05:37 +01:00
fish -c "tldr --update"
2022-09-30 03:23:30 +02:00
# Fish completion
2023-03-12 21:05:37 +01:00
local url_tldr
url_tldr=$(curl -s https://api.github.com/repos/dbrgn/tealdeer/releases/latest \
| grep 'browser_download_url": ".*/completions_fish"' \
| cut --delimiter=":" --field=2,3 \
| tr -d \" )
wget -q --show-progress "${url_tldr:1}" -O completions_fish
2022-09-30 03:23:30 +02:00
mv completions_fish ~/.config/fish/completions/tldr.fish
# === Java ==
curl -s "https://get.sdkman.io" | bash
2023-03-13 00:48:11 +01:00
# Temporary disable nounset for SDK
2023-03-12 21:05:37 +01:00
set +o nounset
# shellcheck source=/dev/null
2022-09-30 03:23:30 +02:00
source "$HOME/.sdkman/bin/sdkman-init.sh"
if [ -x "$HOME"/.config/fish ] ; then
if [ ! -f "$HOME"/.config/fish/functions/fisher.fish ] ; then # install fisher if not already installed
curl -sL https://git.io/fisher | fish -c "source && fisher install jorgebucaran/fisher"
2022-09-30 03:23:30 +02:00
fi
fish -c "fisher install reitzig/sdkman-for-fish"
2022-09-30 03:23:30 +02:00
fi
2023-03-13 00:20:31 +01:00
sdk install java 17.0.6-tem # https://whichjdk.com/#adoptium-eclipse-temurin
2023-03-13 00:48:11 +01:00
# Renable nounset
2023-03-12 21:05:37 +01:00
set -o nounset
2022-09-30 03:23:30 +02:00
# === Manual color ==
fish -c "set -Ux MANPAGER \"sh -c 'col -bx | bat -l man -p'\""
# === Git ==
2023-02-05 12:23:37 +01:00
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/dotfiles/.gitconfig -O "$HOME"/.gitconfig
2022-09-30 03:23:30 +02:00
# === Python ==
2022-09-30 13:00:53 +02:00
# Add PIP packages from Python
2023-03-12 23:13:26 +01:00
mkdir "$HOME"/.local/bin
2022-09-30 13:00:53 +02:00
fish -c "fish_add_path $HOME/.local/bin"
2022-09-30 03:23:30 +02:00
# === OCaml ==
# Init Opam and install stuff
echo | opam init
2023-03-12 21:05:37 +01:00
fish -c "yes | opam init"
2022-11-29 16:59:35 +01:00
opam install -y utop ocaml-lsp-server ocamlformat ocamlformat-rpc menhir
2023-02-05 12:23:37 +01:00
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/dotfiles/.ocamlformat -O "$HOME"/.ocamlformat
# Add Opam packages from OCaml
2023-03-12 21:05:37 +01:00
mkdir -p "$HOME"/.opam/default/bin
2022-11-06 14:24:36 +01:00
fish -c "fish_add_path $HOME/.opam/default/bin"
# Fix dlllwt_unix_stubs.so shared object file
fish -c "set -Ux CAML_LD_LIBRARY_PATH $(opam var stublibs)"
2022-09-30 03:23:30 +02:00
2022-10-02 01:17:46 +02:00
# === Clang ==
2023-02-05 12:23:37 +01:00
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/dotfiles/.clang-format -O "$HOME"/.clang-format
2022-10-02 01:17:46 +02:00
2022-10-14 17:48:53 +02:00
# === Valgrind ==
fish -c "set -Ux DEBUGINFOD_URLS https://debuginfod.archlinux.org"
2022-10-18 17:41:32 +02:00
# === Unison ==
2023-03-12 21:05:37 +01:00
mkdir "$HOME"/.unison
2023-02-05 12:23:37 +01:00
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/.unison/default.prf -O "$HOME"/.unison/default.prf
2022-10-18 17:41:32 +02:00
2023-03-13 00:13:52 +01:00
# === Perl ==
2023-03-13 00:48:11 +01:00
# Add perl packages to path
2023-03-13 00:13:52 +01:00
fish -c "fish_add_path /usr/bin/vendor_perl"
2023-03-19 16:48:27 +01:00
# === Emacs ==
mkdir "$HOME"/.emacs.d
wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/.emacs.d/init.el -O "$HOME"/.emacs.d/init.el
2023-04-04 08:44:57 +02:00
# === Bash VSCode fix ==
curl -s https://git.mylloon.fr/Anri/confOS/raw/branch/main/dotfiles/.bashrc >> "$HOME"/.bashrc
2023-05-03 19:21:26 +02:00
# === MIDI files ==
{
2023-05-03 19:27:40 +02:00
echo "soundfont /usr/share/soundfonts/FluidR3_GS.sf2"
echo "soundfont /usr/share/soundfonts/FluidR3_GM.sf2"
2023-05-03 19:21:26 +02:00
} | sudo tee -a /etc/timidity/timidity.cfg > /dev/null
2023-05-04 11:05:57 +02:00
sudo mkdir -p /usr/share/sounds/sf2
sudo ln -s /usr/share/soundfonts/*.sf2 /usr/share/sounds/sf2/
2023-05-03 19:21:26 +02:00
2023-06-12 00:03:40 +02:00
# === Update NPM ==
sudo npm i -g npm@latest
2022-09-30 03:23:30 +02:00
# === Clear useless packages
2023-03-13 15:34:24 +01:00
pacman -Qqtd | sudo pacman --noconfirm -Rsn subsystemctl - 2> /dev/null || true
2022-09-30 03:23:30 +02:00
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)"
}
2022-09-30 03:23:30 +02:00
if grep "WSL2" /proc/version > /dev/null;
then
main "$@"
2022-09-30 03:23:30 +02:00
else
echo "Ce script ne fonctionne que sur ArchWSL." >&2
2022-09-30 03:23:30 +02:00
fi