nixos: do not test with a disk without a store
This commit is contained in:
parent
26d4f6b62e
commit
983c63aa0b
|
@ -394,7 +394,7 @@ in {
|
||||||
bootDriveImage = import ./lib/make-bootable-image.nix {
|
bootDriveImage = import ./lib/make-bootable-image.nix {
|
||||||
inherit config pkgs espImage storeFsImage;
|
inherit config pkgs espImage storeFsImage;
|
||||||
};
|
};
|
||||||
in bootDriveImage;
|
in lib.mkIf (config.genode.boot.storeBackend != "tarball") bootDriveImage;
|
||||||
|
|
||||||
# virtualisation.useEFIBoot = config.genode.boot.storeBackend == "usb";
|
# virtualisation.useEFIBoot = config.genode.boot.storeBackend == "usb";
|
||||||
|
|
||||||
|
|
|
@ -25,15 +25,6 @@ with lib;
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
hardware.genode.platform.policies = lib.mkOption {
|
|
||||||
type = with types; listOf path;
|
|
||||||
default = [ ];
|
|
||||||
description = ''
|
|
||||||
List of policies to append to the Genode platform driver.
|
|
||||||
Type is Init.Config.Policy.Type.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
hardware.genode = {
|
hardware.genode = {
|
||||||
|
|
||||||
ahci.enable = lib.mkEnableOption "AHCI (SATA) block driver";
|
ahci.enable = lib.mkEnableOption "AHCI (SATA) block driver";
|
||||||
|
@ -58,11 +49,21 @@ with lib;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
platform.policies = lib.mkOption {
|
||||||
|
type = with types; listOf path;
|
||||||
|
default = [ ];
|
||||||
|
description = ''
|
||||||
|
List of policies to append to the Genode platform driver.
|
||||||
|
Type is Init.Config.Policy.Type.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = let cfg = config.hardware.genode;
|
||||||
|
in {
|
||||||
|
|
||||||
assertions = with builtins;
|
assertions = with builtins;
|
||||||
let
|
let
|
||||||
|
@ -99,7 +100,7 @@ with lib;
|
||||||
hardware.genode.usb.storage.enable = config.genode.boot.storeBackend
|
hardware.genode.usb.storage.enable = config.genode.boot.storeBackend
|
||||||
== "usb";
|
== "usb";
|
||||||
|
|
||||||
hardware.genode.usb.enable = config.hardware.genode.usb.storage.enable;
|
hardware.genode.usb.enable = cfg.usb.storage.enable;
|
||||||
|
|
||||||
hardware.genode.platform.policies = lib.lists.imap0 (i: name:
|
hardware.genode.platform.policies = lib.lists.imap0 (i: name:
|
||||||
builtins.toFile (name + ".platform-policy.dhall") ''
|
builtins.toFile (name + ".platform-policy.dhall") ''
|
||||||
|
@ -119,7 +120,7 @@ with lib;
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
'') (builtins.attrNames config.networking.interfaces)
|
'') (builtins.attrNames config.networking.interfaces)
|
||||||
++ (lib.optional config.hardware.genode.ahci.enable
|
++ (lib.optional cfg.ahci.enable
|
||||||
(builtins.toFile ("ahci.platform-policy.dhall") ''
|
(builtins.toFile ("ahci.platform-policy.dhall") ''
|
||||||
let Genode = env:DHALL_GENODE
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
|
@ -131,7 +132,7 @@ with lib;
|
||||||
{ name = "pci", attributes = toMap { class = "AHCI" } }
|
{ name = "pci", attributes = toMap { class = "AHCI" } }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
'')) ++ (lib.optional config.hardware.genode.framebuffer.enable
|
'')) ++ (lib.optional cfg.framebuffer.enable
|
||||||
(builtins.toFile ("framebuffer.platform-policy.dhall") ''
|
(builtins.toFile ("framebuffer.platform-policy.dhall") ''
|
||||||
let Genode = env:DHALL_GENODE
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
|
@ -143,7 +144,7 @@ with lib;
|
||||||
{ name = "pci", attributes = toMap { class = "VGA" } }
|
{ name = "pci", attributes = toMap { class = "VGA" } }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
'')) ++ (lib.optional config.hardware.genode.usb.enable
|
'')) ++ (lib.optional cfg.usb.enable
|
||||||
(builtins.toFile ("usb.platform-policy.dhall") ''
|
(builtins.toFile ("usb.platform-policy.dhall") ''
|
||||||
let Genode = env:DHALL_GENODE
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
|
@ -296,7 +297,7 @@ with lib;
|
||||||
|
|
||||||
in lib.filterAttrs (n: v: v != null) (nics // sockets);
|
in lib.filterAttrs (n: v: v != null) (nics // sockets);
|
||||||
|
|
||||||
genode.core.children.ahci_drv = {
|
genode.core.children.ahci_drv = lib.mkIf cfg.ahci.enable {
|
||||||
inputs = [ pkgs.genodePackages.ahci_drv ];
|
inputs = [ pkgs.genodePackages.ahci_drv ];
|
||||||
configFile = pkgs.writeText "ahci_drv.dhall" ''
|
configFile = pkgs.writeText "ahci_drv.dhall" ''
|
||||||
let Genode = env:DHALL_GENODE
|
let Genode = env:DHALL_GENODE
|
||||||
|
@ -359,43 +360,91 @@ with lib;
|
||||||
|
|
||||||
genode.core.children.platform_drv = {
|
genode.core.children.platform_drv = {
|
||||||
inputs = [ pkgs.genodePackages.platform_drv ];
|
inputs = [ pkgs.genodePackages.platform_drv ];
|
||||||
configFile = let
|
configFile =
|
||||||
policies =
|
let policies = map (policy: ", ${policy}") cfg.platform.policies;
|
||||||
map (policy: ", ${policy}") config.hardware.genode.platform.policies;
|
in pkgs.writeText "platform_drv.dhall" ''
|
||||||
in pkgs.writeText "platform_drv.dhall" ''
|
let Genode = env:DHALL_GENODE
|
||||||
let Genode = env:DHALL_GENODE
|
|
||||||
|
|
||||||
let Init = Genode.Init
|
let Init = Genode.Init
|
||||||
|
|
||||||
in Init.Child.flat
|
in Init.Child.flat
|
||||||
Init.Child.Attributes::{
|
Init.Child.Attributes::{
|
||||||
, binary = "platform_drv"
|
, binary = "platform_drv"
|
||||||
, resources = Init.Resources::{
|
, resources = Init.Resources::{
|
||||||
, caps = 800
|
, caps = 800
|
||||||
, ram = Genode.units.MiB 4
|
, ram = Genode.units.MiB 4
|
||||||
, constrainPhys = True
|
, constrainPhys = True
|
||||||
|
}
|
||||||
|
, reportRoms = let label = "acpi" in [ { local = label, route = label } ]
|
||||||
|
, routes =
|
||||||
|
[ Init.ServiceRoute.parent "IRQ"
|
||||||
|
, Init.ServiceRoute.parent "IO_MEM"
|
||||||
|
, Init.ServiceRoute.parent "IO_PORT"
|
||||||
|
]
|
||||||
|
, config = Init.Config::{
|
||||||
|
, policies = [ ${
|
||||||
|
toString policies
|
||||||
|
} ] : List Init.Config.Policy.Type
|
||||||
|
}
|
||||||
}
|
}
|
||||||
, reportRoms = let label = "acpi" in [ { local = label, route = label } ]
|
'';
|
||||||
, routes =
|
|
||||||
[ Init.ServiceRoute.parent "IRQ"
|
|
||||||
, Init.ServiceRoute.parent "IO_MEM"
|
|
||||||
, Init.ServiceRoute.parent "IO_PORT"
|
|
||||||
]
|
|
||||||
, config = Init.Config::{
|
|
||||||
, policies = [ ${
|
|
||||||
toString policies
|
|
||||||
} ] : List Init.Config.Policy.Type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
genode.core.children.usb_drv = let
|
genode.core.children.usb_drv = let toYesNo = b: if b then "yes" else "no";
|
||||||
cfg = config.hardware.genode.usb;
|
in mkIf cfg.usb.enable {
|
||||||
toYesNo = b: if b then "yes" else "no";
|
|
||||||
in mkIf cfg.enable {
|
|
||||||
inputs = [ pkgs.genodePackages.usb_drv ];
|
inputs = [ pkgs.genodePackages.usb_drv ];
|
||||||
configFile = builtins.toFile "usb_drv.dhall" ''
|
configFile = with cfg.usb;
|
||||||
|
builtins.toFile "usb_drv.dhall" ''
|
||||||
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
|
let XML = Genode.Prelude.XML
|
||||||
|
|
||||||
|
let Init = Genode.Init
|
||||||
|
|
||||||
|
in Init.Child.flat
|
||||||
|
Init.Child.Attributes::{
|
||||||
|
, binary = "usb_drv"
|
||||||
|
, resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 12 }
|
||||||
|
, romReports = let local = "devices" in [ { local, route = local } ]
|
||||||
|
, routes = [ Init.ServiceRoute.parent "IO_MEM" ]
|
||||||
|
, config =
|
||||||
|
let storagePolicy =
|
||||||
|
Init.Config.Policy::{
|
||||||
|
, service = "Usb"
|
||||||
|
, label = Init.LabelSelector.prefix "usb_block_drv"
|
||||||
|
, attributes = toMap { class = "8" }
|
||||||
|
, diag = Some True
|
||||||
|
}
|
||||||
|
|
||||||
|
in Init.Config::{
|
||||||
|
, attributes = toMap
|
||||||
|
{ ehci = "${toYesNo ehciSupport}"
|
||||||
|
, ohci = "${toYesNo ohciSupport}"
|
||||||
|
, uhci = "${toYesNo uhciSupport}"
|
||||||
|
, xhci = "${toYesNo xhciSupport}"
|
||||||
|
}
|
||||||
|
, content =
|
||||||
|
[ XML.element
|
||||||
|
{ name = "raw"
|
||||||
|
, attributes = XML.emptyAttributes
|
||||||
|
, content =
|
||||||
|
[ XML.leaf
|
||||||
|
{ name = "report"
|
||||||
|
, attributes = toMap { devices = "yes" }
|
||||||
|
}
|
||||||
|
, Init.Config.Policy.toXML storagePolicy
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
, policies = [ storagePolicy ] : List Init.Config.Policy.Type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
genode.core.children.usb_block_drv = mkIf cfg.usb.storage.enable {
|
||||||
|
inputs = [ pkgs.genodePackages.usb_block_drv ];
|
||||||
|
configFile = builtins.toFile "usb_block_drv.dhall" ''
|
||||||
let Genode = env:DHALL_GENODE
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
let XML = Genode.Prelude.XML
|
let XML = Genode.Prelude.XML
|
||||||
|
@ -404,107 +453,55 @@ with lib;
|
||||||
|
|
||||||
in Init.Child.flat
|
in Init.Child.flat
|
||||||
Init.Child.Attributes::{
|
Init.Child.Attributes::{
|
||||||
, binary = "usb_drv"
|
, binary = "usb_block_drv"
|
||||||
, resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 12 }
|
, resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 4 }
|
||||||
, romReports = let local = "devices" in [ { local, route = local } ]
|
, config = Init.Config::{
|
||||||
, routes = [ Init.ServiceRoute.parent "IO_MEM" ]
|
, attributes = toMap { writeable = "yes" }
|
||||||
, config =
|
, policies =
|
||||||
let storagePolicy =
|
[ Init.Config.Policy::{
|
||||||
Init.Config.Policy::{
|
, service = "Block"
|
||||||
, service = "Usb"
|
, label = Init.LabelSelector.prefix "part_block"
|
||||||
, label = Init.LabelSelector.prefix "usb_block_drv"
|
}
|
||||||
, attributes = toMap { class = "8" }
|
]
|
||||||
, diag = Some True
|
}
|
||||||
}
|
|
||||||
|
|
||||||
in Init.Config::{
|
|
||||||
, attributes = toMap
|
|
||||||
{ ehci = "${toYesNo cfg.ehciSupport}"
|
|
||||||
, ohci = "${toYesNo cfg.ohciSupport}"
|
|
||||||
, uhci = "${toYesNo cfg.uhciSupport}"
|
|
||||||
, xhci = "${toYesNo cfg.xhciSupport}"
|
|
||||||
}
|
|
||||||
, content =
|
|
||||||
[ XML.element
|
|
||||||
{ name = "raw"
|
|
||||||
, attributes = XML.emptyAttributes
|
|
||||||
, content =
|
|
||||||
[ XML.leaf
|
|
||||||
{ name = "report"
|
|
||||||
, attributes = toMap { devices = "yes" }
|
|
||||||
}
|
|
||||||
, Init.Config.Policy.toXML storagePolicy
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
, policies = [ storagePolicy ] : List Init.Config.Policy.Type
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
genode.core.children.usb_block_drv =
|
genode.core.children.fb_drv = mkIf cfg.framebuffer.enable {
|
||||||
mkIf config.hardware.genode.usb.storage.enable {
|
inputs = with pkgs.genodePackages;
|
||||||
inputs = [ pkgs.genodePackages.usb_block_drv ];
|
{
|
||||||
configFile = builtins.toFile "usb_block_drv.dhall" ''
|
"boot" = [ boot_fb_drv ];
|
||||||
let Genode = env:DHALL_GENODE
|
"vesa" = [ vesa_drv ];
|
||||||
|
}.${cfg.framebuffer.driver};
|
||||||
let XML = Genode.Prelude.XML
|
configFile = let
|
||||||
|
binary = with pkgs.genodePackages;
|
||||||
let Init = Genode.Init
|
|
||||||
|
|
||||||
in Init.Child.flat
|
|
||||||
Init.Child.Attributes::{
|
|
||||||
, binary = "usb_block_drv"
|
|
||||||
, resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 4 }
|
|
||||||
, config = Init.Config::{
|
|
||||||
, attributes = toMap { writeable = "yes" }
|
|
||||||
, policies =
|
|
||||||
[ Init.Config.Policy::{
|
|
||||||
, service = "Block"
|
|
||||||
, label = Init.LabelSelector.prefix "part_block"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
genode.core.children.fb_drv =
|
|
||||||
mkIf config.hardware.genode.framebuffer.enable {
|
|
||||||
inputs = with pkgs.genodePackages;
|
|
||||||
{
|
{
|
||||||
"boot" = [ boot_fb_drv ];
|
"boot" = "boot_fb_drv";
|
||||||
"vesa" = [ vesa_drv ];
|
"vesa" = "vesa_fb_drv";
|
||||||
}.${config.hardware.genode.framebuffer.driver};
|
}.${cfg.framebuffer.driver};
|
||||||
configFile = let
|
in builtins.toFile "fb_drv.dhall" ''
|
||||||
binary = with pkgs.genodePackages;
|
let Genode = env:DHALL_GENODE
|
||||||
{
|
|
||||||
"boot" = "boot_fb_drv";
|
|
||||||
"vesa" = "vesa_fb_drv";
|
|
||||||
}.${config.hardware.genode.framebuffer.driver};
|
|
||||||
in builtins.toFile "fb_drv.dhall" ''
|
|
||||||
let Genode = env:DHALL_GENODE
|
|
||||||
|
|
||||||
let XML = Genode.Prelude.XML
|
let XML = Genode.Prelude.XML
|
||||||
|
|
||||||
let Init = Genode.Init
|
let Init = Genode.Init
|
||||||
|
|
||||||
in Init.Child.flat
|
in Init.Child.flat
|
||||||
Init.Child.Attributes::{
|
Init.Child.Attributes::{
|
||||||
, binary = "${binary}"
|
, binary = "${binary}"
|
||||||
, resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 32 }
|
, resources = Init.Resources::{ caps = 256, ram = Genode.units.MiB 32 }
|
||||||
, routes =
|
, routes =
|
||||||
[ Init.ServiceRoute.parent "IO_MEM"
|
[ Init.ServiceRoute.parent "IO_MEM"
|
||||||
, Init.ServiceRoute.parent "IO_PORT"
|
, Init.ServiceRoute.parent "IO_PORT"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
virtualisation.useBootLoader = config.genode.boot.storeBackend != "tarball";
|
virtualisation.useBootLoader = config.genode.boot.storeBackend != "tarball";
|
||||||
|
|
||||||
virtualisation.qemu.options = lib.optional config.hardware.genode.usb.enable
|
virtualisation.qemu.options = lib.optional cfg.usb.enable
|
||||||
(lib.optional (pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64) "-usb"
|
(lib.optional (pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64) "-usb"
|
||||||
++ lib.optional (pkgs.stdenv.isAarch32 || pkgs.stdenv.isAarch64)
|
++ lib.optional (pkgs.stdenv.isAarch32 || pkgs.stdenv.isAarch64)
|
||||||
"-device usb-ehci,id=usb0");
|
"-device usb-ehci,id=usb0");
|
||||||
|
|
|
@ -23,7 +23,7 @@ let
|
||||||
# Shell script to start the VM.
|
# Shell script to start the VM.
|
||||||
startVM = ''
|
startVM = ''
|
||||||
#! ${pkgs.buildPackages.runtimeShell}
|
#! ${pkgs.buildPackages.runtimeShell}
|
||||||
|
'' + lib.optionalString (config.virtualisation.diskImage != null) ''
|
||||||
NIX_DISK_IMAGE=$(readlink -f ''${NIX_DISK_IMAGE:-${config.virtualisation.diskImage}})
|
NIX_DISK_IMAGE=$(readlink -f ''${NIX_DISK_IMAGE:-${config.virtualisation.diskImage}})
|
||||||
|
|
||||||
if ! test -w "$NIX_DISK_IMAGE"; then
|
if ! test -w "$NIX_DISK_IMAGE"; then
|
||||||
|
@ -36,6 +36,7 @@ let
|
||||||
${toString config.virtualisation.diskSize}M || exit 1
|
${toString config.virtualisation.diskSize}M || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
'' + ''
|
||||||
# Create a directory for storing temporary data of the running VM.
|
# Create a directory for storing temporary data of the running VM.
|
||||||
if [ -z "$TMPDIR" -o -z "$USE_TMPDIR" ]; then
|
if [ -z "$TMPDIR" -o -z "$USE_TMPDIR" ]; then
|
||||||
TMPDIR=$(mktemp -d nix-vm.XXXXXXXXXX --tmpdir)
|
TMPDIR=$(mktemp -d nix-vm.XXXXXXXXXX --tmpdir)
|
||||||
|
@ -72,7 +73,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
virtualisation.diskImage = mkOption {
|
virtualisation.diskImage = mkOption {
|
||||||
default = "./${config.system.name}.qcow2";
|
type = with types; nullOr path;
|
||||||
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Path to the disk image containing the root filesystem.
|
Path to the disk image containing the root filesystem.
|
||||||
The image will be created on startup if it does not
|
The image will be created on startup if it does not
|
||||||
|
|
Loading…
Reference in New Issue