2
0
Fork 0

Copy VDI with vfs_import

This commit is contained in:
Emery Hemingway 2020-05-25 21:07:40 +05:30
parent 4817d73c4f
commit 3343ce8ab8
2 changed files with 23 additions and 26 deletions

View File

@ -26,14 +26,15 @@ let
'' + builtins.concatStringsSep "," (lib.mapAttrsToList (vmName: cfg:
let
inherit (cfg) config;
vdiFile = "${toVdi config}/nixos.vdi";
vdiRoot = toVdi config;
in lib'.runDhallCommand "vbox.dhall" { } ''
vdiUuid=$(${pkgs.virtualbox}/bin/VBoxManage showmediuminfo "${vdiFile}" | awk '/^UUID:/ {print $2}')
vdiUuid=$(${pkgs.virtualbox}/bin/VBoxManage showmediuminfo "${vdiRoot}/nixos.vdi" | awk '/^UUID:/ {print $2}')
dhall > $out << END
{ mapKey = "vbox-${vmName}"
, mapValue =
${./dhall/vbox-guest.dhall}
{ vdiFilename = "${vdiFile}"
{ vdiFilename = "nixos.vdi"
, vdiRoot = "${vdiRoot}"
, vdiUuid = "$vdiUuid"
, memorySize = ${toString config.virtualbox.memorySize}
, vmName = "${vmName}"
@ -80,6 +81,7 @@ let
"vbox5"
"vfs"
"vfs_audit"
"vfs_import"
"vfs_ttf"
] ++ lib.optional (cfg.fbDriver == "vesa") "vesa_drv"
++ lib.optional (cfg.fbDriver == "intel") "intel_fb_drv")
@ -96,6 +98,7 @@ let
"libstdcxx.so"
"libvfs.so"
"libvfs_audit.so"
"libvfs_import.so"
"libvfs_rump.so"
"libvfs_ttf.so"
];

View File

@ -26,6 +26,7 @@ let Vfs/inline =
let toVbox =
λ ( params
: { vdiFilename : Text
, vdiRoot : Text
, vdiUuid : Text
, memorySize : Natural
, vmName : Text
@ -91,9 +92,7 @@ let toVbox =
, binary = "virtualbox5"
, config = Init.Config::{
, attributes = toMap
{ vbox_file = "machine.vbox"
, vm_name = params.vmName
}
{ vbox_file = "machine.vbox", vm_name = params.vmName }
, content =
[ XML.leaf
{ name = "libc"
@ -120,36 +119,31 @@ let toVbox =
, attributes = toMap { name = "dev" }
, content = [ tag "log", tag "rtc" ]
}
, XML.element
{ name = "dir"
, attributes = toMap { name = "nix" }
, content =
[ XML.element
{ name = "dir"
, attributes = toMap { name = "store" }
, content =
[ XML.leaf
{ name = "fs"
, attributes = toMap
{ writeable = "no"
, label = "nix"
}
}
]
}
]
}
, XML.leaf
{ name = "fs"
, attributes = toMap { writeable = "yes" }
}
, XML.element
{ name = "import"
, attributes = toMap { overwrite = "no" }
, content =
[ XML.leaf
{ name = "fs"
, attributes = toMap
{ label = "nix"
, root = "${params.vdiRoot}"
}
}
]
}
]
}
]
}
, resources = Resources::{
, caps = 1024
, ram = Genode.units.MiB 128 + Genode.units.MiB params.memorySize
, ram =
Genode.units.MiB 128 + Genode.units.MiB params.memorySize
}
, routes =
[ ServiceRoute.parent "File_system"