sets: factor shared badaml machinery into _badaml.nix#2405
Conversation
Address the TODO in `badaml-sandbox.nix`: the BadAML test machinery (qemu-wrapped, kata kernel-uvm + image, node-installer-image payload) lives in `_badaml.nix`, taking `withAMLSandbox` so vuln and sandbox share one source of truth. `setsFromDirectory` skips underscore-prefixed files so the helper sits with its consumers without being loaded as a set. Signed-off-by: Spyros Seimenis <sse@edgeless.systems>
charludo
left a comment
There was a problem hiding this comment.
For this specific usecase, the strategy makes sense. However, I think it doesn't quite capture the other usecases we want to cover eventually - e.g. combine runtime-rs and debug. We could of course add a new set runtime-rs-debug which just imports the debug changes. But that gets tedious fast.
The idea I've been toying with would be to add a sepcial syntax for specifying multiple sets. For example, use + as a delimiter, so that you can run nix run .#any+combo+of+sets.package. The setsFromDirectory function would then simply(*) split by +, and for each part, add the set to the list.
In your concrete usecase, IMO badaml-vuln should contain everything in badaml now, and badaml-sandbox should simply overwrite the withAMLSandbox value to true. Sure then either badaml-sanbox imports badaml-vuln, or you specify .#badaml-vuln+badaml-sandbox.package.
But this way there'd not be two mechanisms for factoring out duplication, and IMO the "combine sets" approach is more flexible.
(*) caveat: to allow all combinations of sets that's 2^n for n sets, which is fine, nix builds them lazily anyways; for all permutations, n^n grows a little bit fast-ish. We could also just limit this to a depth of 3 or whatever.
This might be the only solution though. For instance another use case I have now with the oak set, I want to combine with debug, but in that case it doesn't make sense to do debug builds of OVMF for oak (and oak doesn't have debug builds). It just so happens for that particular one, that this derivation change simply doesn't affect it (it doesn't matter which derivation gets build for OVMF, the set will be using oak anyway). It's hard to capture all these/build truly generic sets that can be combined.
On first thought, this seems complex to me for the same reason I already stated but I am curious to see it in action so keep me posted if these explorations lead somewhere.
Or even better, the vuln one would simply be named I think in any case, maybe we should write down some concrete use cases we currently have or few potential ones to avoid overengineering this. Some I have in mind:
|
An idea for addressing the TODO in
badaml-sandbox.nix: the BadAML test machinery (qemu-wrapped, kata kernel-uvm + image, node-installer-image payload) lives in_badaml.nix, takingwithAMLSandboxso vuln and sandbox share one source of truth.setsFromDirectoryskips underscore-prefixed files so the helper sits with its consumers without being loaded as a set.For more ideas, this is an example combined set I was using to test the
badaml-vulnfailures with a debug firmware on top of thebadaml-vulnset changes: