fixup nixos-modules
This commit is contained in:
parent
d200c1c2cd
commit
5d5ba14f82
|
@ -86,11 +86,13 @@
|
||||||
git
|
git
|
||||||
glibc.dev
|
glibc.dev
|
||||||
gnumake
|
gnumake
|
||||||
|
iasl
|
||||||
libxml2
|
libxml2
|
||||||
qemu
|
qemu
|
||||||
tcl
|
tcl
|
||||||
which
|
which
|
||||||
xorriso
|
xorriso
|
||||||
|
yasm
|
||||||
]);
|
]);
|
||||||
runScript = "bash";
|
runScript = "bash";
|
||||||
extraBuildCommands = let
|
extraBuildCommands = let
|
||||||
|
|
|
@ -25,10 +25,12 @@ let
|
||||||
f = binary: {
|
f = binary: {
|
||||||
name = binary;
|
name = binary;
|
||||||
value = let
|
value = let
|
||||||
f = if lib.hasPrefix "lib" binary && lib.hasSuffix ".so" binary then
|
f = drv:
|
||||||
drv: toPath "${drv.lib or drv}/lib/${binary}"
|
if lib.hasPrefix "lib" binary && lib.hasSuffix ".so" binary
|
||||||
else
|
&& pathExists "${drv.lib or drv}/lib" then
|
||||||
drv: toPath "${drv}/${binary}";
|
toPath "${drv.lib or drv}/lib/${binary}"
|
||||||
|
else
|
||||||
|
toPath "${drv}/${binary}";
|
||||||
in filter pathExists (map f imageInputs);
|
in filter pathExists (map f imageInputs);
|
||||||
};
|
};
|
||||||
in map f binaries;
|
in map f binaries;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{ self }:
|
{ self, depot }:
|
||||||
|
|
||||||
{
|
{
|
||||||
vbox = import ./vbox.nix { inherit self; };
|
vbox = import ./vbox.nix { inherit self depot; };
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,13 @@ let Vfs/inline =
|
||||||
→ λ(body : Text)
|
→ λ(body : Text)
|
||||||
→ XML.element
|
→ XML.element
|
||||||
{ name = "inline"
|
{ name = "inline"
|
||||||
, attributes = XML.emptyAttributes
|
, attributes = toMap { name = name }
|
||||||
, content = [ XML.text body ]
|
, content = [ XML.text body ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let routeLogRom =
|
||||||
|
λ(label : Text) → ServiceRoute.parentLabel "ROM" (Some "log") (Some label)
|
||||||
|
|
||||||
let rootInit =
|
let rootInit =
|
||||||
λ ( params
|
λ ( params
|
||||||
: { vdiFilename : Text
|
: { vdiFilename : Text
|
||||||
|
@ -39,12 +42,13 @@ let rootInit =
|
||||||
''
|
''
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<VirtualBox xmlns="http://www.virtualbox.org/" version="1.14-freebsd">
|
<VirtualBox xmlns="http://www.virtualbox.org/" version="1.14-freebsd">
|
||||||
<Machine uuid="{37ab43a5-38d8-4491-93f5-5b0b077f5c32}" name="${params.vmName}" OSType="Linux26_64" snapshotFolder="Snapshots" lastStateChange="2018-01-23T18:40:00Z">
|
<Machine uuid="{37ab43a5-38d8-4491-93f5-5b0b077f5c32}" name="ubuntu_16_04_64" OSType="Ubuntu_64" snapshotFolder="Snapshots" lastStateChange="2018-01-23T18:40:00Z">
|
||||||
<MediaRegistry>
|
<MediaRegistry>
|
||||||
<HardDisks>
|
<HardDisks>
|
||||||
<HardDisk uuid="{${params.vdiUuid}}" location="${params.vdiFilename}" format="VDI" type="Normal"/>
|
<HardDisk uuid="{${params.vdiUuid}}" location="${params.vdiFilename}" format="VDI" type="Normal"/>
|
||||||
</HardDisks>
|
</HardDisks>
|
||||||
<DVDImages/>
|
<DVDImages>
|
||||||
|
</DVDImages>
|
||||||
</MediaRegistry>
|
</MediaRegistry>
|
||||||
<Hardware>
|
<Hardware>
|
||||||
<CPU count="1">
|
<CPU count="1">
|
||||||
|
@ -60,8 +64,15 @@ let rootInit =
|
||||||
<BIOS>
|
<BIOS>
|
||||||
<IOAPIC enabled="true"/>
|
<IOAPIC enabled="true"/>
|
||||||
</BIOS>
|
</BIOS>
|
||||||
<USB/>
|
<USB>
|
||||||
<Network/>
|
<Controllers>
|
||||||
|
</Controllers>
|
||||||
|
</USB>
|
||||||
|
<Network>
|
||||||
|
<Adapter slot="0" enabled="true" MACAddress="0800271D7901" cable="true" type="82540EM">
|
||||||
|
<BridgedInterface/>
|
||||||
|
</Adapter>
|
||||||
|
</Network>
|
||||||
<UART>
|
<UART>
|
||||||
<Port slot="0" enabled="false" IOBase="0x3f8" IRQ="4" hostMode="Disconnected"/>
|
<Port slot="0" enabled="false" IOBase="0x3f8" IRQ="4" hostMode="Disconnected"/>
|
||||||
<Port slot="1" enabled="false" IOBase="0x2f8" IRQ="3" hostMode="Disconnected"/>
|
<Port slot="1" enabled="false" IOBase="0x2f8" IRQ="3" hostMode="Disconnected"/>
|
||||||
|
@ -72,7 +83,8 @@ let rootInit =
|
||||||
</LPT>
|
</LPT>
|
||||||
<AudioAdapter controller="HDA" driver="OSS" enabled="false"/>
|
<AudioAdapter controller="HDA" driver="OSS" enabled="false"/>
|
||||||
<RTC localOrUTC="UTC"/>
|
<RTC localOrUTC="UTC"/>
|
||||||
<SharedFolders/>
|
<SharedFolders>
|
||||||
|
</SharedFolders>
|
||||||
</Hardware>
|
</Hardware>
|
||||||
<StorageControllers>
|
<StorageControllers>
|
||||||
<StorageController name="SATA" type="AHCI" PortCount="4" useHostIOCache="true" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3">
|
<StorageController name="SATA" type="AHCI" PortCount="4" useHostIOCache="true" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3">
|
||||||
|
@ -163,13 +175,13 @@ let rootInit =
|
||||||
<pci bus="0" device="0" function="0"/>
|
<pci bus="0" device="0" function="0"/>
|
||||||
<pci class="ISABRIDGE"/>
|
<pci class="ISABRIDGE"/>
|
||||||
</policy>
|
</policy>
|
||||||
<policy label_suffix="-> wifi">
|
<policy label_suffix="wifi_drv">
|
||||||
<pci class="WIFI"/>
|
<pci class="WIFI"/>
|
||||||
</policy>
|
</policy>
|
||||||
<policy label_suffix="-> nic">
|
<policy label_suffix="nic_drv">
|
||||||
<pci class="ETHERNET"/>
|
<pci class="ETHERNET"/>
|
||||||
</policy>
|
</policy>
|
||||||
<policy label_suffix="-> audio">
|
<policy label_suffix="audio">
|
||||||
<pci class="AUDIO"/>
|
<pci class="AUDIO"/>
|
||||||
<pci class="HDAUDIO"/>
|
<pci class="HDAUDIO"/>
|
||||||
</policy>
|
</policy>
|
||||||
|
@ -313,9 +325,11 @@ let rootInit =
|
||||||
[ XML.text
|
[ XML.text
|
||||||
''
|
''
|
||||||
<domain name="pointer" layer="1" content="client" label="no" origin="pointer" />
|
<domain name="pointer" layer="1" content="client" label="no" origin="pointer" />
|
||||||
<domain name="default" layer="2" content="client" label="yes" hover="always" focus="click"/>
|
<domain name="log" layer="2" content="client" label="yes" hover="always"/>
|
||||||
|
<domain name="vbox" layer="3" content="client" label="yes" hover="always" focus="click"/>
|
||||||
<policy label_prefix="pointer" domain="pointer"/>
|
<policy label_prefix="pointer" domain="pointer"/>
|
||||||
<default-policy domain="default"/>
|
<policy label_prefix="log" domain="log"/>
|
||||||
|
<policy label_prefix="vbox" domain="vbox"/>
|
||||||
''
|
''
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -329,8 +343,88 @@ let rootInit =
|
||||||
Child.flat
|
Child.flat
|
||||||
Child.Attributes::{
|
Child.Attributes::{
|
||||||
, binary = "pointer"
|
, binary = "pointer"
|
||||||
|
, provides = [ "Report" ]
|
||||||
, routes = [ ServiceRoute.child "Nitpicker" "nitpicker" ]
|
, routes = [ ServiceRoute.child "Nitpicker" "nitpicker" ]
|
||||||
}
|
}
|
||||||
|
, nit_fb =
|
||||||
|
Child.flat
|
||||||
|
Child.Attributes::{
|
||||||
|
, binary = "nit_fb"
|
||||||
|
, config = Init.Config::{
|
||||||
|
, attributes = toMap { xpos = "200", width = "600", height = "600" }
|
||||||
|
}
|
||||||
|
, provides = [ "Framebuffer", "Input" ]
|
||||||
|
, resources = Resources::{ ram = Genode.units.MiB 8 }
|
||||||
|
, routes =
|
||||||
|
[ ServiceRoute.childLabel
|
||||||
|
"Nitpicker"
|
||||||
|
"nitpicker"
|
||||||
|
(None Text)
|
||||||
|
(Some "log")
|
||||||
|
]
|
||||||
|
}
|
||||||
|
, terminal =
|
||||||
|
Child.flat
|
||||||
|
Child.Attributes::{
|
||||||
|
, binary = "terminal"
|
||||||
|
, provides = [ "Terminal" ]
|
||||||
|
, resources = Resources::{
|
||||||
|
, caps = 256
|
||||||
|
, ram = Genode.units.MiB 4
|
||||||
|
}
|
||||||
|
, routes =
|
||||||
|
[ ServiceRoute.child "Framebuffer" "nit_fb"
|
||||||
|
, ServiceRoute.child "Input" "nit_fb"
|
||||||
|
]
|
||||||
|
, config = Init.Config::{
|
||||||
|
, content =
|
||||||
|
[ Prelude.XML.text
|
||||||
|
''
|
||||||
|
<vfs>
|
||||||
|
<rom name="Inconsolata.ttf"/>
|
||||||
|
<dir name="fonts">
|
||||||
|
<dir name="monospace">
|
||||||
|
<ttf name="regular" path="/Inconsolata.ttf" size_px="10"/>
|
||||||
|
</dir>
|
||||||
|
</dir>
|
||||||
|
</vfs>
|
||||||
|
''
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
, terminal_log =
|
||||||
|
Child.flat
|
||||||
|
Child.Attributes::{
|
||||||
|
, binary = "terminal_log"
|
||||||
|
, provides = [ "LOG" ]
|
||||||
|
, routes = [ ServiceRoute.child "Terminal" "terminal" ]
|
||||||
|
}
|
||||||
|
, log_core =
|
||||||
|
Child.flat
|
||||||
|
Child.Attributes::{
|
||||||
|
, binary = "log_core"
|
||||||
|
, routes =
|
||||||
|
[ routeLogRom "core_log"
|
||||||
|
, ServiceRoute.childLabel
|
||||||
|
"LOG"
|
||||||
|
"terminal_log"
|
||||||
|
(Some "log")
|
||||||
|
(Some "core")
|
||||||
|
]
|
||||||
|
}
|
||||||
|
, log_kernel =
|
||||||
|
Child.flat
|
||||||
|
Child.Attributes::{
|
||||||
|
, binary = "log_core"
|
||||||
|
, routes =
|
||||||
|
[ routeLogRom "kernel_log"
|
||||||
|
, ServiceRoute.childLabel
|
||||||
|
"LOG"
|
||||||
|
"terminal_log"
|
||||||
|
(Some "log")
|
||||||
|
(Some "kernel")
|
||||||
|
]
|
||||||
|
}
|
||||||
, block =
|
, block =
|
||||||
Child.flat
|
Child.flat
|
||||||
Child.Attributes::{
|
Child.Attributes::{
|
||||||
|
@ -449,7 +543,8 @@ let rootInit =
|
||||||
}
|
}
|
||||||
, XML.leaf
|
, XML.leaf
|
||||||
{ name = "default-policy"
|
{ name = "default-policy"
|
||||||
, attributes = toMap { root = "/" }
|
, attributes = toMap
|
||||||
|
{ root = "/", writeable = "yes" }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -460,13 +555,33 @@ let rootInit =
|
||||||
}
|
}
|
||||||
, routes = [ ServiceRoute.child "Block" "block_router" ]
|
, routes = [ ServiceRoute.child "Block" "block_router" ]
|
||||||
}
|
}
|
||||||
|
, nic_drv =
|
||||||
|
Child.flat
|
||||||
|
Child.Attributes::{
|
||||||
|
, binary = "ipxe_nic_drv"
|
||||||
|
, provides = [ "Nic" ]
|
||||||
|
, resources = Init.Resources::{
|
||||||
|
, caps = 128
|
||||||
|
, ram = Genode.units.MiB 4
|
||||||
|
}
|
||||||
|
, routes =
|
||||||
|
[ ServiceRoute.childLabel
|
||||||
|
"Platform"
|
||||||
|
"platform_drv"
|
||||||
|
(None Text)
|
||||||
|
(Some "nic_drv")
|
||||||
|
]
|
||||||
|
}
|
||||||
, vbox =
|
, vbox =
|
||||||
Child.flat
|
Child.flat
|
||||||
Child.Attributes::{
|
Child.Attributes::{
|
||||||
, binary = "virtualbox5"
|
, binary = "virtualbox5"
|
||||||
, config = Init.Config::{
|
, config = Init.Config::{
|
||||||
, attributes = toMap
|
, attributes = toMap
|
||||||
{ vbox_file = "nixos.vbox", vm_name = "nixos" }
|
{ vbox_file = "machine.vbox"
|
||||||
|
, vm_name = "linux"
|
||||||
|
, xhci = "yes"
|
||||||
|
}
|
||||||
, content =
|
, content =
|
||||||
[ XML.leaf
|
[ XML.leaf
|
||||||
{ name = "libc"
|
{ name = "libc"
|
||||||
|
@ -487,13 +602,17 @@ let rootInit =
|
||||||
, attributes = XML.emptyAttributes
|
, attributes = XML.emptyAttributes
|
||||||
}
|
}
|
||||||
|
|
||||||
in [ Vfs/inline "nixos.vbox" vboxConfig
|
in [ Vfs/inline "machine.vbox" vboxConfig
|
||||||
, XML.element
|
, XML.element
|
||||||
{ name = "dir"
|
{ name = "dir"
|
||||||
, attributes = toMap { name = "dev" }
|
, attributes = toMap { name = "dev" }
|
||||||
, content = [ tag "log", tag "rtc" ]
|
, content = [ tag "log", tag "rtc" ]
|
||||||
}
|
}
|
||||||
, tag "fs"
|
, XML.leaf
|
||||||
|
{ name = "fs"
|
||||||
|
, attributes = toMap
|
||||||
|
{ writeable = "yes" }
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -508,9 +627,28 @@ let rootInit =
|
||||||
[ ServiceRoute.parent "VM"
|
[ ServiceRoute.parent "VM"
|
||||||
, ServiceRoute.child "Nitpicker" "nitpicker"
|
, ServiceRoute.child "Nitpicker" "nitpicker"
|
||||||
, ServiceRoute.child "File_system" "file_system"
|
, ServiceRoute.child "File_system" "file_system"
|
||||||
|
, ServiceRoute.child "Nic" "nic_drv"
|
||||||
, ServiceRoute.child "Rtc" "rtc"
|
, ServiceRoute.child "Rtc" "rtc"
|
||||||
|
, ServiceRoute.childLabel
|
||||||
|
"Report"
|
||||||
|
"_report_rom"
|
||||||
|
(Some "shape")
|
||||||
|
(Some "shape")
|
||||||
|
, ServiceRoute.parentLabel
|
||||||
|
"ROM"
|
||||||
|
(Some "platform_info")
|
||||||
|
(Some "platform_info")
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
, rom_logger =
|
||||||
|
Child.flat
|
||||||
|
Child.Attributes::{
|
||||||
|
, binary = "rom_logger"
|
||||||
|
, config = Init.Config::{
|
||||||
|
, attributes = toMap { rom = "state" }
|
||||||
|
}
|
||||||
|
, reportRoms = [ label "state" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
{ self }:
|
{ self, depot }:
|
||||||
let
|
let
|
||||||
lib' = self.lib.x86_64-linux-x86_64-genode;
|
lib' = self.lib.x86_64-linux-x86_64-genode;
|
||||||
pkgs' = self.packages.x86_64-linux-x86_64-genode;
|
pkgs' = self.packages.x86_64-linux-x86_64-genode;
|
||||||
in { config, lib, pkgs, ... }:
|
in { config, lib, pkgs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
inherit (pkgs.vmTools) qemu;
|
||||||
|
|
||||||
buildBootDescription =
|
buildBootDescription =
|
||||||
self.legacyPackages.x86_64-linux.callPackage ./buildBootDescription.nix {
|
self.legacyPackages.x86_64-linux.callPackage ./buildBootDescription.nix {
|
||||||
lib = lib';
|
lib = lib';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nixosVDI = "${config.system.build.virtualBoxVDI}/nixos.vdi";
|
||||||
|
|
||||||
genodeParams = lib'.runDhallCommand "params.dhall" { } ''
|
genodeParams = lib'.runDhallCommand "params.dhall" { } ''
|
||||||
vdiUuid=$(${pkgs.virtualbox}/bin/VBoxManage showmediuminfo ${config.system.build.virtualBoxVDI}/nixos.vdi | awk '/^UUID:/ {print $2}')
|
vdiUuid=$(${pkgs.virtualbox}/bin/VBoxManage showmediuminfo ${nixosVDI} | awk '/^UUID:/ {print $2}')
|
||||||
dhall > $out << EOD
|
dhall > $out << EOD
|
||||||
{ vdiFilename = "nixos.vdi"
|
{ vdiFilename = "nixos.vdi"
|
||||||
, vdiUuid = "$vdiUuid"
|
, vdiUuid = "$vdiUuid"
|
||||||
|
@ -29,19 +33,26 @@ let
|
||||||
"ahci_drv"
|
"ahci_drv"
|
||||||
"init"
|
"init"
|
||||||
"input_filter"
|
"input_filter"
|
||||||
|
"ipxe_nic_drv"
|
||||||
"libc"
|
"libc"
|
||||||
"libiconv"
|
"libiconv"
|
||||||
|
"log_core"
|
||||||
|
"nit_fb"
|
||||||
"nitpicker"
|
"nitpicker"
|
||||||
"part_block"
|
"part_block"
|
||||||
"platform_drv"
|
"platform_drv"
|
||||||
"ps2_drv"
|
"ps2_drv"
|
||||||
"report_rom"
|
"report_rom"
|
||||||
|
"rom_logger"
|
||||||
"rtc_drv"
|
"rtc_drv"
|
||||||
"rump"
|
"rump"
|
||||||
"stdcxx"
|
"stdcxx"
|
||||||
|
"terminal"
|
||||||
|
"terminal_log"
|
||||||
"vbox5"
|
"vbox5"
|
||||||
"vesa_drv"
|
"vesa_drv"
|
||||||
"vfs"
|
"vfs"
|
||||||
|
"vfs_ttf"
|
||||||
] ++ [ pkgs'.base-nova pkgs'.block_router ];
|
] ++ [ pkgs'.base-nova pkgs'.block_router ];
|
||||||
extraBinaries = [
|
extraBinaries = [
|
||||||
"ld.lib.so"
|
"ld.lib.so"
|
||||||
|
@ -55,48 +66,119 @@ let
|
||||||
"libstdcxx.so"
|
"libstdcxx.so"
|
||||||
"libvfs.so"
|
"libvfs.so"
|
||||||
"libvfs_rump.so"
|
"libvfs_rump.so"
|
||||||
|
"libvfs_ttf.so"
|
||||||
];
|
];
|
||||||
|
extraRoms = {
|
||||||
|
"Inconsolata.ttf" =
|
||||||
|
"${pkgs.inconsolata}/share/fonts/truetype/inconsolata/Inconsolata-Regular.ttf";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
firmware = lib'.novaImage "stage0" { } bootDescription;
|
firmware = lib'.novaImage "stage0" { } bootDescription;
|
||||||
|
|
||||||
# add system.build.virtualBoxVDI/nixos.vdi to disk image
|
grubStandalone = pkgs.runCommand "grub-standalone" {
|
||||||
|
buildInputs = [ pkgs.grub2_efi ];
|
||||||
|
grubModules = [ "multiboot2" "gzio" "normal" "gfxterm" ];
|
||||||
|
} ''
|
||||||
|
cat > grub.cfg << EOF
|
||||||
|
multiboot2 /bender
|
||||||
|
module2 /hypervisor.gz hypervisor iommu novpid novga serial logmem
|
||||||
|
module2 /image.elf.gz image.elf
|
||||||
|
EOF
|
||||||
|
|
||||||
genodeDiskImage = with pkgs;
|
gzip -c "${pkgs'.NOVA}/hypervisor-x86_64" > hypervisor.gz
|
||||||
runCommand "genode.disk" {
|
gzip -c "${firmware}" > image.elf.gz
|
||||||
nativeBuildInputs = [ e2fsprogs gptfdisk lzip vmTools.qemu ];
|
|
||||||
} ''
|
|
||||||
qemu-img create -f raw fs.raw 16M
|
|
||||||
qemu-img create -f raw zero.raw 1M
|
|
||||||
|
|
||||||
mke2fs fs.raw
|
mkdir -p $out
|
||||||
|
grub-mkstandalone -O x86_64-efi -o "$out/bootx64.efi" \
|
||||||
|
--install-modules="$grubModules" \
|
||||||
|
--modules="$grubModules" \
|
||||||
|
"boot/grub/grub.cfg=grub.cfg" \
|
||||||
|
"hypervisor.gz=hypervisor.gz" \
|
||||||
|
"image.elf.gz=image.elf.gz" \
|
||||||
|
'';
|
||||||
|
|
||||||
cat zero.raw fs.raw zero.raw > gpt.raw
|
genodeDiskImage = pkgs.vmTools.runInLinuxVM
|
||||||
|
(pkgs.runCommand "genode-disk-image" {
|
||||||
|
preVM = ''
|
||||||
|
mkdir $out
|
||||||
|
diskImage=$out/disk.img
|
||||||
|
bootFlash=$out/bios.bin
|
||||||
|
${qemu}/bin/qemu-img create -f qcow2 $diskImage 2G
|
||||||
|
install -m0644 ${pkgs.OVMF-CSM.fd}/FV/OVMF.fd $bootFlash
|
||||||
|
'';
|
||||||
|
buildInputs = with pkgs; [ e2fsprogs grub2_efi utillinux ];
|
||||||
|
QEMU_OPTS = "-pflash $out/bios.bin -nographic";
|
||||||
|
}
|
||||||
|
# Use fixed GUIDs for reproducibility
|
||||||
|
''
|
||||||
|
${pkgs.gptfdisk}/bin/sgdisk \
|
||||||
|
--set-alignment=512 --new=1:0:16M --change-name=1:EFISystem \
|
||||||
|
--set-alignment=512 --largest-new=2 --change-name=2:Genode \
|
||||||
|
--typecode=1:ef00 \
|
||||||
|
--typecode=2:${import ./dhall/partition-type} \
|
||||||
|
--attributes=1:set:2 \
|
||||||
|
--disk-guid=E7D8E481-623A-4F0F-87E6-A2327CC591C6 \
|
||||||
|
--partition-guid=1:B4DC4B9C-8B22-43BB-8D96-7CD4473DABE6 \
|
||||||
|
--partition-guid=2:113F1671-8074-4D82-8C25-DC84BA04D2C9 \
|
||||||
|
--recompute-chs /dev/vda
|
||||||
|
|
||||||
sgdisk gpt.raw --new=partnum 1:34:-34 \
|
${pkgs.dosfstools}/bin/mkfs.fat -F16 /dev/vda1
|
||||||
--typecode=1:${import ./dhall/partition-type} \
|
export MTOOLS_SKIP_CHECK=1
|
||||||
--change-name=1:genode
|
${pkgs.mtools}/bin/mlabel -i /dev/vda1 ::boot
|
||||||
|
|
||||||
mkdir -p $out
|
mkdir /boot /genode
|
||||||
lzip -c gpt.raw > "$out/genode-nixos-${config.system.nixos.label}.disk"
|
|
||||||
'';
|
mount /dev/vda1 /boot
|
||||||
|
install -D ${grubStandalone}/bootx64.efi /boot/efi/boot/bootx64.efi
|
||||||
|
umount /boot
|
||||||
|
|
||||||
|
mke2fs /dev/vda2
|
||||||
|
|
||||||
|
mount /dev/vda2 /genode
|
||||||
|
cp ${nixosVDI} /genode/nixos.vdi
|
||||||
|
cp "${pkgs'.genodeSources}/tool/boot/bender" /genode/bender
|
||||||
|
cp "${pkgs'.NOVA}/hypervisor-x86_64" /genode/hypervisor-x86_64
|
||||||
|
gzip -c "${firmware}" > /genode/image.elf.gz
|
||||||
|
umount /genode
|
||||||
|
'');
|
||||||
|
|
||||||
in {
|
in {
|
||||||
system.build.genodeDiskImage =
|
system.build = {
|
||||||
pkgs.runCommand "nixos-vm" { preferLocalBuild = true; } ''
|
genodeGuestScript = pkgs.writeScriptBin "genode-nixos-vm" ''
|
||||||
mkdir -p $out/bin
|
#! ${pkgs.runtimeShell}
|
||||||
ln -s ${
|
set -e
|
||||||
pkgs.writeScript "run-nixos-vm" ''
|
${qemu}/bin/qemu-img create -f qcow2 -b \
|
||||||
#! ${pkgs.runtimeShell}
|
${genodeDiskImage}/disk.img disk.img || exit 1
|
||||||
${pkgs.vmTools.qemu}/bin/qemu-system-x86_64 \
|
install -m0644 ${genodeDiskImage}/bios.bin bios.bin || exit 1
|
||||||
-machine q35 \
|
|
||||||
-cpu phenom \
|
${pkgs.vmTools.qemu}/bin/qemu-system-x86_64 \
|
||||||
-m 512 \
|
-machine q35 \
|
||||||
-serial mon:stdio \
|
-cpu phenom \
|
||||||
-kernel "${pkgs'.bender}" \
|
-m 4096 \
|
||||||
-initrd "${pkgs'.NOVA}/hypervisor-x86_64 arg=iommu novpid serial logmem,${firmware}" \
|
-serial mon:stdio \
|
||||||
$@
|
-pflash bios.bin \
|
||||||
''
|
disk.img \
|
||||||
} $out/bin/run-genode-vm
|
$@
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
genodeGuest = pkgs.runCommand "nixos-vm" { preferLocalBuild = true; } ''
|
||||||
|
mkdir -p $out
|
||||||
|
|
||||||
|
ln -s ${grubStandalone}/bootx64.efi $out/bootx64.efi
|
||||||
|
ln -s ${nixosVDI} $out/nixo.vdi
|
||||||
|
|
||||||
|
cat > $out/README << EOF
|
||||||
|
# Installation instructions
|
||||||
|
|
||||||
|
Copy the following UEFI boot image to the appropriate boot media:
|
||||||
|
|
||||||
|
$out/bootx64.efi
|
||||||
|
|
||||||
|
Copy the following disk image to an Ext2 partition with the partition type
|
||||||
|
${import ./dhall/partition-type}
|
||||||
|
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue