I managed to solve my problems on my own but ended up having written this post in the process. So I thought I would leave it here for posterity. If this is a bad place to post it and I should just get myself a blog I’ll take it down.
The NixOS manual describes how one goes about interactively running the login test:
$ nix-build nixos/tests/login.nix -A driver $ ./result/bin/nixos-test-driver
And that works fine on my machine, both the
nix-build invocation and running
nixos-test-driver. Doing the same for
prometheus-exporters.nix does not work:
$ nix-build nixos/tests/prometheus-exporters.nix -A driver error: attribute 'driver' in selection path 'driver' not found
The nixos.wiki suggests running
nix repl followed by
$ nix repl nixos/tests/prometheus-exporters.nix > driver.outPath error: undefined variable 'driver' at (string):1:1
Again the driver attribute seems to be missing. But this got me thinking “Perhaps each test inside this file has a separate driver” and wouldn’t you know it, such was the case:
> slurm.driver.outPath "/nix/store/hbb6yvg05mvc9byd3khbaczgj4xpfhp1-nixos-test-driver-prometheus-slurm-exporter"
And in that folder I could find
bin/nixos-test-driver. Running it I could then run things like
print(slurm.succeed("ls -l /")) to inspect the contents of the VM.
I hope this can become useful for someone in the future.