haewyr

A FreeBSD desktop - part 2

In the last post I installed FreeBSD and wrestled with drivers and got the GPU up and running. The next step was to install a usable desktop environment. I did consider briefly installing a window manager as I am interested in updating my knowledge of them but at this point in time I think just getting more intimate with FreeBSD is enough of a challenge.

As I am using senior hardware I decided on installing MATE desktop which I haven't used much in a long while but was a avid GNOME 2 user back in the day. Installing MATE was simple following the handbook I ran pkg install mate and also installed lightdm as a login manager. With a couple of lines added to /etc/rc.conf I could now reboot and land straight into a graphical login prompt!

Running MATE is like slipping into a well worn pair of jeans. I'm instantly familiar with it and can get around it easily. It is fast and provides all the configurable options I could want. It even looked decent from the default configuration. I checked my resources and saw that with just the desktop loaded my memory usage hovered just over half a GiB! I installed Firefox and had a nice time playing around with it for a few hours.

I still wanted to get WiFi working though, I decided to pick up a different USB Wifi dongle, this one is a TP-Link TL-WN725N, a 802.11n adapter based on the RTL8188EU chipset that should be compatible with FreeBSD. For the princely sum of £5 it didn't need much mulling over and I ordered it for next day. When it arrived I plugged it in and went through configuring it per the handbook. This seemed to go well, it brought the link up and got an address. I tried installing some packages to test it but it wasn't clear whether it was preferring it over the wired Ethernet - probably not - so I disconnected the wired connection and the network dropped out completely! I restarted the networking service and connectivity came back up, definitely over the WiFi this time. The speeds I was getting were poor though, downloads were peaking at about 6mbps, my Internet connection is two orders of magnitude faster than this so something seemed wrong. I tried plugging the wired connection back in and restarted networking again and this time I was pulling downloads about 10x faster, still slow but better. I don't know what is causing this issue, it might be the dongle, it might be the FreeBSD drivers, it'll need more investigation when time permits but for now, I'm just happy it works at all.

By now I felt this install was getting too messy so I decided to start over and wiped the SSD. This time I installed Wifi during installation and it worked from the start. I dropped to the shell and installed the Nvidia drivers and Xorg and set up the hardwired configuration bypassing Xorg auto-configure. This now worked from the get go and I ran zfs snapshot zroot@postinstall to snapshot the machine in this state so I can rewind back here without doing a full reinstall again in future.

This time I decided to try XFCE which I have more recent experience with although usually under a heavy theming job like on Linux Mint. This time I'm running it with the default configuration and it is actually very pleasant on a 1080p display.

I went to install some of my standard applications, but I was interested in trying the ports collection as I have not used this in a long time. For those unfamiliar, the port collection is a directory tree installed in /usr/ports that contains a set of scripts for automatically downloading, configuring, compiling and installing package straight from source. This can be a time consuming process so it's often easier to just use pkg install <name> to install a pre-compiled binary, but the binary packages will be built from the ports collection by the maintainers. Using ports means I can include/exclude features, reduce dependencies and optimise the software for my use case, this theory. In practice I don't think this is true anymore and I'll explain why.

To start with I choose a "simple" app I use every day, KeepassXC, assuming that a behemoth like Firefox or Libre Office would take days to compile. I started the process off like this:

$ cd /usr/ports/security/keepassxc
$ make install clean

That's the basic use of the ports tree, it now presents a TUI menu where you select your configurable options and it then does this again for each of the dependencies, and their dependencies, and their dependencies, and so on.

The configuration menus normally appear one package at a time so it can spend a few minutes compiling one package then ask for input to start the next one. After a while of doing this I realised I didn't have all night and was adding little value to the process so I cancelled the process with ctrl-c and decided to look ahead at just how many dependencies are in the KeepassXC tree, I found make all-depends-list should provide a list of them all and it filled the page, and another, and another... I ran it again make all-depends-list | wc -l to count the number of dependencies and the result was over 800 packages!!

I was intending to run a command to run the configuration steps all together up front but even this seemed woefully naive given the scale of the job. I also had to recognise that my little dual-core machine was not up to it, no doubt the machines they use to build the binary packages are huge Threadripper servers and can do the job in a fraction of the time but that isn't the case here and I might be looking at a compile time measured in weeks or even months! It's nice the ports tree is available, but for practical every day use I think it's now best left as just a tool for binary package maintainers.

As an aside it was an very eye-opening experience seeing just how complex modern software has become. It made me think about the libxz backdoor and how that was caught by the slimmest of coincidences. When you've a "simple" application that pulls in hundreds upon hundreds of packages to build, the attack surface now isn't just polygonal, it's fractal! I have no doubt that similar backdoors are widespread in software today and more are being added all the time without anyone becoming any the wiser to it. I am feeling a strong urge now to switch away from as many GUI apps as possible towards simpler CLI/TUI apps but I'm unsure whether even this will be enough.