summaryrefslogtreecommitdiff
path: root/src/pages/blog/2022-04-17.md
blob: 01b1ed79847c8fa28e300e27eaa554ccf3ec62c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
layout: ../../layouts/BlogLayout.astro
---
# Running Gentoo :gentoo: on multiple workstations
Last week I've migrated my daily-driver laptop :computer: from [Artix Linux](https://artixlinux.org/) to [Gentoo](https://www.gentoo.org/). 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 :cry:
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? :thinking:


## Introducing `distcc`
From [Gentoo wiki](https://wiki.gentoo.org/wiki/Distcc):
> 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 :raspberry-pi: 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* :fire:
 - I can setup [ccache](https://wiki.gentoo.org/wiki/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? :scream:
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](https://wiki.gentoo.org/wiki/Binary_package_guide).

# Managing portage configuration across workstations :hammer_and_wrench:
[Portage](https://wiki.gentoo.org/wiki/Portage) is **the best** package manager I ever used. The obvious benefit is an ability to split your packages into [sets](https://wiki.gentoo.org/wiki/Package_sets). I can define as many sets as I want, for example here's my `/etc/portage/sets/base`:
```bash
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.