diary at Telent Netowrks

I will try to fix you#

Thu, 21 Jun 2018 19:30:36 +0000

Last week I had hooked up the serial port on my upstairs wifi access point. This week I'm posting this blog entry through it. Which is a win, I think.

All is not finished yet, though, because the NixWRT install on it is too big for the teeny tiny 4MB flash chip and is running in RAM. Which means I can't put the case back on yet. So I've been working on ways to make the image smaller, which mostly has been about removing kernel options I don't need and busybox applets it doesn't use.

To do this, I have changed the module system to introduce - without, I admit, fully understanding - the fix-point pattern as used in package overlays. The deal here is that many packages may wish to change the compile-time options for busybox/the kernel, and simultaneously they also wish to use the resulting binary - and as packagers we want them all to use the same binary instead of making a new kernel/busybox for every package that needs a slightly different one. This is a mutually recursive dependency, but mercifully it's a mutually recursive dependency with a base case. What this means is that a module now takes self and super parameters where the super is a configuration attrset that it can modify and return, and the self is the "final" shape of that attrset that it can use for references to other packages and things that it needs but is not modifying. That's not an exact explanation of how to use this pattern, but it's basically the limit of my understanding of it.

Rearranging things in this way has led to a couple of nice features: for example, I can now add a module to introduce the kernel phram support that is only needed for TFTP boots (and thus have it excluded from the flashable image) or the 9p filesystem support that's only relevant to qemu builds. It also means my image size is now down to 1635k (kernel) plus 2600k (root), but squeezing out the final 300k or so that I'll need (I don't have an exact number but u-boot and ART partition will want space) is proving to be somewhat challenging. When this device was produced it was using a 3.x series kernel and I think 4.9 just unavoidably has a bit more heft in it.

Incidentally, backuphost.nix is assumed broken by this latest set of changes. Some day soon I will figure out a workable CI process for this project.

In other news, finally finished moving stuff off my old Debian shell host to a Nixos installation. Obligatory Bytemark plug goes here.