Resurrecting My Old Website With Ancient NixOS Packages
You don't always have to update your code when dependencies push breaking changes
The past few weeks I have been putting off updating my personal website, which has sat untouched since October 2019. I've done quite a lot of interesting work since 2019, so finally this past weekend, I forced myself to sit down, clone the repository, and update it.
My personal website is nothing fancy; just a static website built with Hugo and a community theme, and hosted on S3. This should be simple, right?
Wrong.
After cloning the repository and trying to build the website, I'm told that I'm missing a theme.
For as long as I have used Hugo, the themes ecosystem has been dependent on using Git submodules. I'm not a huge fan of using them, but it's fine.
My website uses the "Dimension" theme adapted by GitHub user @sethmacleod, which is hosted at https://github.com/sethmacleod/dimension.
git according to my .gitmodules
file.
No big deal, I try to pull in the submodule. But wait, what's this? That repository doesn't exist anymore? That user has deleted their entire GitHub account? Ok…
Let's take a look in the Wayback Machine. Luckily there is an archived snapshot of the page on GitHub from 13 Jun 2018 and I can see that even by that point it had 63 forks.
Phew. I start trawling through GitHub trying to find a fork and before long I find one I'm happy with. I update the reference in my .gitmodules
file and try again. This time I'm met with a small victory.
Wait. What if this person deletes their fork or their account too? Better fork it myself. Always fork every community theme that you use.
Time to try building the website again. What's that? A whole bunch of Go functions were not found? GetParam
? What?
I am already feeling mentally exhausted by what should have been a trivial task of adding a few links to a Markdown file.
The last time I built this site with Hugo was in 2019, so maybe there have been some breaking changes in a major version release since then? What's that, Hugo is still at v0.x.x? Of course it is...
Luckily, I had spent the previous Thursday migrating my old Arch WSL2 VM to a fancy new NixOS WSL2 VM. Time to show me what you're made of, Nix!
My first stop was this excellent post by Marcelo Lazaroni on installing old versions of Nix packages, which culminated in his creation of Nix Package Versions, where you can put in the name of any package and see its version history.
Let’s see, the last time I successfully built my website was in October 2019, so v0.58.3 of Hugo which was released on the 19th of September in 2019 seems like it could be a good candidate. It is pretty easy to find on Nix Package Versions.
Now all that’s left is to make a shell.nix
for my website repository and make sure I install that specific version of Hugo.
Beautiful. Let’s enter the shell and try building again with this ancient version of Hugo… Success!
Finally I can update my website to include links to Notado, Kullish, komorebi, and of course all of the RSS feeds that I now curate.
My three main take-aways from this experience are:
Fork everything that you depend on for any public-facing website
If your static site generator decides to release breaking changes and you are an end-user (and not a theme developer) just pin the binary to the last known working version and forget about it
Every project I work on needs a
shell.nix