virtualbox-image: Make the image size configurable

This commit is contained in:
Rickard Nilsson 2014-08-04 11:29:51 +02:00
parent 7eb93f944b
commit ced7fc37c2

View File

@ -2,7 +2,26 @@
with lib;
{
let
cfg = config.virtualbox;
in {
options = {
virtualbox = {
baseImageSize = mkOption {
type = types.str;
default = 10G;
description = ''
The size of the VirtualBox base image. The size string should be on
a format the qemu-img command accepts.
'';
};
};
};
config = {
system.build.virtualBoxImage =
pkgs.vmTools.runInLinuxVM (
pkgs.runCommand "virtualbox-image"
@ -11,7 +30,7 @@ with lib;
''
mkdir $out
diskImage=$out/image
${pkgs.vmTools.qemu}/bin/qemu-img create -f raw $diskImage "10G"
${pkgs.vmTools.qemu}/bin/qemu-img create -f raw $diskImage "${cfg.baseImageSize}"
mv closure xchg/
'';
postVM =
@ -110,4 +129,5 @@ with lib;
boot.loader.grub.device = "/dev/sda";
services.virtualbox.enable = true;
};
}