Packaging the Blog

I already had a shell.nix file, so I the dependency resolution part of the packaging process was already done for me. Neat!

However, the peculiar way nix builds things to get reproducible outputs introduced some interesting issues.

Hakyll, UTF-8, and locale

In order to handle utf-8 character encodings, hakyll site binaries require the user set a utf-8 compatible locale (e.g. en_US-UTF8.

I’m unfamiliar with how locale actually works in Linux. Normally I just set it once when I install and forget about it. Apparently there’s a series of Perl scripts that manage your language settings for time formats, keyboard layout, etc. Some part of the mechanism requires a locale store, which is provided as a part of glibc.

To get around this, we can add a dependency on glibc and point to the locale-archive before the site is built.

github_remote and github_token are values set in a let binding at the head of the page, and is loaded on evaluation from a file github_secret in the same folder.

End Notes

I’m pretty pleased with the end result, all things considered. Nix is proving to be pretty powerful, if a little difficult to pick up.

Future Work

Resolving problems with commit hashes

Right now, networked builds are deployed with response to a commit ID and hash on the master branch. This means that in order to update the commit referenced by the networked system, you have to make 2 commits. This could be fixed by storing the package descriptions in a separate repo, but I think this makes it kind of hard to track how to build your projects.

Continuous Integration with Hydra

Currently, builds still have to be triggered manually. It would be nice to use hydra to automatically build and upload the site. However, this brings up the question of how to keep the github token secret again.

Thanks

I probably would have given up on this pretty quickly if not for the help of the people who hang out in the #nixos freenode irc channel.

clever for helping me struggle with the nix language and nixpkgs stdlib

pxc, gchristensen, and Lethalman for advice on how to manage a personal package repo