Creating a blog with Clojure in 50 simple steps
- Install NixOS on your laptop because it’s super cool but also because you hate yourself just a little.
- Come up with the idea of writing something every day this summer and publishing it on “your blog”.
- Try and remember if you have a blog somewhere.
- Try and remember what your password to that blog might have been. Or did you use your Google account to sign up?
- Get lucky when you sign in with Google and you’re dropped into your profile where you have a single blog entry from several years ago and of course a few drafts because why not?
- Start a new blog entry.
- Try to figure out what in the world you’re going to write about.
- Go on a walk with your dog and talk to your friend Ray on the phone (well, Signal audio call, because who uses their phone for actual phoning?) about your nascent blogging career.
- Mention that you’re planning to do your blogging on your own site, using some static site generator or other. Wisely realise that this will be way more work that you think. Predict serious rabbit-holing to your friend.
- Remember that the inimitable borkdude wrote a blog
entry about how he’s generating his blog as a static site with Babashka.
- Clone borkdude’s blog from Github because of course the blog itself is open source because borkdude is awesome!
pkgs.babashka to your
home.nix and run
sudo nixos-rebuild switch to install it.
bb render and get excited as Babashka downloads the clj-kondo pod.
- Cry tears of sadness as Babashka errors out with:
java.util.zip.ZipException: invalid entry CRC (expected 0x7463ff01 but got
- Realise that you’re about a million versions behind the most current Babashka.
babashka.nix on the main branch of nixpkgs to see what the latest available version is.
- Get excited when you see that someone has just upgraded to the latest version of Babashka last week.
- Update your home.nix to pull Babashka (and just Babashka) from nixpkgs atthe commit where it was updated because you can do that in Nix and you knew thatNix rules previously so that’s why you’re running NixOS like a boss! (Also,because you hate yourself just a little.)
bb render again, triumphant in the knowledge that it’s going to work now that it’s on the latest version, because the latest version of any given piece of software has fixed all of the bugs.
- Get a permission denied error when Babashka tries to execute clj-kondo.
ls -l ~/.babashka/pods/repository/borkdude/clj-kondo/2021.10.19/clj-kondo
- See that in fact the execute bit is not set.
- Surmise that this is because the clj-kondo pod failed to install due to the
rm -rf ~/.babashka/pods/repository/ && bb render
- Get the same bloody ZipException.
- Try to remember your password to Clojurians
- Install the desktop Slack client by adding pkgs.slack to your home.nix.
- Revel in the glory of Nix.
- Get a magic signin link from the Slack client to your email.
- See that your friend Ray DM’d you back in 2019 to ask if you were going to ClojuTre and you totally ghosted him because you apparently hadn’t logged into Clojurians Slack since the spring of 2018.
- See if there’s a #babashka channel on Clojurians Slack and breathe a sigh of relief when of course there is!
- Post about your problem in #babashka.
- Wait 42 seconds for borkdude himself (creator of Babashka and about azillion other awesome open source thingies, mostly Clojure-related) to answeryour question.
- Provide borkdude with the version of zlib you’re using to validate his theory.
- Watch as borkdude pings in some badass Nix expert to help and wait 42 more seconds before said badass arrives.
- Provide the badass with a 14 line
bb.nix that reproduces the problem on any Nix installation because that’s how Nix works.
- Whilst the badass works on a proper fix (applying the Arch Linux patch where they fixed the zlib issue to the zlib derivation that the graalvm derivation depends on, obviously), attempt to create a Nix overlay that pins zlib to 1.2.11, the last version that works with GraalVM.
- Ask yourself WTF is happening when you keep getting infinite recursion when evaluating your new Babashka derivation that uses the overlay that pins zlib.
- Find out that apparently you can’t override zlib in an
pkgs.stdlib for Linux includes zlib.
- Despair when borkdude points you to a Nix flake that you could probably hack up to work around the problem because you haven’t had the time to wrap your head around Nix flakes.
- Walk your dog and talk to Ray on Signal and describe the rabbit hole and laugh when he says that your words from the previous chat were prophetic when you said that building your blog in Clojure would result in a rabbit hole.
- Be proud of yourself for writing your daily blog entry before messing around with this stuff.
- Make some oatmeal for yourself and your son.
- Start to head back to your desk to keep hacking but then realise that the sun is shining so go outside and play football with your son instead.
- [Optional step] Go out to supper with some good friends from the union and drink your troubles away.
- Watch some Star Trek: The Next Generation even though your friend Sen hates on it all the time because she thinks TOS is better even though she’s wrong and is super mean about it when you try to convince her she’s wrong but that’s OK because she just got a dope NCC-1701 tattoo so all is forgiven and she’s actually the best anyway because she’s chair of the local union and a total badass.
- Fall asleep on the couch for half an hour but then do the responsible thing and brush your teeth and take the dog out for a wee before getting in bed.
- Sleep pretty damned well even though your rib is aching like wild because you broke it 7 years ago and then broke it again 6 years ago (and when you say you broke it, what you actually mean is that some wanker broke it for you during football training, and then a really nice guy from work who was going in fairly for a 50–50 challenge caught you in the same rib with his shoulder a year later and broke it for you again) and then some 20-something wanker from Brommapojkarna (they really need to change their name, the sexist bastards) performed a full-on hockey-style body check on you during a 7-a-side football match last week and hit the damned rib but luckily it didn’t break this time but just bruised pretty badly.
- Wake up and see that the Nix badass has opened a PR to nixpkgs that fixes your issue.
- Responsibly write a blog entry on how to write a blog in Clojure in 50 easy steps before you try out the fix from the badass’s branch.
See, toldya it was easy!
PS: I did write a blog entry and publish it yesterday, but it was a guest piece for my friend Tim’s blog: “Story of a mediocre
fan”. I guess next time I do that, I should at least link it here so I have a record of having written something for posterity.
Discuss this post here.