By: Tom Sydney Kerckhove <syd@cs-syd.eu>
Decide at evaluation time everything that is known then routeros-vmtest was a command that parsed a --chassis flag and a file argument out of bash, and vmtestFor existed only to hand it both. Since both are known when the derivation is built, there is now one function that takes them and no command that parses anything: vmtest.nix is gone and vmtestFor does the whole job. What that buys, beyond deleting the argument parsing and the jq dependency: - A chassis this image cannot stand in for is an evaluation error rather than a message somebody reads five minutes into a boot. - The interface list and the serial port count are constants in the script instead of jq reading the chassis back at runtime. - What the two RouterOS versions are, and whether they differ, is decided when the script is written. - The file the router fetches over tftp is a store directory, so the only thing the command still assembles is the disk image, which it has to, because the router writes to it. The selftest listed its examples with a shell glob; builtins.readDir knows them at evaluation time, so it builds one vm test per example and reads each .expected with lib.fileContents. The chassis parser in Haskell now takes all five fields rather than the two it uses. A stale chassis is then an error rather than something that parses and quietly means less than it says.