Building a Homelab, Part 3 - Patch Panel, Email, Minecraft Server

January 3, 2024 | 10 min. read


Happy New Year! This is the newest post in a series I'm doing on my adventures in homelabbing. Read the previous posts first!

This should be a pretty short update. Most of the additions to the lab are of pretty minimal impact, or took little effort.

Patch It Up

The first big one is upgrading the networking switch from a dinky 8-port TP Link switch to a 24-port switch from TrendNet. There's no rhyme or reason behind why I chose that particular model - I was actually at the last remaining MicroCenter in California when visiting family when I saw it on the shelf. It was the cheapest model, and I figured that there's likely no discernible difference in quality between any given unmanaged network switches After all, it's called commodity hardware! .

In addition, I've finally made use of the patch panel and punched down some CAT6 cabling for the first time. Turns out, it was super easy - all I needed was this tutorial, a keystone for practice, and I had it down within 5 minutes. I bungled up the labeling on the patch panel itself before realizing I was writing in permanent Sharpie rather than dry erase marker, but it's a dumb switch so I don't really need to keep track of what's plugged into what port.

Here it is, in all its glory:

I also bought a Phillips Hue hub, which is to the left of the RasPi rack. I don't really consider it part of the lab though, since it's a plug-and-play appliance and isn't integrated with anything other than WiFi. I got a few smart bulbs and a smart LED strip to put around my apartment, so I'll probably set up Home Assistant in the future.

Email

There's a bunch of software I'm hosting in the homelab that is enhanced by using email in some way: Calibre can send books over email via the Send To Kindle feature, Authelia can send password reset links, qBittorrent can send notifications on download completions, etc. So far, I've just been using Gmail's third-party app functionality to let everything send emails with my Gmail account's SMTP creds. This is suboptimal for two reasons:

  1. I've probably said this a million times so far, but I'm wary of over-relying on Google for too much of my digital life. This is especially true for things like free access to APIs for third-party applications, which Reddit's recent changes have made me wary of.
  2. I would like to have specialized email addresses under my domain for the various functions of the homelab - librarian@janissary.xyz for Calibre stuff, auth@janissary.xyz for Authelia/LDAP, as well as addresses for myself (noah@janissary.xyz) and anyone else who uses the lab. This is for aesthetics, but also makes labeling and filtering automated mails easier.

I really, really wanted to self-host email as part of the homelab, for both educational and ideological reasons. Concerning the educational benefit of email, it's a pretty important group of protocols. It's the fundamental communication mechanism of the Age of Internet, and I think most people (especially a software person like myself) would benefit from learning its inner workings to some degree. That being said, the ideology of self-hosting email is much more important. There's a simple beauty - and freedom - in being able to communicate reliably with anyone, anywhere, anytime, with common hardware and an Internet connection. This whole "Internet" thing was kind of founded on the idea of federation and decentralization, anyway!

Unfortunately, I sold out. After hearing all the horror stories from people who self-host their email, I figured that I might as well save myself some pain and pay someone that's already in the good graces of Gmail/Outlook/iCloud. While doing some research on vendors, it turns out MXRoute was doing a sale at the time and had pretty positive reviews. I forked over $15 for two years' worth of service. Not a bad deal at all!

I will admit, it does kind of look like the people who run MXRoute have just slapped their label on some open-source web administration GUIs and called it a day. Regardless, getting all of my services to use it for email was as simple as updating the SMTP creds in any config files that referenced them. I wasn't in the mood to update all of my other (non-self-hosted) user accounts to use my new @janissary.xyz email, so I just configured that address to forward to the Proton Mail address that I've used for years. I tested sending to/from various @janissary.xyz addresses, and everything worked like a charm.

...but at what cost?

Minecraft

This was another pretty small addition to the lab. My girlfriend, God bless her heart, heard me excitedly talking about the new Raspberry Pi (the Model 5) that was coming out soon. As an early Christmas present, she went on Amazon and mistakenly purchased the Model 4. I think she might have just been excited that she was able to find it in stock after I told her how hard it'll be to find any, and she bought it before reading the fine print.

I couldn't bear to return it considering how excited she was for me, so I figured I could still put it to use and make a dedicated Minecraft server in the lab. I also took it as a chance to install NixOS on one of the lab machines for the first time. My desktop and all my laptops run NixOS (or nix-darwin, in the case of my MacBook) and a few of the Pis have the Nix package manager installed, but all of the Pis just run Raspbian as their base OS.

Since I didn't have a Micro HDMI cable handy to install the Pi's OS manually, I tried getting a little creative to perform the installation hands-free. This was new to me, since I've always been lazy and just gone through the graphical/CLI installation on every OS I've After all the times in high school I nuked my Arch Linux install and had to re-install, I could probably try for the Arch Linux Installation any% world record. .

I first tried using the nix-generators tool to build an Aarch64 image. I knew about tools like morph and nixops, but this seemed like the smaller and more appropriate tool for the job. I wrote up a pretty barebones configuration.nix, ran nix-generator -f iso -c configuration.nix, and waited a good long while to get this error:

modprobe: FATAL: Module sun4i-drm not found in directory /nix/store/yzy66g628lq9v047mkb8sk2nfgy6p674-linux-6.1.21-1.20230405-modules/lib/modules/6.1.21
error: builder for '/nix/store/v2wx88729cskpkn65cp1s92rqwdz37zf-linux-6.1.21-1.20230405-modules-shrunk.drv' failed with exit code 1;
       last 10 log lines:
       >   copying dependency: /nix/store/yzy66g628lq9v047mkb8sk2nfgy6p674-linux-6.1.21-1.20230405-modules/lib/modules/6.1.21/kernel/drivers/message/fusion/mptscsih.ko.xz
       >   copying dependency: /nix/store/yzy66g628lq9v047mkb8sk2nfgy6p674-linux-6.1.21-1.20230405-modules/lib/modules/6.1.21/kernel/drivers/message/fusion/mptspi.ko.xz
       > root module: vmxnet3
       >   copying dependency: /nix/store/yzy66g628lq9v047mkb8sk2nfgy6p674-linux-6.1.21-1.20230405-modules/lib/modules/6.1.21/kernel/drivers/net/vmxnet3/vmxnet3.ko.xz
       > root module: vsock
       >   copying dependency: /nix/store/yzy66g628lq9v047mkb8sk2nfgy6p674-linux-6.1.21-1.20230405-modules/lib/modules/6.1.21/kernel/net/vmw_vsock/vsock.ko.xz
       > root module: simplefb
       >   builtin dependency: simplefb
       > root module: sun4i-drm
       > modprobe: FATAL: Module sun4i-drm not found in directory /nix/store/yzy66g628lq9v047mkb8sk2nfgy6p674-linux-6.1.21-1.20230405-modules/lib/modules/6.1.21
       For full logs, run 'nix log /nix/store/v2wx88729cskpkn65cp1s92rqwdz37zf-linux-6.1.21-1.20230405-modules-shrunk.drv'.
error: 1 dependencies of derivation '/nix/store/qa1411b7cf1sza6hxz88svvh4jygc253-stage-1-init.sh.drv' failed to build
error: 1 dependencies of derivation '/nix/store/76crwagxbyzj3ipbk6liwq49yk3qg57q-initrd-linux-6.1.21-1.20230405.drv' failed to build
error: 1 dependencies of derivation '/nix/store/bkwly8q1w4f51kn2h3lq88pjy4hl50hc-nixos-system-heracles-23.11.20231011.01441e1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/4cpjqy9ml43pvidqx6p7r4wx6kyh8vbi-ext4-fs.img.zst.drv' failed to build
error: 1 dependencies of derivation '/nix/store/gcz799a2k5jysl66snvp53r0mad76bsw-nixos-sd-image-23.11.20231011.01441e1-aarch64-linux.img.drv' failed to build

I tried poking around a little to see what was wrong, but it seemed like some inscrutable kernel module was making things angry. A kernel wizard I am not (yet, a kernel commit is still on my bucket list), so I bit the bullet and ordered a cheapo Micro HDMI cable from Amazon and went back to the tried and true method of manually installing the OS.

I tried to appease the computer gods by at least copying the official NixOS ISO image onto the micro SD card with dd like a good Linux user, but my hubris must have angered them futher since the Pi refused to boot the image. Humbled, I downloaded the official Raspberry Pi Imager and copied over the NixOS ISO via the GUI. That finally did the trick, and I got NixOS installed.

Thankfully, it was an absolute snap to set up the Minecraft server once NixOS was installed. All I had to do were the following additions to configuration.nix:

...

  environment.systemPackages = with pkgs; [
    neovim
    wget
    papermc # apparently this flavor of minecraft server is better than default?
  ];

...

  # I'm lazy and don't want to hunt down the port that the server needs, I just
  # disabled the firewall altogether
  networking.firewall.enable = false;

  # this systemd service allows the server to start/stop with boot/shutdown 
  systemd.services.minecraft = {
    enable = true;
    description = "The Minecraft server!";
    after = [ "network.target" ];
    serviceConfig = {
      ExecStart = "${pkgs.papermc}/bin/minecraft-server";
      ExecStop = "pkill minecraft-server";
      WorkingDirectory="/opt/minecraft";
    };
    wantedBy = [ "multi-user.target" ];
  };

...and that's all it took! I'm currently in the process of standardizing and Flake-ifying all of my NixOS machines within my dotfiles, but I haven't gotten around to adding the new Pi (dubbed heracles) to it yet.

Conclusions

This was a pretty small update, but I'm planning on doing quite a bit of work in the next few weeks.

Like I mentioned earlier, I'd like to get Home Assistant set up so I can control the smart lights and smart thermostat that I recently set up around my place. It's pretty annoying to go through a few different apps to control all that stuff, and I have some ideas for automations that Home Assistant could tie together.

I also still need to Nixify the remaining Raspberry Pis and consolidate all of the configurations within my dotfiles. My desktop, MacBook, and ThinkPad have been migrated to a unified Flake setup, but I have yet to even install NixOS on the remaining 3/4 Pis in the lab. I imagine that'll lead to some bumpy downtime, so I'm kind of putting that off.

Finally, I think it's time I jumped the shark and tried self-hosting Kubernetes. Even though I'm only up to four physical machines in my homelab, I'm already experiencing some headaches caused by configuration drift between them. It would be really sweet to have a Magic Compute Cluster that I can just throw YAML at until it spits out self-hosted services. I'm a little intimidated, since I've really only used managed K8s instances and hosting it on bare metal can be a whole other beast from what I've heard. I also totally acknowledge that I might be setting myself up for heartbreak here. In the past year or so I've become somewhat pro-monolithic backends, pro-on-prem infra, anti-cloud, anti-overengineering, etc. Kubernetes in a homelab might be anathema to that cluster of values, but I'm willing to give it a try.

Anyway, that's all I have for now. See you next time!