DEV Community

Diego Chueri
Diego Chueri

Posted on • Updated on

ArchLinux config on WSL2 to developers

Versão em português

In the last few days, I needed to format my equipment again and I felt the need to have documentation to speed up this part of configuring my development environment. I use some apps in my day-to-day life that prevent me from using only Linux, for a while I used dual-boot, but the need to restart the PC for some quick code changes made me look for another alternative, in this case, WSL.

The initial idea was just to document to facilitate my configuration process, but as lemonade comes from lemon, I decided to share it with you here. I'm not going to sound deep about the WSL or the reasons for each choice, but I'm open to suggestions and dialogues with anyone interested.

If you don't know what WSL is or are looking for more information about it, follow the link to the official Microsoft documentation (numerous articles can be found by a quick search):

What is the Windows Subsystem for Linux?

Installing WSL

If you have not yet installed WSL on your Windows, enter the following command in Windows PowerShell:

wsl --install
Enter fullscreen mode Exit fullscreen mode

Install WSL | Microsoft Learn

Windows Terminal

I prefer to use Windows Terminal for two main reasons: customization and taking advantage of some Linux commands. Installation is simple and can be done using the link below:

Windows Terminal - Microsoft Store Apps

Install Arch

This version of Arch that I use is very lightweight compared to other options (like Manjaro):

https://github.com/yuk7/ArchWSL

Just extract the files to a preferred folder and run the Arch file, which will start the installation.

Creating a user

Once the installation is complete, it's time to configure a user and make it the default at startup, avoiding using the root user. Just follow the commands below, remembering to replace {username} with the desired name:

echo "%wheel ALL=(ALL) ALL" > /etc/sudoers.d/wheel
Enter fullscreen mode Exit fullscreen mode
useradd -m -G wheel -s /bin/bash {username}
Enter fullscreen mode Exit fullscreen mode
passwd {username}
Enter fullscreen mode Exit fullscreen mode

Now to set the created user as default, close Arch and open your terminal in the folder where the Arch.exe file is and enter the following command:

.\Arch.Exe config --default-user {username}
Enter fullscreen mode Exit fullscreen mode

How to Setup | ArchWSL official documentation

Updating distro packages

Before updating we need to initialize pacman's keyring:

sudo pacman-key --init
Enter fullscreen mode Exit fullscreen mode

And also perform the initial configuration of the keys with the:

sudo pacman-key --populate
Enter fullscreen mode Exit fullscreen mode
sudo pacman -Sy archlinux-keyring
Enter fullscreen mode Exit fullscreen mode
sudo pacman -Syu
Enter fullscreen mode Exit fullscreen mode

pacman/Package signing - ArchWiki

Initialize keyring | ArchWSL official documentation (wsldl-pg.github.io)

Package managers

I will initially install the YARN and NPM managers:

sudo pacman -S yarn npm
Enter fullscreen mode Exit fullscreen mode

As AUR manager I use Yay:

sudo pacman -S --needed git base-devel
Enter fullscreen mode Exit fullscreen mode

Finally, with “Rust” package to use “cargo”:

sudo pacman -S rust
Enter fullscreen mode Exit fullscreen mode

To install Yay it will be necessary to clone the repository, as after installation the files will no longer be used I choose to create a temporary folder to facilitate deletion later:

mkdir tmp
Enter fullscreen mode Exit fullscreen mode
cd tmp
Enter fullscreen mode Exit fullscreen mode

Now just clone the repository and build it with makepkg:

git clone https://aur.archlinux.org/yay.git
Enter fullscreen mode Exit fullscreen mode
cd yay
Enter fullscreen mode Exit fullscreen mode
makepkg -si
Enter fullscreen mode Exit fullscreen mode

Jguer/yay: Yet another Yogurt - An AUR Helper written in Go (github.com)

Z Shell

Install ZSH:

yay -S zsh
Enter fullscreen mode Exit fullscreen mode

Customizing the Terminal

Changing the terminal theme

Windows Terminal Themes has several themes ready for your terminal, just choose the theme of your choice and click on the “Get theme” button, and with that selected theme will be copied to your clipboard. My favorite theme is Dracula.

Just go back to the terminal, use the shortcut Ctrl + , to open the Configurations, and click on Open JSON file in the lower left corner.

Print screen

After the last theme (themes are inside the "schemes" array), put a , and paste the chosen theme. Save and close the file.

Note: If you "break" the JSON file, while the terminal is open it may work normally, but when restarting it you will find an error similar to this. If this is tolerated, just click “OK”, open the JSON file again, check the syntax and save the file.

Return to the Settings screen, open the Arch profile, under “Additional settings” and click on “Appearance”. Now just change the “Color Scheme” to the desired option. Click “Save” and close the settings.

Customizing ZSH

To change the ZSH theme I use Powerlevel10k:

yay -S --noconfirm zsh-theme-powerlevel10k-git
Enter fullscreen mode Exit fullscreen mode
echo 'source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
Enter fullscreen mode Exit fullscreen mode
chsh -s /usr/bin/zsh
Enter fullscreen mode Exit fullscreen mode

Restart the terminal.

Font

After installing Powerlevel10k, when you start the terminal again, a settings screen will appear where some symbols should be displayed:

Print of terminal

If you are unable to view the displayed symbols, just install one of the calls Nerd Fonts and change the Arch profile font in “Additional Settings” > “Appearance” > “Font type”.

When you want to access the Powerlevel10k configuration screen again, just type:

p10k configure
Enter fullscreen mode Exit fullscreen mode

Plugins

In my case, I usually use the following plugins:

  • ZSH Autosuggestions: which does an autocomplete based on my command history;

  • exa: serves as an alternative to “ls”; and

  • bat: alternative “cat”.

mkdir .zsh
Enter fullscreen mode Exit fullscreen mode
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
Enter fullscreen mode Exit fullscreen mode
cargo install bat exa
Enter fullscreen mode Exit fullscreen mode

Open the .zshrc file in your preferred editor and add to the end of the file:

code .zshrc
Enter fullscreen mode Exit fullscreen mode
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
alias ls="exa --icons"
alias bat="bat --style-auto"
Enter fullscreen mode Exit fullscreen mode

NVM

For managing node versions I use NVM:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

Docker

It is necessary to have Docker Desktop installed on Windows. With that, just type in the terminal:

yay -S docker
Enter fullscreen mode Exit fullscreen mode

And finally, enable the Arch distro in the Resources of Docker Desktop.

And is this

Throughout the article, I tried to provide some useful links so that each one can perform the best configuration as appropriate. As said at the beginning, feel free to make suggestions, as well as indicate any errors that occurred during the process and also share your preferences with others.

Top comments (0)