Skip to content

Commit fda87bf

Browse files
committed
allow to prepare the VMWare image
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.
1 parent a50d042 commit fda87bf

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

flake.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,20 @@
4040
system = "x86_64-linux";
4141
user = "mitchellh";
4242
};
43+
44+
# Use this to prepare a new VMWare image.
45+
#
46+
# $ nix build .#vmwareImage -L
47+
# $ open ./result/*.vmdk
48+
#
49+
packages.aarch64-linux = {
50+
vmwareImage =
51+
self.nixosConfigurations.vm-aarch64.config.system.build.vmwareImage;
52+
};
53+
54+
packages.x86_64-linux = {
55+
vmwareImage =
56+
self.nixosConfigurations.vm-intel.config.system.build.vmwareImage;
57+
};
4358
};
4459
}

hardware/vm-intel.nix

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,14 @@
44
{ config, lib, pkgs, modulesPath, ... }:
55

66
{
7-
imports = [ ];
7+
imports = [ "${modulesPath}/virtualisation/vmware-image.nix" ];
88

99
boot.initrd.availableKernelModules = [
1010
"ata_piix" "mptspi" "uhci_hcd" "ehci_pci" "sd_mod" "sr_mod" ];
1111
boot.initrd.kernelModules = [ ];
1212
boot.kernelModules = [ ];
1313
boot.extraModulePackages = [ ];
1414

15-
fileSystems."/" =
16-
{ device = "/dev/disk/by-label/nixos";
17-
fsType = "ext4";
18-
};
19-
20-
fileSystems."/boot" =
21-
{ device = "/dev/disk/by-label/boot";
22-
fsType = "vfat";
23-
};
24-
2515
swapDevices = [ ];
2616

2717
}

0 commit comments

Comments
 (0)