36 KiB
Install a Phundrak-flavored Arch Linux
- Introduction
- Install Arch Linux
- Install basic packages
- Execute bootstrap
- Decrypt private yadm files
- Get a correct keyboard layout
- Set our locale
- Create some folders
- Set user’s shell to fish
- Install
yay
if it isn’t already installed - Install basic packages
- Tangle configuration files from Org files
- Setting up Emacs: Installing Spacemacs
- Set up dotfiles
- Enable some services
- Symlink some system config files
- Install packages from git
- Install Rust
- Install some python packages
- Install go packages
- Set up Chicken (Scheme interpreter/compiler)
- Clean the
pacman
andyay
cache - Export configuration file from org files
- Set up our fish shell
Introduction
Here will be presented what I do to get my system up and running on a fresh Arch Linux install. These installation instructions were written in order to get an Arch Linux distribution up and running with the same configuration as my main computer’s and my travelling laptop’s configuration.
Install Arch Linux
I usually install Arch from the vanilla ISO, however I began using archfi to
install easily the distro (I’ve done it so many times, I know how it works
now). Usually, my distros will be installed on at least two partitions, one
dedicated to /home
, the other to the root partition /
.
If the computer supports EFI bootloaders, the EFI partition will be mounted on
/boot
. I generally use rEFInd as my boot manager, but if you are more
comfortable with another one, just install what you want. Be aware that if you
format your /boot
partition, you will delete all boot managers that already
exist; so, if you are dual-booting, DO NOT FORMAT IT. Yes, I made the
mistake of wiping the Windows boot manager.
The swap partition is always at least 4GB large, and I should have a total of 12GB of combined RAM and swap. This means on my main computer I have 16GB of RAM and 4GB of swap, but on my thinkpad I have 4GB of RAM and 8GB of swap.
Get the latest live system with fast mirrors
When you boot into the live ISO, execute the following command:
pacman -Sy reflector
reflector -c France -c Germany -l 200 -p http -p https --sort rate \
--save /etc/pacman.d/mirrorlist --verbose
This will update the packages from your live ISO, and you will get the best mirrors for your installation. Of course, change the countries accordingly to your location.
Install the system
Then you can use a custom script to ease your installation of Arch if you do not wish to do it manually. Personally, I’ve done it several times already, I know how the distro works, I just want to be able to install my distro quickly now.
wget archfi.sf.net/archfi
# Or from matmoul.github.io/archfi if SourceForge is down
sh archfi
Then, follow the instructions and install Arch Linux. Take the opportunity to
install as many packages as you need, mainly yay
which I use as my package
manager (it is just a wrapper for pacman
) and AUR helper, and
pacman-contrib
which will help us installing some packages later.
Once your system is installed, reboot and remove your installation media from your computer.
Install basic packages
We will need some basic packages in order to run the bootstrap file. So, let’s
install fish
(our shell running the script) and git
.
yay -Sy fish git yadm
Execute bootstrap
yadm
comes with a very handy feature: its bootstrap script. It can be
executed automatically once the dotfiles are cloned with yadm:
yadm clone https://labs.phundrak.com/phundrak/dotfiles
# or if labs.phundrak.com is down or too slow for you
yadm clone https://github.com/phundrak/dotfiles
Notice these two header files, we can see this is a fish script, hence why we need fish (which is my daily shell anyway).
#!/usr/bin/fish
# -*- mode: fish -*-
Let’s take a look at what it does.
Decrypt private yadm files
Some private files are stored encrypted in the repository of my yadm dotfiles. I will need them later on during the bootstrap execution.
yadm decrypt
Get a correct keyboard layout
I use mainly the bépo layout, a French keyboard layout inspired by Dvorak layouts, however I sometimes need to switch back to the standard French AZERTY or the American QWERTY layout, so I make it so the Menu key switches for me my layout between these three. This makes it so my xorg configuration of my keyboard looks like this:
set keyboardconf \
'Section "InputClass"
Identifier "system-keyboard"
MatchIsKeyboard "on"
Option "XkbLayout" "fr,fr,us"
Option "XkbModel" "pc104"
Option "XkbVariant" "bepo_afnor,,"
Option "XkbOptions" "grp:menu_toggle"
EndSection'
So, let’s set it as our keyboard configuration.
printf "\n# Set keyboard layout #########################################################\n\n"
echo $keyboardconf | sudo tee /etc/X11/xorg.conf.d/00-keyboard.conf
Set our locale
I use two main locales, the French and US UTF-8 locales, and I like to keep the Japanese locale activated just in case.
set mylocales "en_US.UTF-8 UTF-8" "fr_FR.UTF-8 UTF-8" "ja_JP.UTF-8 UTF-8"
Let’s enable these.
printf "\n# Set locale ##################################################################\n\n"
for item in $mylocales
if test (grep -e "#$item" /etc/locale.gen)
sudo sed -i "/$item/s/^#//g" /etc/locale.gen
end
end
This is my configuration I usually use when it comes to my locale.
set localeconf "LANG=en_US.UTF-8
LC_COLLATE=C
LC_NAME=fr_FR.UTF-8
LC_NUMERIC=fr_FR.UTF-8
LC_IDENTIFICATION=fr_FR.UTF-8
LC_TELEPHONE=fr_FR.UTF-8
LC_MONETARY=fr_FR.UTF-8
LC_PAPER=fr_FR.UTF-8
LC_ADDRESS=fr_FR.UTF-8
LC_TIME=fr_FR.UTF-8
LC_MEASUREMENT=fr_FR.UTF-8"
Let’s set it as our system’s locale.
echo $localeconf | sudo tee /etc/locale.conf
Now we can generate our locale!
printf "\n# Generate locale #############################################################\n\n"
sudo locale-gen
Create some folders
Let’s create some folders we might need for mounting our drives, Android devices and CDs.
printf "\n# Create directories for mounting #############################################\n\n"
sudo mkdir -p /mnt/{USB,CD,Android}
sudo chown $USER:(id -g $USER) /mnt/{USB,CD,Android}
We also need the following folder for our nano backups.
mkdir -p $HOME/.cache/nano/backups
Set user’s shell to fish
First of all, the bootstrap shell will set the user’s shell to fish.
printf "\n# Set fish as the default shell ###############################################\n\n"
if not test "$SHELL" = "/usr/bin/fish"
chsh -s /usr/bin/fish
end
Install yay
if it isn’t already installed
Now we’ll need to be sure yay
, our AUR helper, is installed on our system.
If it is, we don’t need to to anything. However, if it isn’t, we’ll install
it manually.
if ! test (which yay)
printf "\n# Installing yay ##############################################################\n\n"
cd
mkdir -p ~/fromGIT
cd ~/fromGIT
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si --noconfirm
else
printf "\n# yay already installed #######################################################\n\n"
end
Install basic packages
Let’s set in a custom varible what packages we’ll be needing.
set PACKAGES \
acpilight adobe-source-han-sans-jp-fonts asar ascii aspell-en aspell-fr \
awesome awesome-terminal-fonts awesome-freedesktop-git base-devel bat biber \
bluez-firmware bluez-utils bookworm bzip2 ccls chicken chromium clisp cppcheck \
cppreference cppreference-devhelp cpupower discord-canary discount dmenu-lpass \
docker docker-compose dockerfile-language-server-bin doxygen dunst emacs \
emacs-org-mode exfat-utils farbfeld ffmpegthumbnailer findutils firefox flake8 \
freeglut fzf gcc-libs gdb gimp gnome-disk-utility gnome-epub-thumbnailer \
gnu-free-fonts gnuplot go-tools golangci-lint-bin graphviz htop \
i3-gaps-rounded-git i3lock-blur igdm-bin inetutils j4-dmenu-desktop \
javascript-typescript-langserver js-beautify jfsutils jmtpfs lain-git less \
linux-headers lldb logrotate lvm2 ly meson minted man-db man-pages mpc mpd \
mpd-rich-presence-discord-git mpv mupdf-tools nano ncdu ncmpcpp nemo-fileroller \
nemo-preview neofetch netctl networkmanager networkmanager-openvpn \
nm-connection-editor nodejs-vmd nomacs nordvpn-bin noto-fonts-emoji npm ntfs-3g \
numlockx openssh otf-fandol otf-ipafont p7zip pacman-contrib pandoc-bin pass \
pavucontrol pdfpc picom-ibhagwan-git polybar powerline-fonts prettier \
pulseaudio-bluetooth python-autoflake python-envtpl-git python-epc \
python-importmagic python-language-server python-nose python-pip python-ptvsd \
python-pytest python-pywal qt5-imageformats qemu r raw-thumbnailer reflector \
rofi rsync rtv rustup samba scrot sent shadow siji-git simplescreenrecorder \
sshfs st-luke-git sxiv texlive-bin texlive-langchinese texlive-langcyrillic \
texlive-langgreek texlive-langjapanese texlive-langkorean texlive-latexextra \
texlive-localmanager-git texlive-most tmux tree ttf-arphic-uming ttf-baekmuk \
ttf-dejavu ttf-google-fonts-opinionated-git ttf-hanazono ttf-joypixels \
ttf-koruri ttf-liberation ttf-monapo ttf-sazanami ttf-tibetan-machine \
typescript typescript-language-server-bin unicode-emoji unrar usbutils valgrind \
vscode-css-languageserver-bin vscode-html-languageserver-bin w3m wget \
x11-ssh-askpass xclip xdg-user-dirs-gtk xfsprogs xorg-drivers xorg-server \
xorg-xinit xss-lock xvkbd yaml-language-server-bin yapf
These are the minimum I would have in my own installation. You can edit it however you want. Let’s install those.
printf "\n# Installing needed packages ##################################################\n\n"
sudo pacman -Syu
for pkg in $PACKAGES
yay -S --needed $pkg
end
Tangle configuration files from Org files
The next step is to tangle all the Org files. Here is the list of files that are to be tangled:
filename |
---|
bin.org |
fish.org |
i3.org |
index.org |
nano.org |
polybar.org |
spacemacs.org |
tmux.org |
printf '\n\n==== Tangling bin.org\n\n' && \ emacs -q --batch --eval '(require \'ob-tangle)' \ --eval '(setq org-confirm-babel-evaluate nil)' \ --eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \ --eval '(org-babel-tangle-file "~/org/config/bin.org")' printf '\n\n==== Tangling fish.org\n\n' && \ emacs -q --batch --eval '(require \'ob-tangle)' \ --eval '(setq org-confirm-babel-evaluate nil)' \ --eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \ --eval '(org-babel-tangle-file "~/org/config/fish.org")' printf '\n\n==== Tangling i3.org\n\n' && \ emacs -q --batch --eval '(require \'ob-tangle)' \ --eval '(setq org-confirm-babel-evaluate nil)' \ --eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \ --eval '(org-babel-tangle-file "~/org/config/i3.org")' printf '\n\n==== Tangling index.org\n\n' && \ emacs -q --batch --eval '(require \'ob-tangle)' \ --eval '(setq org-confirm-babel-evaluate nil)' \ --eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \ --eval '(org-babel-tangle-file "~/org/config/index.org")' printf '\n\n==== Tangling nano.org\n\n' && \ emacs -q --batch --eval '(require \'ob-tangle)' \ --eval '(setq org-confirm-babel-evaluate nil)' \ --eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \ --eval '(org-babel-tangle-file "~/org/config/nano.org")' printf '\n\n==== Tangling polybar.org\n\n' && \ emacs -q --batch --eval '(require \'ob-tangle)' \ --eval '(setq org-confirm-babel-evaluate nil)' \ --eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \ --eval '(org-babel-tangle-file "~/org/config/polybar.org")' printf '\n\n==== Tangling spacemacs.org\n\n' && \ emacs -q --batch --eval '(require \'ob-tangle)' \ --eval '(setq org-confirm-babel-evaluate nil)' \ --eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \ --eval '(org-babel-tangle-file "~/org/config/spacemacs.org")' printf '\n\n==== Tangling tmux.org\n\n' && \ emacs -q --batch --eval '(require \'ob-tangle)' \ --eval '(setq org-confirm-babel-evaluate nil)' \ --eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \ --eval '(org-babel-tangle-file "~/org/config/tmux.org")'
printf "\n# Tangling org files ##########################################################\n\n"
<<generate-tangle()>>
Let’s also make sure the exported files that are supposed to be executables are indeed executables.
find ~/.local/bin -type f -exec chmod +x {} +
Setting up Emacs: Installing Spacemacs
Now, the first thing we want to do with Emacs is install its Spacemacs
distribution. We’ll clone its develop
branch into ~/.config/emacs
. We
need to do this prior to our dotfiles’ cloning because of some submodules
that are cloned within our ~/.config/emacs
directory, and git won’t let us
clone Spacemacs in an already existing and non-empty directory. To make sure
it isn’t one, let’s delete any potentially existing ~/.config/emacs
directory:
printf "\n# Installing Spacemacs ########################################################\n\n"
rm -rf ~/.config/emacs
Now we can clone Spacemacs:
git clone --single-branch --branch develop https://github.com/syl20bnr/spacemacs ~/.config/emacs
And we can restore what might have been deleted in our ~/.emacs.d/private
directory:
yadm checkout -- ~/.config/emacs/private/
Set up dotfiles
Update our dotfiles’ remotes
This line in the bootstrap script will test if the current user is using my username. If yes, it’s probably me.
if ! test (echo "phundrak" | sed -e "s/^.*$USER//I")
If it is me installing and using these dotfiles, I want the remotes of my dotfiles to be set to ssh remotes using my ssh keys.
printf "\n# Update yadm’s remotes #######################################################\n\n"
yadm remote set-url origin git@labs.phundrak.com:phundrak/dotfiles.git
yadm remote add github git@github.com:phundrak/dotfiles.git
I will also want to decrypt my encrypted files, such as said ssh keys.
printf "\n# Decrypt encrypted dotfiles ##################################################\n\n"
yadm decrypt
Finally, let’s close this if
statement.
end
Get envtpl
Before we set our dotfiles up, let’s make sure envtpl
is correctly
installed. This package will be needed for generating our alt dotfiles.
printf '\n# Install envtpl ##############################################################\n\n'
yay -Syu --needed python-envtpl-git
Update our submodules
Now we can download the various dependencies of our dotfiles. To do so, let’s run the following command:
printf "\n# Getting yadm susbmodules ####################################################\n\n"
yadm submodule update --init --recursive
Enable some services
We have installed some packages which require some services to run. Let’s enable them.
Systemd-timesyncd
This service enables time syncing with the NTP protocol, so I can be sure my computer’s time is correct. The service first needs to be enabled:
printf "\n# Enabling timesync ###########################################################\n\n"
sudo systemctl enable --now systemd-timesyncd
Now, let systemd know I want to use the NTP protocol to keep my computer’s time synced.
sudo timedatectl set-ntp true
Docker
First, let’s activate Docker.
printf "\n# Enabling and starting Docker ################################################\n\n"
sudo systemctl enable --now docker
Now, if we wish it, we can be added to the docker
group so we won’t have
to type sudo
each time we call Docker or Docker Compose.
read --prompt "echo 'Do you wish to be added to the `docker` group? (Y/n): ' " -l adddockergroup
if test $adddockergroup = 'y' || test $adddockergroup = "Y" || test $adddockergroup = ''
sudo usermod -aG docker $USER
end
Emacs
Emacs will run as a user service, which means it won’t be launched until we log in.
printf "\n# Enabling Emacs as user service ##############################################\n\n"
systemctl --user enable --now emacs
Mpd
Mpd will also use as a user service in order to get rid of some lines of code in my configuration.
printf "\n# Enabling Mpd as a user service ##############################################\n\n"
mkdir -p ~/.config/mpd/playlists
systemctl --user enable --now mpd
SSH server
Maybe we want to activate an SSH server on our machine. If so, we can enable it. Let’s ask the question.
read --prompt "echo 'Do you want to activate the ssh server? (Y/n): ' " -l sshdserver
if test $sshdserver = 'y' || test $sshdserver = "Y" || test $sshdserver = ''
printf "\n# Enabling ssh server #########################################################\n\n"
sudo systemctl enable --now sshd
end
Ly
Ly is a display manager based on ncurses which I find nice enough for me to use (I generally don’t like using display managers). Let’s enable it, and let’s disable tty2 while we’re at it (Ly uses it to run X).
sudo systemctl enable --now ly
sudo systemctl disable getty@tty2
Acpilight
acpilight
is our utility managing the brightness of our screen. There is
actually no service to enable here, but we must ensure the user is part of
the video
group so we can modify the brightness of our screen without
using sudo
.
sudo usermod -aG video $USER
NordVPN
Thanks to the AUR package nordvpn-bin
, I no longer have to manually
maintain my VPN connections manually with OpenVPN. However, it requires a
service that we should activate:
sudo systemctl enable --now nordvpnd
Symlink some system config files
We have some files in etc/ that are to be symlinked to /etc
.
for f in (find ~/.etc -type f)
set dest (echo $f | sed -n 's/^.*etc\(.*\)$/\/etc\1/p')
sudo ln -s $f $dest
end
We may also want to symlink our nanorc to the /root
directory for when we
use nano
as sudo
.
read --prompt "echo 'Symlink .nanorc to root’s .nanorc? (Y/n): ' " -l nanoroot
if test $nanoroot = 'y' || test $nanoroot = "Y" || test $nanoroot = ''
printf "\n# Symlinking .nanorc to root’s .nanorc ########################################\n\n"
sudo ln -s $HOME/.nanorc /root/.nanorc
end
Install packages from git
Now, let’s install some packages from git directly.
mkdir -p ~/fromGIT
Polybar Battery
Now let’s install polybar-battery
. This is a binary that I’ll use in my i3
config to indicate my battery level. It also sends a notification on low
battery and on charging completed.
printf "\n# Install polybar-battery #####################################################\n\n"
cd ~/fromGIT
git clone https://github.com/drdeimos/polybar_another_battery.git
cd polybar_another_battery
go get -u github.com/distatus/battery/cmd/battery
make build
Now, we have our binary, let’s symlink it in our local binary directory,
~/.local/bin
.
cd ~/.local/bin
ln -s ~/fromGIT/polybar_another_battery/polybar-ab polybar-ab
Reveal.JS
I sometimes use Reveal.JS to make presentations, and I set its location in
my dotspacemacs file to be in ~/fromGIT
, so let’s clone it there.
printf "\n# Install Reveal.JS ###########################################################\n\n"
cd ~/fromGIT
git clone https://github.com/hakimel/reveal.js.git
Install powerline fonts
I also need some powerline fonts for my terminal theme.
printf "\n# Install powerline fonts #####################################################\n\n"
cd ~/fromGIT
git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
./install.sh
fc-cache -vf
Install Rust
Install the toolchains
When using rust, I bounce between two toolchains, the stable
toolchain and
the nightly
toolchain. To install them, I will use rustup
which has
already been installed.
printf "\n# Install the rust toolchains, nightly is the default one #####################\n\n"
rustup default nightly
This will both download the nightly toolchain and set it as the default one. Yup, I like to live dangerously. Now to install the stable toolchain, let’s run this:
rustup toolchain install stable
Install some utilities
We’ll need some utilities when developing Rust from Emacs, namely rustfmt
and racer
. Let’s install them with cargo
.
printf "\n# Add rust utilities ##########################################################\n\n"
cargo install rustfmt racer
We will also need some components for development purposes:
rustup component add src
rustup component add rls
Install some python packages
Some packages will be needed from pip in order to get our Emacs setup correctly working. Let’s install them locally for our user:
printf "\n# Installing Python packages ##################################################\n\n"
pip install --user pyls-isort pyls-mypy
For some reason, the version of jedi
installed with the Python language
server is too recent, it is required by pyls
. So, let’s replace it:
sudo pip uninstall jedi
sudo pip install 'jedi<0.16,>=0.14.1'
Hopefully this will be fixed soon.
Install go packages
For go development from Emacs, the Spacemacs go and lsp layers requires some packages to be installed.
printf "\n# Installing Go packages ######################################################\n\n"
go get -v golang.org/x/tools/gopls@latest
go get -u -v golang.org/x/tools/cmd/godoc
go get -u -v golang.org/x/tools/cmd/goimports
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v golang.org/x/tools/cmd/guru
go get -u -v github.com/cweill/gotests/...
go get -u -v github.com/davidrjenni/reftools/cmd/fillstruct
go get -u -v github.com/fatih/gomodifytags
go get -u -v github.com/godoctor/godoctor
go get -u -v github.com/golangci/golangci-lint/cmd/golangci-lint
go get -u -v github.com/haya14busa/gopkgs/cmd/gopkgs
go get -u -v github.com/josharian/impl
go get -u -v github.com/mdempsky/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/zmb3/gogetdoc
go get -u -v golang.org/x/tools/gopls
Set up Chicken (Scheme interpreter/compiler)
Chicken needs to be set up before being used. First, we need to install its documentation.
printf "\n# Setting up Chicken ##########################################################\n\n"
chicken-install -s apropos chicken-doc
Then, we’ll complete the documentation like so:
cd (chicken-csi -b -e "(import (chicken platform))" -p "(chicken-home)")
curl https://3e8.org/pub/chicken-doc/chicken-doc-repo.tgz | sudo tar zx
Clean the pacman
and yay
cache
Finally, we are almost done! Let’s clean the cache of pacman
and yay
.
printf "\n# Clean the pacman and yay cache ##############################################\n\n"
yay -Sc --noconfirm
Export configuration file from org files
As I strive to write most of my configuration file as literary programming files through org-mode, they are not versioned nor downloaded by git when cloning my dotfiles. This is why
Set up our fish shell
The last thing we want to do is to set up our fish shell with some extensions in order to improve the user experience.
Install fisher
We will be using fisher
as our extensions manager for Fish. Let’s install
it.
printf "\n# Installing fisher ###########################################################\n\n"
curl https://git.io/fisher --create-dirs -sLo ~/.config/fish/functions/fisher.fish
Install our extensions
I generally use the following extensions in my Fish shell.
Package name | Description |
---|---|
fishpkg/fish-prompt-metro | Fast, git-aware, space-conscious, Powerline prompt |
jorgebucaran/fish-bax | Run bash scripts, replaying environment changes in fish |
franciscolourenco/done | Automatically receive notifications when a long process finishes |
jethrokuan/fzf | Improved key bindings for junegunn/fzf |
jethrokuan/z | Pure-fish rupa/z-like directory jumping |
jorgebucaran/fish-getopts | CLI options parser; alternative to the argparse fish builtin |
laughedelic/pisces | Autoclose parentheses, braces, quotes and other paired symbols |
acomagu/fish-async-prompt | Make your prompt asynchronous to increase it reactivity |
fisher add fishpkg/fish-prompt-metro fisher add jorgebucaran/fish-bax fisher add franciscolourenco/done fisher add jethrokuan/fzf fisher add jethrokuan/z fisher add jorgebucaran/fish-getopts fisher add laughedelic/pisces fisher add acomagu/fish-async-prompt
printf "\n# Installing Fisher Extensions ################################################\n\n"
<<fish-ext-py()>>