Skip to content

Instantly share code, notes, and snippets.

@ajitid
Last active May 27, 2022 10:00
Show Gist options
  • Save ajitid/93b2e40625056e90958130d4d90f985f to your computer and use it in GitHub Desktop.
Save ajitid/93b2e40625056e90958130d4d90f985f to your computer and use it in GitHub Desktop.
Setup Fedora on WSL

Installation

Download and install using https://github.com/WhitewaterFoundry/Fedora-Remix-for-WSL/releases

Uninstallation

Uninstall using wsl --unregister fedoraremix

Setup guide

Enter a username ("zlksnk" preferable) and a password, even if it says BAD PASSWORD, it still accepts it.

Once in bash, do sudo vim /etc/wsl.conf and add

[interop]
appendwindowspath=false

Do wsl --shutdown. Then do wsl -l -v. If fedoraremix is not default, do wsl -s fedoraremix.

You might not get an entry for fedora in your windows terminal by now. So close the terminal and reopen it. Alternatively you can search for fedora in start menu.

Once WSL is open again, do sudo dnf distro-sync to upgrade all installed packages.

Install kitty (https://sw.kovidgoyal.net/kitty/binary/)

curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin
cd .local
mkdir bin && cd bin
ln -s ../kitty.app/bin/kitty .

Install Fuse to run nvim.appimage using sudo dnf install fuse fuse-devel (probably not needed in Fedora Workstation, but required in Fedora Remix WSL). Then download nvim under ~/.local/bin dir only (https://github.com/neovim/neovim/releases)

wget https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage
chmod u+x nvim.appimage

You should still prefer opening stuff using vim and not nvim unless explicitly told to.

Now if you cd to ~ and run nvim.appimage it won't run, because .local/bin is not added to PATH by default.

Copy .ssh folder from previous distro:

cd ~
mv winhome/Downloads/.ssh/ .

add ssh pvt keys:

cd ~/.ssh
eval "$(ssh-agent -s)"
ssh-add id_ed25519
# other ssh keys

If you see WARNING: UNPROTECTED PRIVATE KEY FILE! and the process is aborted, change access level for pvt ssh keys:

chmod 600 id_ed25519
# other keys

then do ssh-add command again.

Install git, stow and ghq (https://github.com/x-motemen/ghq/releases/)

sudo dnf install git stow
cd /tmp
# use the latest version here
wget https://github.com/x-motemen/ghq/releases/download/v1.2.1/ghq_linux_amd64.zip
unzip ghq_linux_amd64
mv ghq_linux_amd64/ghq ~/.local/bin

Pull dotfiles

cd ~/.local/bin
./ghq get -p https://github.com/ajitid/dotfiles

Stow dotfiles

cd ~/ghq/github.com/ajitid/dotfiles
ls -d */ | xargs -I {} stow {} -t ~

Install sublime merge https://www.sublimemerge.com/docs/linux_repositories. Copy custom commands in Default.sublime-commands file which lives in user packages directory (found via Preferences > Browse Packages... > User).

Download fish and set it as default

sudo dnf install fish
# from https://www.reddit.com/r/Fedora/comments/4q4byk/whatever_happened_to_chsh_in_f24/
sudo lchsh -i zlksnk

Set /usr/bin/fish in lchsh prompt. Open a new shell in windows terminal (not kitty yet). Run fisher update.

Look at errors for commands not found — they would be for zoxide, go and miniconda. Let's install them along with node, fzf, ripgrep and fd.

We would keep seeing a hanging fish shell on each command output. Do ctrl+c to resume commands. Or simply comment errorenous config.fish lines and open shell and uncomment them after we're done installing stuff.

  • Let's install zoxide first
curl -sS https://webinstall.dev/zoxide | bash

If you see an envman entry being added, it possibly added by webinstall.dev. You can remove it from config.fish and do rm -rf .config/envman/.

cd /tmp
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod u+x Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh
Do you wish the installer to initialize Miniconda3
by running conda init? [yes|no]
[no] >>> yes
  • Followed by ripgrep, fzf and fd
sudo dnf install ripgrep fzf fd

Note: fd could be fd-find.

  • Now go
cd /tmp
# grab latest from https://go.dev/doc/install
wget https://go.dev/dl/go1.18.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.18.linux-amd64.tar.gz
sudo dnf install make gcc
curl -L https://git.io/n-install | bash

Installing node will add stuff to config.fish, remove it.

Now that we're done with these, we can start configuring nvim:

bash
# from https://github.com/junegunn/vim-plug for neovim
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
       https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'

Install universal-ctags

ghq get -p https://github.com/universal-ctags/ctags
cd ~/ghq/github.com/universal-ctags/ctags
sudo dnf install make gcc
sudo dnf install autoconf automake
# follow instructions in ctags repo
# another stuff needed by treesitter
sudo dnf install gcc-c++
nvim.appimage
:PlugInstall
# ignore if you see nvim-treesitter errors, just restart neovim

If you see erorrs from nvim-treesitter, do dnf update && dnf groupinstall "Development Tools" and Open nvim again. To determine what is in this groupinstall, do dnf groupinfo "Development Tools". (Actually Development Tools is useless, but it may pull its own deps, that's why mentioned anyway.)

To install color highlighting (vim-hexokinase):

cd ~/.local/share/nvim/plugged/vim-hexokinase
make hexokinase

To install deps needed for gopls and friends to work, go to https://github.com/ajitid/dotfiles/blob/main/nvim/.config/nvim/mine/go/init.vim and at the bottom you'd find commands to install all intelli-deps.

Install pretteird npm install -g @fsouza/prettierd

Install vale (https://github.com/errata-ai/vale/releases):

cd /tmp
# take the latest one
wget https://github.com/errata-ai/vale/releases/download/v2.15.5/vale_2.15.5_Linux_64-bit.tar.gz  
tarunzip vale_2.15.5_Linux_64-bit.tar.gz
cd vale_2.15.5_Linux_64-bit/
mv vale ~/.local/bin/

Install terminal clipboard utility using sudo dnf install xsel.

Copy operator mono ssm and codicon font:

mkdir ~/.fonts
# and copy

and that's it for neovim.

Install tldr npm install -g tldr

For watchexec (https://watchexec.github.io/downloads/watchexec/):

cd /tmp
# download the latest Linux x86-64 musl XZ version
wget https://github.com/watchexec/watchexec/releases/download/cli-v1.18.11/watchexec-1.18.11-x86_64-unknown-linux-musl.tar.xz
tarunzip watchexec-1.18.11-x86_64-unknown-linux-musl.tar.xz
cd watchexec-1.18.11-x86_64-unknown-linux-musl/ 
mv watchexec ~/.local/bin/

Workarounds and fixes

Workaround for wsl clock drift https://github.com/stuartleeks/wsl-clock

try fiddling with ctrl+shift+f10/f11 to turn kitty to fullscreen (without titlebar).

No need for RPM Fusion in my use but good to know that it exists. There's also flathub if you don't want RPM Fusion.

Port hang issue can happen if you update wslg from windows store. (no fix)

wsl --shutdown might not work. (no fix)

If you do sudo vim /etc/dnf/dnf.conf, you'd find Fedora-Remix-for-WSL has set fastestmirror=True and max_parallel_downloads=10. While max_parallel_downloads would help, fastestmirror can make the downloads slower (see https://www.reddit.com/r/Fedora/comments/o95vvj/why_fastestmirror_is_not_enabled_by_default_in/h39ekv3/). So remove fastestmirror line.

You, if you want to, can remove miniconda and envman from ~/.bashrc. I did.