Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos-configuration-on-vm.md: Show how to run headless #768

Closed
wants to merge 1 commit into from

Conversation

nh2
Copy link
Contributor

@nh2 nh2 commented Oct 21, 2023

Fixes #767.

@nh2 nh2 requested a review from a team as a code owner October 21, 2023 14:37
@nh2 nh2 mentioned this pull request Oct 21, 2023
@github-actions
Copy link
Contributor

Deploy Preview

Name Result
Last commit: b0aea9ee6215dfd17f9b8d616d643f2c016d7c3b
Preview URL: https://8672287e.nix-dot-dev.pages.dev

Copy link
Collaborator

@fricklerhandwerk fricklerhandwerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. I like the general direction of the change, but think it needs some streamlining.

@@ -180,13 +180,19 @@ ls -R ./result
run-nixos-vm
```

Run the virtual machine:
To run the virtual machine in a new window (requires GUI environment):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To run the virtual machine in a new window (requires GUI environment):
Run the virtual machine in the current terminal:

Let's not show all the options here, that's what reference documentation is for. The purpose of this tutorial (as any tutorial here) is to serve as a first encounter, with pointers to all the details.

I prefer the terminal version as that is or at least appears more lightweight, and showing a the flag here should provide enough of a hint that omitting it may give you a GUI.

./result/bin/run-nixos-vm -nographic
```

You will see the boot process of the virtual machine and end at the `gdm` login screen where you can log in as `alice` with the password `testpw`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly recommend against describing perceptions, as not everyone can even have them. Describe what the machine does instead.

Suggested change
You will see the boot process of the virtual machine and end at the `gdm` login screen where you can log in as `alice` with the password `testpw`.
This will show the boot process of the virtual machine and end at the `gdm` login screen where you can log in as `alice` with the password `testpw`.

I currently can't check it myself: will that indeed be a terminal prompt? Isn't GDM a graphical tool?


```shell-session
./result/bin/run-nixos-vm
```

This command opens a window that shows the boot process of the virtual machine and ends at the `gdm` login screen where you can log in as `alice` with the password `testpw`.
To run it in the current terminal instead, pass `-nographic`:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, instead of presenting multiple options - which is distracting to first-time users because they'll be busy with following one set of instructions, and also doesn't scale well, since where do you draw the line? – we should link to the manual right afterward, such as:

Refer to the Nixpkgs manual for a [list of all commmand-line options to `run-nixos-vm`](<URL>).

(If that exists. Otherwise there's likely a --help flag?)

@github-actions
Copy link
Contributor

Deploy Preview

Name Result
Last commit: 8e3f2fbff771864ff39093c3064b054de5cfbc24
Preview URL: https://36ed7ce0.nix-dot-dev.pages.dev

@nh2
Copy link
Contributor Author

nh2 commented Oct 22, 2023

@fricklerhandwerk I've updated the PR.

Your comment was right that of course with the terminal, you can't see the configured GDM.

I think it's important to describe both the GUI and non-GUI options, because

  • the article as-is just fails with gtk initialization failed when invoking run-nixos-vm from a non-GUI NixOS environment, which is extremely confusing (and the reason why I opened this PR, as the instructions didn't work out-of-the-box)
  • the non-GUI option isn't perfect either, as you need a GUI to see the configured GDM, and there will likely be as many desktop users as headless users
    • further, the -nographic solution suffers from terminal corruption because QEMU serial consoles most of the time do not match the size of the terminal you launch them from; I've added a note about this now, so that users don't have the same "what is this rubbish, none of this works!"-feeling as I got initially.

@fricklerhandwerk
Copy link
Collaborator

fricklerhandwerk commented Oct 23, 2023

Your comment was right that of course with the terminal, you can't see the configured GDM.

How is this addressed in the PR then?

the article as-is just fails with gtk initialization failed when invoking run-nixos-vm from a non-GUI NixOS

Instead of overloading learners with options, we could add a graphical environment to the requirements at the beginning and more explicitly point to the manual for details.

the non-GUI option isn't perfect either

All these problems and the hassle required to work around them indicate that the additional information you collected should be put into the NixOS manual. For instance, that you can pass any QEMU flags, and how to handle terminal scrambling should definitely go into the manual.

I think all this is important to know, but not for the first encounter. Therefore, let's put it in the manual.

I opened #769 to make the change here as described and suggest closing this PR. Please ping me or @NixOS/documentation-team if you want to do the NixOS manual PR. Sorry for the detour, I needed the iteration to understand the full depth of the problem.

@fricklerhandwerk
Copy link
Collaborator

Feel free to reopen if there is something particular you still want to address here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Running NixOS VMs headlessly
2 participants