-
Notifications
You must be signed in to change notification settings - Fork 196
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
allow to prepare the VMWare image #1
base: main
Are you sure you want to change the base?
Conversation
Well god damn this is cool. I'll have to give this a shot. |
I tried this - does this require nixos to build? I tried standard nix on my mac and it didn't work, but this would be a much easier way. |
There is a bit of a bootstrap problem because you need a Linux machine with Nix installed to generate the image. One way to work around the issue is to use GitHub Actions to build and push the VM. Or you can install Nix on your macOS, and set up a Nix remote builder like https://nixbuild.net . |
This is more of a showcase of a feature which I really like with NixOS. If the CI or another machine has Nix installed, it's possible to generate a new VMDK directly from the NixOS configuration. Building and copying the VMDK would replace almost all the bootstrap steps from the video. A similar technique is also possible to generate AMIs and other system images from the same config. I wasn't able to test this unfortunately because I don't have VMWare installed. You might have to set a password to the user using the NixOS config as well in order to be able to login.
a156078
to
fda87bf
Compare
@zimbatm do you have any example of how the GH action would look like?This could really create |
First, we need to add a GHA to the repo. So I created #14 Then append the following steps to the action (make sure to fix the indent so it's the same as the other steps): - run: nix build .#vmwareImage
- uses: actions/upload-artifact@v2
with:
name: vmware
path: ./result/*.vmdk |
Note that this approach is also applicable to building VirtualBox, Qemu, Vagrant, AMIs, ... by including the right NixOS module. It takes a bit of fiddling and reading the code still, but here is a good inspiration source: https://github.com/nix-community/nixos-generators/ |
These configurations were copied[1] and heavily modified. The general modification strategy was to remove as much as I could without breaking things. Later, I'll add customizations back go the nixos configurations. The VMware build comes from comments[2]. This commit tests if the vmware build works. I am editing from a Mac, so I am relying on Github actions to test the nixos and vmware artifact build. References: 1. https://github.com/mitchellh/nixos-config/tree/01fcaea3bdcd47540da39446d80e85d042a70cc1 2. mitchellh/nixos-config#1
I was able to build a qcow2 image with minimal nix config using
where the nixos config for the build and for the guest OS are defined here |
This is more of a showcase of a feature which I really like with NixOS.
If the CI or another machine has Nix installed, it's possible to
generate a new VMDK directly from the NixOS configuration. Building and
copying the VMDK would replace almost all the bootstrap steps from the
video. A similar technique is also possible to generate AMIs and other
system images from the same config.
I wasn't able to test this unfortunately because I don't have VMWare
installed. You might have to set a password to the user using the NixOS
config as well in order to be able to login.