feat: add vm-headless app to run the VM detached in the background#6
Merged
Conversation
`nix run .#vm` keeps its current foreground behavior (serial console attached to the terminal). The new `nix run .#vm-headless` starts the VM fully detached and prints the SSH port to connect to, then returns control to the shell. - lib/mk-vm-runner.nix: new `background` runner that launches QEMU with `-daemonize -display none -monitor none`, captures the serial console to /tmp/<vm>-console.log, writes a pidfile, and prints the SSH command - lib/mk-vm-apps.nix: expose the runner as the `vm-headless` app - README: document the foreground / background / GUI run modes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
vm-headlessflake app so the VM can be started detached in the background, printing the SSH port to connect to instead of attaching a console to your terminal.nix run .#vm— unchanged (foreground; serial console attached to your terminal).nix run .#vm-headless— new; daemonizes QEMU and prints the SSH command, then returns control to your shell.nix run .#vm-gui— unchanged (graphical window).How it works
lib/mk-vm-runner.nixgains abackgroundrunner that launches QEMU with-daemonize -display none -monitor none, captures the serial console to/tmp/<vm>-console.log, and writes a pidfile to/tmp/<vm>.pidfor easy stopping.lib/mk-vm-apps.nixexposes it as thevm-headlessapp./tmp/<vm>-ssh-port).Example output:
Notes
origin/mainso the diff is vm-headless only.Test plan
nix eval .#apps.x86_64-linuxlistsdefault,vm,vm-gui,vm-headless.bash -n.nix run .#vm-headlessboots a VM detached andssh dev@localhost -p <port>connects.nix run .#vmstill attaches to the terminal as before.🤖 Generated with Claude Code