From 1a2e4f37d0baa000f1a25bbb20036371ac0f0179 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 2 Jul 2013 00:23:48 +0200 Subject: [PATCH] release.nix: Generate a VirtualBox image --- modules/virtualisation/virtualbox-config.nix | 5 +++ modules/virtualisation/virtualbox-image.nix | 2 +- release.nix | 38 ++++++++++++++++++-- 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 modules/virtualisation/virtualbox-config.nix diff --git a/modules/virtualisation/virtualbox-config.nix b/modules/virtualisation/virtualbox-config.nix new file mode 100644 index 000000000000..72dea0bc2222 --- /dev/null +++ b/modules/virtualisation/virtualbox-config.nix @@ -0,0 +1,5 @@ +{ config, pkgs, modulesPath, ... }: + +{ + require = [ "${modulesPath}/virtualisation/virtualbox-image.nix" ]; +} diff --git a/modules/virtualisation/virtualbox-image.nix b/modules/virtualisation/virtualbox-image.nix index 5569e2a1fc91..32aa20806210 100644 --- a/modules/virtualisation/virtualbox-image.nix +++ b/modules/virtualisation/virtualbox-image.nix @@ -61,7 +61,7 @@ with pkgs.lib; # Install a configuration.nix. mkdir -p /mnt/etc/nixos - cp ${./nova-config.nix} /mnt/etc/nixos/configuration.nix + cp ${./virtualbox-config.nix} /mnt/etc/nixos/configuration.nix # `switch-to-configuration' requires a /bin/sh mkdir -p /mnt/bin diff --git a/release.nix b/release.nix index 1ae786e58fba..cda5d4e61527 100644 --- a/release.nix +++ b/release.nix @@ -43,7 +43,7 @@ let passthru = { inherit config; }; } '' - ensureDir $out/nix-support + mkdir -p $out/nix-support echo "file iso" $iso/iso/*.iso* >> $out/nix-support/hydra-build-products ''; # */ @@ -86,7 +86,7 @@ in { distPhase = '' echo -n $VERSION_SUFFIX > .version-suffix releaseName=nixos-$VERSION$VERSION_SUFFIX - ensureDir "$out/tarballs" + mkdir -p $out/tarballs mkdir ../$releaseName cp -prd . ../$releaseName cd .. @@ -112,7 +112,7 @@ in { distPhase = '' echo -n $VERSION_SUFFIX > .version-suffix releaseName=nixos-$VERSION$VERSION_SUFFIX - ensureDir "$out/tarballs" + mkdir -p $out/tarballs mkdir ../$releaseName cp -prd . ../$releaseName/nixos cp -prd ${nixpkgs} ../$releaseName/nixpkgs @@ -175,6 +175,38 @@ in { }); + # A bootable VirtualBox image. FIXME: generate a OVF appliance? + vdi.x86_64-linux = + with import { system = "x86_64-linux"; }; + + let + + config = (import lib/eval-config.nix { + inherit system; + modules = + [ ./modules/virtualisation/virtualbox-image.nix + ./modules/installer/cd-dvd/channel.nix + ./modules/profiles/graphical.nix + ]; + }).config; + + in + # Declare the VDI as a build product so that it shows up in Hydra. + runCommand "nixos-vdi-${config.system.nixosVersion}" + { meta = { + description = "NixOS VirtualBox disk image (64-bit)"; + maintainers = lib.maintainers.eelco; + }; + vdi = config.system.build.virtualBoxImage; + } + '' + mkdir -p $out/nix-support + fn=$out/nixos-${config.system.nixosVersion}.vdi.xz + xz < $vdi/*.vdi > $fn + echo "file vdi $fn" >> $out/nix-support/hydra-build-products + ''; # */ + + # Provide a tarball that can be unpacked into an SD card, and easily # boot that system from uboot (like for the sheevaplug). # The pc variant helps preparing the expression for the system tarball