Failing To Purge X11
I've stated before that my primary personal laptop runs Gentoo. It's fun to play around with. I don't mind the extra time compilation takes and it makes me feel like a hacker.
Recently X11 has been in the news. X11 is version 11 of X Windows, the aging GUI underpinnings of much of the Linux ecosystem. The project was started in the 1980s and continues to this day. It's been stable and only accepting bug fixes for a long time. The code is crusty and difficult to work with.
X Vs Wayland
Over the last decade, due to frustration with being unable to innovate or solve longstanding flaws with the design of X because they are fundamental to supported features, many graphics developers, including X developers, began working on a new windowing system for Linux called Wayland. Adoption has been slow because the windowing system is such a major part of a Linux distribution and it takes time to rebuild everything that depends on graphics. But adoption is gaining speed.
At this point adoption has reached a point where none of the X maintainers were applying community supported patches and bug fixes. This lead to someone forking the project to create XLibre. They claim the fork was necessary because "big tech moles" were sabotaging the X project to forcibly move everyone to Wayland faster.
My Position
Though I have not verified the claims in detail, it seems like nonsense to me. X has a lot of legacy crap I don't care about, so it's time to do what I've been flirting with for a while. I've had pure Wayland machines in the past, but for this Gentoo setup I chose the old and stable to not do anything too hard. But I looked the Wayland ecosystem has progressed a lot in the last few years and seems far more usable now. I set out to purge X from my laptop.
Difficulties
Part of what makes Gentoo fun also makes it fussy to work with. Most packages are compiled from scratch, meaning you have control over a lot of compile-time features of every software package on your system. Gentoo controls this through its Portage package manager. Portage is configurable through USE flags, variables which tell Portage which compile time features to use for which package.
USE flags are set in several places. There are system defaults that depend on the "profile" of your system. "Profiles" are pre-configured sets of USE flags to help people get close to the kind of system they want out of the box. For example, a graphical desktop has different default USE flags than a server.
In the easy case, you can just add the USE flag `-X` to your global configuration and rebuild @world. I was not facing the easy case. One of the annoying things about Portage is the additional freedom creates additional snarls and it's hard to know all the configuration changes needed to get a working system at the end. Make heavy use of the –pretend option on all package management.
Of course the first thing I did was remove my old X window manager i3 and its dependencies. That removed disappointingly few X libraries. I had a couple problems.
- I had some binary packages installed that were compiled with X support and thus hard-required it. Whatever, I can live without.
- Many packages, even those that don't hard-require X, still pull in X-requiring versions of their dependencies for features that don't seem obviously related. You have to read a lot of dependency output to make progress here.
- As a result of (2), the only practical solution to keep from tearing your hair out is to uninstall troublesome packages. This hurt because I really didn't want to uninstall things like ffmpeg.
Eventually I got down to about two dozen X libraries, including the base libX11 that I couldn't figure out how to get rid of without breaking my system.
Restore
I decided to stop what I was doing and just restore to a previously good state. Btrfs snapshots to the rescue. All I have to do is reboot from a good snapshot, mount the file system, move the bad root out of the way and replace it with the good snapshot. Easy!
But it was not so easy. My hard drive root is on an encrypted partition, and somehow the snapshot I booted from didn't have the cryptsetup program to decrypt it, so I had no way to move the broken root out of the way.
But because I had snapshots, I had a known good /etc/portage configuration, and I keep all packages I choose to install under /etc/portage/sets which should make my portage configuration entirely declarative. I copied the valid configuration to the current root and set out to reinstall all the things I had removed. The command has been running for about 10 hours now but should finish soon!
I still want to purge X11 from my system, but I will be more careful about it next time.