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

module request: virtualisation -- ESXi image, guest support #94104

Open
evanjs opened this issue Jul 28, 2020 · 6 comments
Open

module request: virtualisation -- ESXi image, guest support #94104

evanjs opened this issue Jul 28, 2020 · 6 comments
Labels
0.kind: enhancement Add something new 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 9.needs: module (update) This needs a module to be changed

Comments

@evanjs
Copy link
Member

evanjs commented Jul 28, 2020

ESXi Virtualisation Support

There are currently plenty of virtualisation modules for both images and guests.
ESXi is not among those provided.

While VMWare images ought to work, from what I've found, ESXi is known to be notoriously picky when it comes to OVA/OVF imports.


I posted a bit more on the issue on Discourse.

My current workflow is a complicated mess that involves importing nixos-generators, generating a VirtualBox image, extracting the generated OVA, modifying the OVF definition, re-calculating the hashes in the mf file, and re-packaging the OVA.

While the edits that I am doing to the OVA could potentially be improved by applications like cot (see also: glennmatthews/cot#80), it would be nice to eventually see some of these changes make it upstream.


My current approach is so hacky that I'm not sure it would be a welcome addition in its current state.

I'm open to ideas, but I'm hoping to eventually be able to run e.g. nixos-generate -f esxi without all hacks I currently have to maintain.

@evanjs evanjs added the 0.kind: packaging request Request for a new package to be added label Jul 28, 2020
@veprbl veprbl added the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Jul 29, 2020
@stale
Copy link

stale bot commented Jan 25, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 25, 2021
@mschwaig
Copy link
Member

I am interested in this feature.

I recently had to generate an Image for ESXi image from a flake and went with specifying

  imports = [
    (modulesPath + "/virtualisation/vmware-image.nix") {
      vmware.baseImageSize = ...;
    }
  ];

in my system configuration and then generating it with

nix build .#nixosConfigurations.[system-name].config.system.build.vmwareImage

without using nixos-generators. (I did not get nixos-generators to work on my machine.)

Generating an OVA image would have been a better option for me, because that would have additionally included the hardware configuration, while I only got the disk image.

Right now I would have to import modulesPath + "/virtualisation/virtualbox-image.nix" to get system.build.virtualBoxOVA, but that image would then have

virtualisation.virtualbox.guest.enable = true;

and not

virtualisation.vmware.guest.enable = true;

and it would still require the changes you mentioned on top of that to be useful in ESXi, and I would imagine it would be useful to have more conformant images for VMware Workstation as well.

I think ideally system.build.virtualBoxOVA and system.build.vmwareOVA would both use the code inside virtualbox-image.nix to generate the image, but could be configured independently of each other. but I'm not sure.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 29, 2021
@mayl
Copy link
Contributor

mayl commented Jun 23, 2021

Just chiming in to also express interest in this feature!

@stale
Copy link

stale bot commented Jan 9, 2022

I marked this as stale due to inactivity. → More info

@KoviRobi
Copy link
Contributor

KoviRobi commented Jun 28, 2022

I've had success in modifying the virtualbox-image.nix by replacing SATA with SCSI -- I plan on making it more generic and opening a PR in a bit. For now I just copied the virtualbox-image.nix (and added it to my flake, the "${nixpkgs}/..." is like using <nixpkgs/...> in impure evaluation mode) and did these modifications:

--- /nix/pkgs/nixos/modules/virtualisation/virtualbox-image.nix	2022-02-16 10:39:53.091710499 +0000
+++ vmware-ova.nix	2022-06-28 17:30:02.213422098 +0100
@@ -1,3 +1,10 @@
+# This is a copy of
+# ${nixpkgs}/nixos/modules/virtualisation/virtualbox-image.nix
+# The important change from there is
+# - Using SCSI not SATA for the disk controller
+# - Putting in the VirtualBox compatibility field into the OVA
+
+{ nixpkgs, ... } @ flake-args:
 { config, lib, pkgs, ... }:

 with lib;
@@ -53,6 +61,14 @@
           The file name of the VirtualBox appliance.
         '';
       };
+      vmx = mkOption {
+        type = types.str;
+        default = "vmx-14";
+        example = "vmx-9";
+        description = ''
+          The VMware hardware version, see https://kb.vmware.com/s/article/1003746.
+        '';
+      };
       params = mkOption {
         type = with types; attrsOf (oneOf [ str int bool (listOf str) ]);
         example = {
@@ -130,7 +149,7 @@
       (mkIf (pkgs.stdenv.hostPlatform.system == "i686-linux") { pae = "on"; })
     ];

-    system.build.virtualBoxOVA = import ../../lib/make-disk-image.nix {
+    system.build.virtualBoxOVA = import "${nixpkgs}/nixos/lib/make-disk-image.nix" {
       name = cfg.vmDerivationName;

       inherit pkgs lib config;
@@ -167,11 +186,11 @@
           VBoxManage modifyvm "$vmName" \
             --memory ${toString cfg.memorySize} \
             ${lib.cli.toGNUCommandLineShell { } cfg.params}
-          VBoxManage storagectl "$vmName" --name SATA --add sata --portcount 4 --bootable on --hostiocache on
-          VBoxManage storageattach "$vmName" --storagectl SATA --port 0 --device 0 --type hdd \
+          VBoxManage storagectl "$vmName" --name SCSI --add scsi --portcount 16 --bootable on --hostiocache on
+          VBoxManage storageattach "$vmName" --storagectl SCSI --port 0 --device 0 --type hdd \
             --medium disk.vmdk
           ${optionalString (cfg.extraDisk != null) ''
-            VBoxManage storageattach "$vmName" --storagectl SATA --port 1 --device 0 --type hdd \
+            VBoxManage storageattach "$vmName" --storagectl SCSI --port 1 --device 0 --type hdd \
             --medium data-disk.vmdk
           ''}

@@ -179,6 +198,7 @@
           mkdir -p $out
           fn="$out/${cfg.vmFileName}"
           VBoxManage export "$vmName" --output "$fn" --options manifest ${escapeShellArgs cfg.exportParams}
+          ${pkgs.cot}/bin/cot edit-hardware $fn -v ${cfg.vmx}

           rm -v $diskImage

@@ -209,7 +229,7 @@
       size = 2048;
     }];

-    virtualisation.virtualbox.guest.enable = true;
+    virtualisation.vmware.guest.enable = true;

   };
 }

mayl added a commit to mayl/nixEsxiFormat that referenced this issue Jan 6, 2023
Working on an initial ESXi format module for nix, based on a github
comment:
NixOS/nixpkgs#94104 (comment)
@vifino
Copy link
Member

vifino commented Oct 4, 2023

Hey, I would love to have this as well.
It's currently a big chore to generate images.

@tomodachi94 tomodachi94 added 0.kind: enhancement Add something new 9.needs: module (update) This needs a module to be changed and removed 0.kind: packaging request Request for a new package to be added labels Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement Add something new 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 9.needs: module (update) This needs a module to be changed
Projects
None yet
Development

No branches or pull requests

7 participants