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

Add Hyperv support #36

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Add Hyperv support #36

wants to merge 7 commits into from

Conversation

PierreR
Copy link
Collaborator

@PierreR PierreR commented Dec 19, 2018

This is an attemps to fix #26.

It works on Windows 10 if you use a specific network external adapter.

Any comment, suggestion is welcomed.

I also took the liberty to add a hook so I can make heavier packer images. This need cames from the need to debug the vagrant box part of the generated hyperv box.

Copy link
Member

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

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

Nice!

I just have one comment, other than that it looks good to go.

@@ -25,6 +25,7 @@ nixos-generate-config --root /mnt
curl -f "$packer_http/vagrant.nix" > /mnt/etc/nixos/vagrant.nix
curl -f "$packer_http/vagrant-hostname.nix" > /mnt/etc/nixos/vagrant-hostname.nix
curl -f "$packer_http/vagrant-network.nix" > /mnt/etc/nixos/vagrant-network.nix
curl -f "$packer_http/custom-configuration.nix" > /mnt/etc/nixos/custom-configuration.nix
Copy link
Member

Choose a reason for hiding this comment

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

It would be good to only include the target guest config. I don't know how much hyperv support adds to the closure size?

Eg: curl -f "$packer_http/guest/$packet_target.nix" > /mnt/etc/nixos/guest.nix ($packet_target is probably wrong but you get the idea)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am surprised. I would believe virtualisation.hypervGuest.enable = false; would do nothing ? The idea was to remove this specific configuration out of configuration.nix

Copy link
Member

Choose a reason for hiding this comment

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

I didn't look at the code close enough. Now I see the sed commands.

I still think that it would be best to have one file per virtualization technology as the "sed" clauses will be quite fragile.

Copy link
Member

Choose a reason for hiding this comment

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

I introduced the mechanism in #37 to make it easier for you

@zimbatm
Copy link
Member

zimbatm commented Jan 3, 2019

@PierreR mind rebasing on top of master?

@PierreR
Copy link
Collaborator Author

PierreR commented Jan 3, 2019

Yep I will do that asap.

By the way I was also wondering how to keep in sync the iso_url value from https://github.com/nix-community/nixbox/blob/master/nixos-x86_64.json#L18 ?

It looks like you really need to create an network adapter (here named "Devbox")
This is handy to configure locale, hypervisor or any other organisation specific
configuration.
"echo http://{{.HTTPIP}}:{{.HTTPPort}} > .packer_http<enter>",
"mkdir -m 0700 .ssh<enter>",
"curl $(cat .packer_http)/install_rsa.pub > .ssh/authorized_keys<enter><wait>",
"nixos-rebuild switch<enter><wait>",
Copy link
Member

Choose a reason for hiding this comment

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

is this line necessary? It's not used for the other targets

Copy link
Collaborator Author

@PierreR PierreR Jan 5, 2019

Choose a reason for hiding this comment

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

Just remove that line and tested ... It is actually needed because nixos has to be rebuild with virtualisation.hypervGuest.enable = true; otherwise windows never gets the IP back from the guest and the ssh callback will never fire. That means that I need the sed call after all ...

In other words, I need to rebuild the nixos guest with hypervGuest enable to have a chance to get the provisioned install script to kick in. Can you think of another way to make this work ?

For your information, even when the hyperv packer images succeeded, I have never managed to get it work with vagrant. For some reason the X server will fail to start up ...

At the end, hyperv has been a gigantic piece of wasted time on my side :-(

Copy link
Member

Choose a reason for hiding this comment

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

Ouch, sorry to hear that. I think the best way would be to change the generation of images to be Nix-driven instead of Packer-driven. But that will take some more work.

Copy link
Member

Choose a reason for hiding this comment

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

The least effort would to cave in and install VirtualBox I'm afraid. I also think that Vagrant mainly works well with VirtualBox, all the other targets are less tested.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok no problem. I don't mind closing the PR and keeping the branch for documentation purpose.

As a note, what motivates me to investigate other hypervisors is the need for nested virtualization (not supported by Virtualbox on Intel).

"ram_size": 2048,
"enable_mac_spoofing": true,
"guest_additions_mode": "disable",
"enable_virtualization_extensions": false
Copy link
Member

Choose a reason for hiding this comment

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

The json code is generated by the gen_template.rb script. The new target would be declared here:

Copy link
Member

@zimbatm zimbatm Jan 4, 2019

Choose a reason for hiding this comment

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

To re-generate the json run nix-shell --run "make update"

@zimbatm
Copy link
Member

zimbatm commented Dec 27, 2022

@PierreR sorry I didn't react quickly enough on my end to get this merged. Do you want to do yet another rebase or let it be?

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

Successfully merging this pull request may close these issues.

Add support for hyperV
2 participants