mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 19:21:04 +00:00
Generate a VirtualBox appliance (in OVF format) instead of a disk image
This commit is contained in:
parent
5c17d7d2a6
commit
687e0059d5
|
@ -16,6 +16,7 @@ with pkgs.lib;
|
|||
'';
|
||||
postVM =
|
||||
''
|
||||
echo "creating VirtualBox disk image..."
|
||||
${pkgs.vmTools.qemu}/bin/qemu-img convert -f raw -O vdi $diskImage $out/disk.vdi
|
||||
rm $diskImage
|
||||
'';
|
||||
|
@ -74,6 +75,31 @@ with pkgs.lib;
|
|||
''
|
||||
);
|
||||
|
||||
system.build.virtualBoxOVA = pkgs.runCommand "virtualbox-ova"
|
||||
{ buildInputs = [ pkgs.linuxPackages.virtualbox ];
|
||||
vmName = "NixOS ${config.system.nixosVersion} (${pkgs.stdenv.system})";
|
||||
fileName = "nixos-${config.system.nixosVersion}-${pkgs.stdenv.system}.ova";
|
||||
}
|
||||
''
|
||||
echo "creating VirtualBox VM..."
|
||||
export HOME=$PWD
|
||||
VBoxManage createvm --name "$vmName" --register \
|
||||
--ostype ${if pkgs.stdenv.system == "x86_64-linux" then "Linux26_64" else "Linux26"}
|
||||
VBoxManage modifyvm "$vmName" \
|
||||
--memory 1536 --acpi on --vram 10 \
|
||||
--nictype1 virtio --nic1 nat \
|
||||
--audiocontroller ac97 --audio alsa \
|
||||
--rtcuseutc on \
|
||||
--usb on --mouse usbtablet
|
||||
VBoxManage storagectl "$vmName" --name SATA --add sata --sataportcount 4 --bootable on --hostiocache on
|
||||
VBoxManage storageattach "$vmName" --storagectl SATA --port 0 --device 0 --type hdd \
|
||||
--medium ${config.system.build.virtualBoxImage}/disk.vdi
|
||||
|
||||
echo "exporting VirtualBox VM..."
|
||||
mkdir -p $out
|
||||
VBoxManage export "$vmName" --output "$out/$fileName"
|
||||
'';
|
||||
|
||||
fileSystems."/".device = "/dev/disk/by-label/nixos";
|
||||
|
||||
boot.loader.grub.version = 2;
|
||||
|
|
|
@ -42,7 +42,7 @@ in rec {
|
|||
|
||||
(all nixos.iso_minimal)
|
||||
(all nixos.iso_graphical)
|
||||
(all nixos.vdi)
|
||||
(all nixos.ova)
|
||||
|
||||
(all nixos.tests.firefox)
|
||||
(all nixos.tests.firewall)
|
||||
|
|
17
release.nix
17
release.nix
|
@ -174,8 +174,8 @@ in {
|
|||
});
|
||||
|
||||
|
||||
# A bootable VirtualBox image. FIXME: generate a OVF appliance?
|
||||
vdi = pkgs.lib.genAttrs systems (system:
|
||||
# A bootable VirtualBox virtual appliance as an OVA file (i.e. packaged OVF).
|
||||
ova = pkgs.lib.genAttrs systems (system:
|
||||
|
||||
with import <nixpkgs> { inherit system; };
|
||||
|
||||
|
@ -190,19 +190,18 @@ in {
|
|||
}).config;
|
||||
|
||||
in
|
||||
# Declare the VDI as a build product so that it shows up in Hydra.
|
||||
runCommand "nixos-vdi-${config.system.nixosVersion}-${system}"
|
||||
# Declare the OVA as a build product so that it shows up in Hydra.
|
||||
runCommand "nixos-ova-${config.system.nixosVersion}-${system}"
|
||||
{ meta = {
|
||||
description = "NixOS VirtualBox disk image (${system})";
|
||||
description = "NixOS VirtualBox appliance (${system})";
|
||||
maintainers = lib.maintainers.eelco;
|
||||
};
|
||||
vdi = config.system.build.virtualBoxImage;
|
||||
ova = config.system.build.virtualBoxOVA;
|
||||
}
|
||||
''
|
||||
mkdir -p $out/nix-support
|
||||
fn=$out/nixos-${config.system.nixosVersion}-${system}.vdi.xz
|
||||
xz < $vdi/*.vdi > $fn
|
||||
echo "file vdi $fn" >> $out/nix-support/hydra-build-products
|
||||
fn=$(echo $ova/*.ova)
|
||||
echo "file ova $fn" >> $out/nix-support/hydra-build-products
|
||||
'' # */
|
||||
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue