Combine OVA generation steps

Previously this was done in three derivations (one to build the raw
disk image, one to convert to OVA, one to add a hydra-build-products
file). Now it's done in one step to reduce the amount of copying
to/from S3. In particular, not uploading the raw disk image prevents
us from hitting hydra-queue-runner's size limit of 2 GiB.

+38 -54
+2 -1
nixos/lib/make-disk-image.nix
··· 22 22 , # Shell code executed after the VM has finished. 23 23 postVM ? "" 24 24 25 + , name ? "nixos-disk-image" 25 26 }: 26 27 27 28 with lib; 28 29 29 30 pkgs.vmTools.runInLinuxVM ( 30 - pkgs.runCommand "nixos-disk-image" 31 + pkgs.runCommand name 31 32 { preVM = 32 33 '' 33 34 mkdir $out
+29 -28
nixos/modules/virtualisation/virtualbox-image.nix
··· 22 22 23 23 config = { 24 24 25 - system.build.virtualBoxImage = import ../../lib/make-disk-image.nix { 25 + system.build.virtualBoxOVA = import ../../lib/make-disk-image.nix { 26 + name = "nixos-ova-${config.system.nixosLabel}-${pkgs.stdenv.system}"; 27 + 26 28 inherit pkgs lib config; 27 29 partitioned = true; 28 30 diskSize = cfg.baseImageSize; ··· 37 39 postVM = 38 40 '' 39 41 echo "creating VirtualBox disk image..." 40 - ${pkgs.vmTools.qemu}/bin/qemu-img convert -f raw -O vdi $diskImage $out/disk.vdi 42 + ${pkgs.vmTools.qemu}/bin/qemu-img convert -f raw -O vdi $diskImage disk.vdi 41 43 rm $diskImage 44 + 45 + echo "creating VirtualBox VM..." 46 + export HOME=$PWD 47 + export PATH=${pkgs.linuxPackages.virtualbox}/bin:$PATH 48 + vmName="NixOS ${config.system.nixosLabel} (${pkgs.stdenv.system})" 49 + VBoxManage createvm --name "$vmName" --register \ 50 + --ostype ${if pkgs.stdenv.system == "x86_64-linux" then "Linux26_64" else "Linux26"} 51 + VBoxManage modifyvm "$vmName" \ 52 + --memory 1536 --acpi on --vram 32 \ 53 + ${optionalString (pkgs.stdenv.system == "i686-linux") "--pae on"} \ 54 + --nictype1 virtio --nic1 nat \ 55 + --audiocontroller ac97 --audio alsa \ 56 + --rtcuseutc on \ 57 + --usb on --mouse usbtablet 58 + VBoxManage storagectl "$vmName" --name SATA --add sata --portcount 4 --bootable on --hostiocache on 59 + VBoxManage storageattach "$vmName" --storagectl SATA --port 0 --device 0 --type hdd \ 60 + --medium disk.vdi 61 + 62 + echo "exporting VirtualBox VM..." 63 + mkdir -p $out 64 + fn="$out/nixos-${config.system.nixosLabel}-${pkgs.stdenv.system}.ova" 65 + VBoxManage export "$vmName" --output "$fn" 66 + 67 + mkdir -p $out/nix-support 68 + echo "file ova $fn" >> $out/nix-support/hydra-build-products 42 69 ''; 43 70 }; 44 - 45 - system.build.virtualBoxOVA = pkgs.runCommand "virtualbox-ova" 46 - { buildInputs = [ pkgs.linuxPackages.virtualbox ]; 47 - vmName = "NixOS ${config.system.nixosLabel} (${pkgs.stdenv.system})"; 48 - fileName = "nixos-image-${config.system.nixosLabel}-${pkgs.stdenv.system}.ova"; 49 - } 50 - '' 51 - echo "creating VirtualBox VM..." 52 - export HOME=$PWD 53 - VBoxManage createvm --name "$vmName" --register \ 54 - --ostype ${if pkgs.stdenv.system == "x86_64-linux" then "Linux26_64" else "Linux26"} 55 - VBoxManage modifyvm "$vmName" \ 56 - --memory 1536 --acpi on --vram 32 \ 57 - ${optionalString (pkgs.stdenv.system == "i686-linux") "--pae on"} \ 58 - --nictype1 virtio --nic1 nat \ 59 - --audiocontroller ac97 --audio alsa \ 60 - --rtcuseutc on \ 61 - --usb on --mouse usbtablet 62 - VBoxManage storagectl "$vmName" --name SATA --add sata --portcount 4 --bootable on --hostiocache on 63 - VBoxManage storageattach "$vmName" --storagectl SATA --port 0 --device 0 --type hdd \ 64 - --medium ${config.system.build.virtualBoxImage}/disk.vdi 65 - 66 - echo "exporting VirtualBox VM..." 67 - mkdir -p $out 68 - VBoxManage export "$vmName" --output "$out/$fileName" 69 - ''; 70 71 71 72 fileSystems."/".device = "/dev/disk/by-label/nixos"; 72 73
+7 -25
nixos/release.nix
··· 150 150 151 151 with import nixpkgs { inherit system; }; 152 152 153 - let 154 - 155 - config = (import lib/eval-config.nix { 156 - inherit system; 157 - modules = 158 - [ versionModule 159 - ./modules/installer/virtualbox-demo.nix 160 - ]; 161 - }).config; 162 - 163 - in 164 - # Declare the OVA as a build product so that it shows up in Hydra. 165 - hydraJob (runCommand "nixos-ova-${config.system.nixosVersion}-${system}" 166 - { meta = { 167 - description = "NixOS VirtualBox appliance (${system})"; 168 - maintainers = maintainers.eelco; 169 - }; 170 - ova = config.system.build.virtualBoxOVA; 171 - preferLocalBuild = true; 172 - } 173 - '' 174 - mkdir -p $out/nix-support 175 - fn=$(echo $ova/*.ova) 176 - echo "file ova $fn" >> $out/nix-support/hydra-build-products 177 - '') # */ 153 + hydraJob ((import lib/eval-config.nix { 154 + inherit system; 155 + modules = 156 + [ versionModule 157 + ./modules/installer/virtualbox-demo.nix 158 + ]; 159 + }).config.system.build.virtualBoxOVA) 178 160 179 161 ); 180 162