diary at Telent Netowrks

Creta than the sum of its parts#

Sun, 24 Nov 2019 17:01:18 +0000

The Creta (GL-AR750) travel router now boots NixWRT. Although, I hasten to add, I have not checked whether (and don't really expect that) any of its network interfaces work yet.

As alluded to previously, the snapshot release of OpenWRT for this device uses the newer ath79 target, not the older ar71xx target - in their words "it's modernization under the hood, with the main goal to bring the code into a form that is acceptable for Linux upstream, so that all (most) of the whole ar71xx supported devices can be handled by an upstream, unpatched Linux kernel". Which is, obviously, a good thing, and one which I wanted to have in NixWRT instead of sticking with the rather elderly kernel that comes with the vendor firmware.

So, a summary list of changes required

I also lost a day or more because of an off-by-0 error. Which is to say, off-by-factor-of-16, where I'd added a zero to the end of the address I was loading the firmware into RAM and not added the same zero to the address where I told it to look for the firmware. Because this workflow depends on CONFIG_MTD_SPLIT_FIRMWARE which is now deprecated I made the unwarranted assumption that the problem was more complicated than it turned out to be

None of this is actually on Github right now, because of the strong likelihood (racing certainty) that it breaks the ramips target, but by tomorrow with a bit of luck it will probably at least be checked in on a branch.

Got the power#

Mon, 18 Nov 2019 23:26:36 +0000

This is little more than a placeholder, really, to note that I am 98% of the way to a working NixWRT test system again.

I rebuilt the computer-controlled USB power cable from last summer, because some time between then and now half the cables fell out and it wasn't immediately obvious where to put them back. This time I dun it on stripboard with soldered connections, but I connected it to a GPIO pin on the Raspberry Pi instead of using an Arduino. Because I need the Pi anyway and why needlessly multiply entities? That went pretty well except for the bit where I killed the transistor by failing to clip the legs until sometime after bending them to touch each other and applying power. Lesson learned.

The thing you see it plugged into is a second GL-AR750, because the first one is now serving my family's Internet needs (using OpenWRT, I am not in a dogfood situation here) and can't really be unplugged just so I can play with it (because that would be something closer to a doghouse situation). One piece of good news (maybe not actually new news, but I only noticed recently ) here is that the Linux kernel for said device has now been ported from the ar71 subarchitecture to ath79, which means it now uses device tree files instead of hardcoding where all the hardware bits and bobs inside it are.

Light touch regulation#

Wed, 02 Oct 2019 23:34:42 +0000

Or less obliquely, how to configure the Thinkpad X1 Carbon (gen 4, if it matters) touchpad in NixOS to not respond to the lightest brush of a finger as if it were a click. An end to accidentally favouriting random tweets while browsing Twitter on Firefox. Or at least, I hope, the elimination of a significant source of such.

First off, the instructions at https://people.freedesktop.org/~whot/libinput-rtd/touchpad-pressure.html#touchpad-pressure-hwdb are very nearly all true, and you should read them because I am not going to recapitulate them. I say "almost" because I found that where it says list-quirks I had to say quirks list instead. Following that process led me to create a file /etc/libinput/local-overrides.quirks that reads as follows:

[Section touchpad pressure]
MatchUdevType=touchpad
MatchName=*SynPS/2 Synaptics TouchPad
MatchDMIModalias=dmi:*svnLENOVO:*:pvrThinkPadX1Carbon4th*
AttrPressureRange=45:42

Second, it's more complicated than that. In NixOS 19.03, the libinput binary doesn't look at that file, it looks at /nix/store/9lwm03xqd8pkbxc3hgq9iiginddiyha3-libinput-1.12.6/etc/libinput/local-overrides.quirks, which is owned by the libinput derivation and can't be changed. (This is probably a bug. I will report it in the morning). Because I am trying to stick to channels and not maintain more forks of nixpkgs than I need to, I decided to patch it with an overlay. Therefore

[dan@noetbook:~]$ cat /etc/nixos/overlays/libinput.nix
self : super: {
  libinput = super.libinput.overrideAttrs (o: {
    mesonFlags = o.mesonFlags ++ [
      "--sysconfdir=/etc"
    ];
  });
}

and

[dan@noetbook:~]$ grep -B1 -A9 overlays /etc/nixos/configuration.nix 
{
  nixpkgs.overlays = [ (import /etc/nixos/overlays/libinput.nix) ];
  environment.etc."libinput/local-overrides.quirks" = {
    text = ''
[Section touchpad pressure]
MatchUdevType=touchpad
MatchName=*SynPS/2 Synaptics TouchPad
MatchDMIModalias=dmi:*svnLENOVO:*:pvrThinkPadX1Carbon4th*
AttrPressureRange=45:42
'';
  };

and nixos-rebuild switch, and after some swearing caused mostly by accidentally forgetting to exit all the nix-shells I had accidentally got myself into, about 30 minutes rebuilding later, it worked.

Note that adding overlays in configuration.nix does not make them available to nix-env or nix run, so you probably also want to add libinput to environment.systemPackages if you want to test your quirks are getting picked up. Then you can do this:

[dan@noetbook:~]$ strace -e openat libinput quirks list /dev/input/event7 2>&1 |grep etc 
openat(AT_FDCWD, "/etc/libinput/local-overrides.quirks", O_RDONLY) = 3

[dan@noetbook:~]$ libinput quirks list /dev/input/event7 ModelSynapticsSerialTouchpad=1 AttrPressureRange=45:42 AttrThumbPressureThreshold=100

A great improvement / A+++ would recommend. Wish I'd done it three years ago.

Nix wrought#

Tue, 03 Sep 2019 22:00:29 +0000

Time from unboxing new GL.iNet GL-MT300N-V2 to an ssh-able NixWRT installation: 30 minutes. Though admittedly this does not include the actual firmware build time itself as I did that bit yesterday when I ordered the box.

I lost the CPU for my backup server somewhere when we moved - I still have the disk, just not the bit that makes it go. Probably it's in a box I haven't unpacked yet, but anyway. Having generated much new "content" over the past few days - I've now scanned something over 500 pieces of paper into my paperless archive - it becomes somewhat more pressing to get the automated backup service running again.

  1. make the image
  2. find some scissors, open the box
  3. plug the device LAN port into my laptop and configure it to use a different RFC1918 address than the one it came with (which conflicts with the LAN here)
  4. upload the firmware.bin using the gl.inet web router admin page
  5. wait
  6. why is it not showing up on the LAN?
  7. wait
  8. ah yes, because it's still plugged into my laptop. Try plugging it into a LAN switch instead
  9. odds bodikins, I can ssh into it!

So, 30 minutes, would have been quicker if I weren't an idiot at step 6. To say I am mildly stoked this went so smoothly would be an understatement.

There are a couple of niggles: I need to rebuild the image because I forgot to update the name of the syslog host and I think I have probably also forgotten to put a real password on the rsync service. But both those are (or should be) simple fices.

Cracking over the papers#

Fri, 30 Aug 2019 11:19:35 +0000

One of the several billion things that needs sorting in our new house is a filing system for all the paper junk we get sent that we don't immediately need to deal with but probably shouldn't throw away: bills, PAYE coding notices, letters from the council, bank statements etc. After some thought and thanks to @antifuchs alerting me to the existence of the Paperless project I decided to go digital. Recommend.

Notes, in the order they occur to me

    services.paperless = {
      enable = true;
      extraConfig = {
        PAPERLESS_CORS_ALLOWED_HOSTS="http://localhost:8080";
      };
    };

sudo -u scanner scanimage --format png --batch=/var/spool/scans/$(date +%Y%m%d%H%M%S)Z_p%04d.png  --resolution 300 --source 'ADF Duplex'

where scanner is the username that paperless is running as and /var/spool/scans/ is where I arbitrarily decided the consumption directory should be. I scan to png not pdf because scanimage was silently failing to convert to pdf and instead leaving the files as pbm images. (1) pbm images are huge; (2) pbm images files with .pdf suffixes confuse the paperless web frontend and they confuse me too. I would like to automate this so it runs whenever I (or a family member) presses the "scan" button on the scanner itself, but haven't got that far yet. scanbd will probably do it but seems excessively featureful for my needs.

[dan@loaclhost:~]$ systemctl cat paperless-consumer.service| grep 'ExecStart='
ExecStart=/nix/store/2jaqzp6yhqwb2p0vs93whkwj0r0jf509-paperless document_consumer
[dan@loaclhost:~]$ sudo -u scanner /nix/store/2jaqzp6yhqwb2p0vs93whkwj0r0jf509-paperless document_correspondents