Switching to Gentoo
Here I explain why I switched to Gentoo and how I set it up. This is mostly a technical blog and incorporates some of my configuration.
Author: Coding Otaku
Date Created:
Date Updated:

The prologue
I have changed my operating system a lot of times, and I finally settled with Arch Linux, or so I thought.
I mentioned the beginning of my journey in my "Why do I say GNU/Linux?" blog, since then, I have moved on to many variants of GNU/Linux.
After going through many "distro hopping" phases, I settled with both Debian, and Arch Linux as they were to my liking.
Contrary to what most people say, Arch Linux is very stable, you just need to install it right, and also read the Arch Linux news before every update that has important packages. I stayed on Arch Linux for almost 6 years and I did not face any stability issues nor had to chroot to fix problems.
Debian is what I still use to run my server, an occasional system update and maintenance for the services I host are what I mostly do there. It is very stable, and I will probably never switch from Debian for servers.
So why the switch to Gentoo?
Believe it or not, I did not really want to try out Gentoo, all the memes about compiling Gentoo system kept me away from it.
What I really wanted to install was GNU GUIX, yes, I use a modern system, and yes, GUIX will not work on my system unless I include the "nonguix" repository and install mainline Linux instead of Linux-libre.
But I wanted to try out GNU GUIX anyway, so I backed up my system, and started installing GNU GUIX. It was fairly easy to install, I also had to look up an article written by David Thompson about installing nonguix on ThinkPad X1. The article helped me install the system without needing to build a custom ISO!, I'm very grateful for that.
Soon after the installation, I started fumbling as I modify the configuration files which were in Guile, which is written in Scheme programming language, and that language is part of Lisp family.
It wasn't easy, I still haven't figured my way around lisp (though I am using Emacs to write this article). I was making silly mistakes, needing to read the documentation multiple times, and copy-pasting things I don't fully understand.
I decided that instead of doing something completely unknown and breaking my system, I should start learning more about the language before even trying out GNU GUIX. Going back to my Arch Linux setup was in my mind, but I was still in my distro hopping mood. So I tried out Gentoo, which was one of the mainstream distribution of GNU/Linux that I was yet to try.
Installation
Installing Gentoo was not that hard, if I compare it to my previous Arch Linux installs, Gentoo is slightly more time-consuming, but it makes up for that with the power of "choice", which is the philosophy of Gentoo. I am not documenting my installation steps here, the official Gentoo handbook already does a great job in doing that.
Building a pure Wayland system
Since Gentoo is a source based distribution, and has the wonderful USE flag feature, I decided to build a pure wayland system. I am not against the X window system, but I was curious to know where we are on using Wayland native programs in GNU/Linux, I was running everything on Wayland in my previous arch install anyway.
Setting up the useflag was easy, remove the support of "X" and add support of "Wayland" in my /etc/portage/make.conf
file.
USE="wayland -X"
While I was at it, I also removed the systemd support from packages as I already use OpenRC as init system, which is 100% compatible with Gentoo init scripts. Additionally, I added the -telemetry
flag to avoid telemetry that might enter my system as I install more packages.
USE="wayland -X -systemd -telemetry"
There were many packages that I used in my previous Arch installs which runs on Wayland, I have the list archived in my arch-post-install repository. One could say that I was already running a pure Wayland system.
I now use nearly the same base packages, with some minor changes, like using Emacs without GUI instead of Neovim as I want to learn more Lisp, and light (depricated) instead of brightnessctl, etc., they all work and has nothing to do with Wayland or X.
Problems I faced while building a pure Wayland system
I started adding more useflags as I choose and install more packages, and I realized that Firefox and Qt5 pulls in the libX11
(X headers) regardless of the -X
flag. Some QT packages also fails to compile without the libX11
library. LibreWolf is my browser of choice, and I was able to build it without X
.
I found the solution for QT packages in one of the resolved Gentoo bugs, it was to add -DQT_EGL_NO_X11
flag to the CXXFLAGS
in the /etc/portage/make.conf
file. With that, I was able to install all the packages that I use without any compile errors.
Well, almost all. Both Thunderbird and Signal were not playing nice to my configuration. Thunderbird still requires X
and Signal only distributes signal-desktop-bin
which has X. Oh well, I don't use them much these days anyway, it would be nice if I can build thunderbird at least without X
, I did not manage to create an ebuild (text file for package manager that contains instruction on how to install a package) for it.
Update: As of , Thunderbird v115 and above lets you build without X headers because it depends on Firefox v115 that has pure wayland support, I still have no hope for Signal as it provides a generic binary.
Nextcloud Desktop was also not building without x11-libs/libX11
, I do not use the Nextcloud GUI much, so I searched for ways to build the nextcloud-desktop-cmd
instead. There is an open issue in their repository to build the nextcloud-desktop-cmd
without the QT GUI libraries, for now, I use rclone to sync things with my Nextcloud instance.
A couple of nice-to-have packages were missing in the official Gentoo repository, though I was able to find an ebuild repository for them, I decided to make one by myself for those packages, it is now available in codeberg.org/codingotaku/cowaybuilds.
I also have some useful scripts that runs in fuzzel menu to make some things easier to do, they can be found in codeberg.org/codingotaku/fuzzel-scripts
Managing configurations
Useflags will pile up as you install more packages, I avoid adding a global useflag if it is used by only one package or the flags are tagged as a Local Use Flags
. I still have a lot of useflags in my /etc/portage/make.conf
, so I split them into categories like below.
nice_to_have_flags="hardened wayland iwd gsl dbus udev readline" graphics_flags="vulkan eglfs sdl egl v4l vaapi gles2-only gles2 opencl" image_formats="jpeg jpegxl png tiff webp svg gif exif heif ogg xml" media_flags="pulseaudio screencast ogg dvb ${image_formats}" allowed_flags="${nice_to_have_flags} ${graphics_flags} ${media_flags}" disallowed_flags="-X -XWayland -systemd -telemetry -clang -vdpau -cuda -xvmc -alsa" USE="${allowed_flags} ${disallowed_flags}"
The flags in /etc/portage/package.use
(Local Use Flags) are much simpler, they are created per package, and useflags for their dependencies are also included in their parent package.
Below is the output of tail -n +1 *
in my /etc/portage/package.use/
directory.
==> 00cpu-flags <== */* CPU_FLAGS_X86: aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 ==> fuzzel-flags <== gui-apps/fuzzel cairo ==> iwd-flags <== net-wireless/iwd standalone wired ==> keepass-flags <== app-admin/keepassxc browser dev-libs/qtkeychain keyring ==> libcamera-flags <== media-libs/libcamera uvcvideo gstreamer ==> librewolf-flags <== www-client/librewolf eme-free system-png system-jpeg system-av1 system-webp system-libvpx system-harfbuzz system-icu system-libevent openh264 >=media-libs/libvpx-1.12.0-r1 postproc >=media-libs/libpng-1.6.39 apng ==> mesa-flags <== media-libs/mesa -proprietary-codecs >=x11-libs/libdrm-2.4.110 video_cards_radeon ==> mpv-flags <== media-video/mpv lua sixel -xv media-video/ffmpeg x264 ==> nheko-flags <== >=dev-qt/qtmultimedia-5.15.9 qml gstreamer widgets >=dev-qt/qtquickcontrols2-5.15.9 widgets ==> pipewire-flags <== media-video/pipewire sound-server bluetooth modemmanager ffmpeg gstreamer lv2 echo-cancel extra pipewire-alsa media-sound/pulseaudio -X -daemon ==> rust-flags <== dev-lang/rust clippy rustfmt ==> sway-flags <== gui-wm/sway tray swaybar -swaynag media-libs/freetype harfbuzz sys-auth/seatd server
What did I learn?
Setting up a source based distribution like Gentoo is not hard, but it is a bit time-consuming. Once you have a setup that you are happy with, the maintenance work like updating packages and adding functionalities are very easy to do. The updates can be done in the background, or on weekends.
It is not necessary to update the packages everyday like what most people do in Arch Linux, I update the system if there is a security update, or on weekends. The package updates can be run on background if I limit the number of CPU threads to build, so it never interferes with my tasks.
Having control over what a package use to build is extremely useful, it keeps the system more secure by reducing the attack vector, while keeping the system minimal, usable, and stable.
Will I ever move from Gentoo?
Probably, I still want to give GNU GUIX another try, I may not do it anytime soon as I"m feeling at home with Gentoo.