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
cdituri/feature/hyperv packer builder #58
cdituri/feature/hyperv packer builder #58
Conversation
builder( | ||
type: 'hyperv-iso', | ||
generation: 1, | ||
# generation: 2, # gen 2 fails uefi boot, missing configuration in builders/hyperv-iso.nix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Packer builds just fine with generation 2
set but the resultant vagrant .box
fails at UEFI boot.
Guessing something I missed re: the bootloader and UEFI in scripts/builders/hyperv-iso.nix
... was hoping a maintainer or someone from the community may have a better idea here. Gen v1 works no problem however.
gen_template.rb
Outdated
"mkdir -m 0700 .ssh<enter>", | ||
"curl $(cat .packer_http)/install_rsa.pub > .ssh/authorized_keys<enter>", | ||
"sudo nix-env -f '<nixpkgs>' -iA linuxPackages.hyperv-daemons<enter><wait10>", | ||
"sudo $(find /nix/store -executable -iname 'hv_kvp_daemon' | head -n 1)<enter><wait10>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if there's a better way to determine the path to hv_kvp_daemon
; this daemon needs to be running during live-cd installation in order to pass the dynamically assigned guest-ip back to the hyperv host (in order for packer to continue it's setup over ssh).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth note: went this direction, over nixos-rebuild switch
and setting virtualisation.hypervGuest.enable
in configuration.nix
, because the execution time is greatly reduced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get the store path with nix-build --expr "(import <nixpkgs> {}).linuxPackages.hyperv-daemons"
for example. But I think it's fine like that. The chances that there are two versions of the same binary is probably fairly low.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The different methods resolve to different paths in the nixstore, seems to have to do with hyperv-daemons
vs hyperv-daemons-bin
.
Not exactly sure how to properly access the latter however, nix-build --expr "(import <nixpkgs> {}).linuxPackages.hyperv-daemons-bin"
does not work. So stuck with the original method using find
. Would love to know what the best way is here, but ultimately agree @zimbatm; chances that there are two versions of the same binary is low.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 on principle. This is going to be hard to maintain as it requires the user to have HyperV installed. But there isn't much we can do, this is the current packer design.
Thanks for the review @zimbatm, much appreciated 👍 crazy at work atm so aiming to circle back here sometime over the weekend to incorporate your feedback.
Totally understand, re: maintenance and packer design. I just want more NixOS! and as long as Windows is the preference at my employer, more than happy to help maintain this native Hyper-V builder 😃 |
Sounds good. Let me know when it's ready to be merged :) |
The web site put in a newline that breaks the assumption of the regex parse. This commit switches the scraper from regex parsing to XML parsing, which hopefully is more robust. Taken from the submission by @shajra-simspace in: - nix-community#59 - https://github.com/shajra-simspace
NixOS upstream now provides a 'latest' .iso image, so we track latest in iso_urls.json: - https://channels.nixos.org/nixos-20.03/latest-nixos-minimal-x86_64-linux.iso - https://channels.nixos.org/nixos-20.03/latest-nixos-minimal-i686-linux.iso
7b18305
to
e25f042
Compare
@zimbatm pull request is ready to merge at the moment. Some things worth nothing below first however:
@shajra-simspace hope you're ok with the above approach. Any thoughts, or would you like things attributed differently, etc? see the commit link.
Click to expand and show warnings generated
|
thanks! |
Overview
This pull request adds
hyperv-iso
builder support tonix-community/nixbox
:!!! Important: the last commit in the series brings
iso_urls.json
,nixos-i686.json
, andnixos-x86_64.json
to current. This is note-worthy because it looks like NixOS upstream is now using a 'latest'.iso
release, and we leverage that new approach here as well.Steps
Run packer build:
Import resultant vagrant
.box
image:vagrant box add --force --name hyperv/nixos-x86_64 .\nixos-19.09-hyperv-x86_64.box
Run vagrant:
Final note: many individuals on Windows have
git config --global core.autocrlf true
set, myself included. Havingautocrlf
set caused the following error during packer build, after a fresh clone:If you see this error, its because
scripts/{install, post-install}.sh
need to be LF; andgit
on Windows has presumably checked them out with CRLF line-endings on clone/checkout.