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!
- Add
pkgs.babashka
to your home.nix
and run sudo nixos-rebuild switch
to install it. - Run
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
0x6bbe279e)
- Realise that youâre about a million versions behind the most current Babashka.
- Check
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.)
- Run
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
ZipException
. rm -rf ~/.babashka/pods/repository/ && bb render
- Get the same bloody ZipException.
- Try to remember your password to Clojurians
Slack.
- 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
overlay because
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.