Running Gentoo on multiple workstations
Last week I’ve migrated my daily-driver laptop 💻 from Artix Linux to Gentoo. I also have Gentoo-powered PC for a ~half a year already, so some experience has accumulated. I always wanted to do that, but there was a fear of unknown:
- Is my CPU performance sufficient for compiling packages?
- What if I don’t have time to compile a package (e.g at work)?
- How am I gonna manage the USE flags?
Of course, none of that shit can stop me!
My CPU is weak 😢
My laptop has a pretty weak CPU (Intel i3) compared to flagship models. My PC has Intel i5, so obviously compiling packages on laptop will be even slower. That is definitely gonna be a problem…
But wait, why don’t we use both CPU’s for compilation? 🤔
Introducing distcc
From Gentoo wiki:
Distcc is a program designed to distribute compiling tasks across a network to participating hosts. It comprises a server, distccd, and a client program, distcc. Distcc can work transparently with ccache, Portage, and Automake with a small amount of setup.
Installation and usage is of course covered in the wiki along with instructions on bootstrapping new machine. Thanks to distcc
installing Gentoo on my laptop was even faster than on more performant PC.
Basically my PC runs a distccd
server in my LAN and my laptop connects to it, sending compilation requests. Now every time I want to compile some heavy packages I just wait to come home and do it at almost twice the speed. There are more optional benefits:
- I can bring my RaspberryPI to the compilation network (not without some cross-architecture magic)
- I can pull up some more old rusty metal, connect it to my LAN and have my packages compiled even faster 🔥
- I can setup ccache and share compilation cache within my network, making heavy package updates finish in seconds
What if I’m outside and don’t have time for compilation? 😱
Actually turns out it’s a very hypothetical situation. Most of the time you already have your toolkit installed anyway. It’s only annoying if you want to try something new - for that I recommend remote or virtual machines (yes, docker
still exists).
In any case, if such an urgent situation occurs, you can just get a binary! There are also ways to setup your own binary package server.
Managing portage configuration across workstations 🛠️
Portage is the best package manager I ever used. The obvious benefit is an ability to split your packages into sets. I can define as many sets as I want, for example here’s my /etc/portage/sets/base
:
app-admin/doas
app-admin/stow
app-editors/neovim
app-shells/dash
app-shells/zsh
dev-vcs/git
app-misc/vifm
net-misc/ntp
I can install everything from this set with emerge --ask --verbose @base
. Or if I want to install everything development-related, I can just install @development
set. As easy as it gets!
This way I can categorize my packages by purpose, compilation time, shared libraries, etc. Each package can belong to many sets. And most importantly, package set is just a plaintext file! You can manually edit it, you can store it under git
, and you can share it across your workstations.
Since portage is fully configurable via plaintext files, the same works for USE flags, keywords, accepted keywords and licenses.