Avoiding the stage-2 interactive shell in runInLinuxImage

I’m trying to understand how an invocation of runInLinuxImage such as vmTools.buildRPM actually kicks off the included build phases, when invoked with a diskImage previously constructed with runInLinuxVM.

  • runInLinuxVM hardcodes use of qemuCommandLinux, which references stage2Init.
  • Only one stage2Init definition appears to exist, and that definition is built to run only once (dropping to an interactive shell if the VM is re-invoked).

However, runInLinuxImage – as used by buildRPM – takes an arbitrary derivation, and runs it inside the guest… but how? That guest, when it runs, starts up with an init= parameter telling it to run a command that drops to an interactive shell (which I don’t see an obvious way to interact with from nix-build, though that’s a rather secondary concern), rather than invoking the builder in question.

Is there documentation available on how this is expected to work?

buildRPM overrides builder of the the runInLinuxVM functions, which is then executed within the VM on this line:

I don’t think there is documentation on those rather low-level implementation details.

1 Like

Ahh! What I missed was this critical line in fillDiskWithRPMs:

rm /mnt/.debug

Thank you for your time and patience. :slight_smile: