nixos: config.genode.boot.storeBackend is "fs" or "memory"
Make the config.genode.boot.storeBackend option a choice between a traditional file-system or memory-backed file-system image. Fix GRUB booting when using a file-system store. The nova-ahci test shows that this is working.
This commit is contained in:
parent
6f9f1b7069
commit
8c0c7d55c4
|
@ -7,7 +7,7 @@ with lib; {
|
|||
|
||||
device = lib.mkOption { type = types.int; };
|
||||
|
||||
driver = lib.mkOption { type = types.enum [ "ahci" ]; };
|
||||
driver = lib.mkOption { type = types.enum [ "ahci" "usb" ]; };
|
||||
|
||||
partition = lib.mkOption { type = types.ints.positive; };
|
||||
|
||||
|
@ -24,6 +24,9 @@ with lib; {
|
|||
|
||||
hardware.genode.ahci.enable =
|
||||
any (fs: fs.block.driver == "ahci") (attrValues config.fileSystems);
|
||||
|
||||
hardware.genode.usb.storage.enable =
|
||||
any (fs: fs.block.driver == "usb") (attrValues config.fileSystems);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -98,40 +98,28 @@ in {
|
|||
};
|
||||
|
||||
storeBackend = mkOption {
|
||||
type = types.enum [ "ahci" "tarball" "usb" ]; # "parent"?
|
||||
default = "tarball";
|
||||
type = types.enum [ "fs" "memory" ]; # "parent"?
|
||||
default = "memory";
|
||||
description = ''
|
||||
Backend for the initial /nix/store file-system.
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>ahci</literal></term>
|
||||
<term>
|
||||
<literal>fs</literal>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
An EXT2 file-system backed by SATA storage.
|
||||
</para>
|
||||
<para>Store backed by a File_system session.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>tarball</literal></term>
|
||||
<term>
|
||||
<literal>tarball</literal>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
An in-memory tarball.
|
||||
</para>
|
||||
<para>An in-memory tarball.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>usb</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
An EXT2 file-system backed by USB storage.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
'';
|
||||
};
|
||||
|
@ -198,12 +186,12 @@ in {
|
|||
}];
|
||||
|
||||
genode.core.basePackages =
|
||||
lib.optional (config.genode.boot.storeBackend != "tarball")
|
||||
lib.optional (config.genode.boot.storeBackend != "memory")
|
||||
pkgs.genodePackages.part_block;
|
||||
|
||||
genode.core.children =
|
||||
# Component to steer the store_fs to a specific partition
|
||||
(if config.genode.boot.storeBackend != "tarball" then {
|
||||
(if config.genode.boot.storeBackend != "memory" then {
|
||||
part_block.configFile = builtins.toFile "part_block.dhall" ''
|
||||
let Genode = env:DHALL_GENODE
|
||||
|
||||
|
@ -236,7 +224,7 @@ in {
|
|||
store_fs.configFile = let
|
||||
|
||||
storeVfsConfig =
|
||||
if config.genode.boot.storeBackend == "tarball" then ''
|
||||
if config.genode.boot.storeBackend == "memory" then ''
|
||||
VFS.vfs [ VFS.leafAttrs "tar" (toMap { name = "${config.system.build.tarball.fileName}.tar" }) ]
|
||||
'' else
|
||||
let
|
||||
|
@ -252,9 +240,8 @@ in {
|
|||
rumpExt2 =
|
||||
"Init.Resources::{ caps = 256, ram = Genode.units.MiB 16 }";
|
||||
in {
|
||||
ahci = rumpExt2;
|
||||
tarball = "Init.Resources.default";
|
||||
usb = rumpExt2;
|
||||
fs = rumpExt2;
|
||||
memory = "Init.Resources.default";
|
||||
}.${config.genode.boot.storeBackend};
|
||||
|
||||
persistencePolicies = lib.mapAttrsToList (name: _: ''
|
||||
|
@ -316,9 +303,8 @@ in {
|
|||
"${config.system.build.tarball}/tarball/${config.system.build.tarball.fileName}.tar";
|
||||
|
||||
storeBackendInputs = {
|
||||
ahci = [ pkgs.genodePackages.rump ];
|
||||
tarball = [ config.system.build.tarball ];
|
||||
usb = [ pkgs.genodePackages.rump ];
|
||||
fs = [ pkgs.genodePackages.rump ];
|
||||
memory = [ config.system.build.tarball ];
|
||||
}.${config.genode.boot.storeBackend};
|
||||
|
||||
coreInputs = with builtins;
|
||||
|
@ -422,19 +408,15 @@ in {
|
|||
bootDriveImage = import ./lib/make-bootable-image.nix {
|
||||
inherit config pkgs espImage storeFsImage;
|
||||
};
|
||||
in lib.mkIf (config.genode.boot.storeBackend != "tarball") bootDriveImage;
|
||||
in lib.mkIf (config.genode.boot.storeBackend != "memory") bootDriveImage;
|
||||
|
||||
virtualisation.useBootLoader = config.genode.boot.storeBackend != "tarball";
|
||||
virtualisation.useBootLoader = config.genode.boot.storeBackend != "memory";
|
||||
|
||||
virtualisation.qemu.options =
|
||||
let blockCommon = [ "-bios ${pkgs.buildPackages.OVMF.fd}/FV/OVMF.fd" ];
|
||||
in {
|
||||
tarball = [ ];
|
||||
ahci = blockCommon;
|
||||
usb = blockCommon ++ [
|
||||
"-drive id=usbdisk,file=${config.system.build.bootDriveImage},if=none,readonly"
|
||||
"-device usb-storage,drive=usbdisk"
|
||||
];
|
||||
fs = blockCommon;
|
||||
memory = [ ];
|
||||
}.${config.genode.boot.storeBackend};
|
||||
|
||||
};
|
||||
|
|
|
@ -18,9 +18,6 @@ with lib;
|
|||
config = let cfg = config.hardware.genode.usb;
|
||||
in {
|
||||
|
||||
hardware.genode.usb.storage.enable = config.genode.boot.storeBackend
|
||||
== "usb";
|
||||
|
||||
hardware.genode.usb.enable = cfg.storage.enable;
|
||||
|
||||
hardware.genode.platform.policies = lib.optional cfg.enable
|
||||
|
@ -118,7 +115,10 @@ with lib;
|
|||
virtualisation.qemu.options = lib.optional cfg.enable
|
||||
(lib.optional (pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64) "-usb"
|
||||
++ lib.optional (pkgs.stdenv.isAarch32 || pkgs.stdenv.isAarch64)
|
||||
"-device usb-ehci,id=usb0");
|
||||
"-device usb-ehci,id=usb0") ++ lib.optional cfg.storage.enable [
|
||||
"-drive id=usbdisk,file=${config.system.build.bootDriveImage},if=none,readonly"
|
||||
"-device usb-storage,drive=usbdisk"
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -23,6 +23,12 @@ in pkgs.stdenv.mkDerivation {
|
|||
# Create nix/store before copying path
|
||||
mkdir -p ./rootImage/boot/grub ./rootImage/nix/store
|
||||
|
||||
cat > extraPrepareConfig.sh <<< '${config.boot.loader.grub.extraPrepareConfig}'
|
||||
substituteInPlace extraPrepareConfig.sh \
|
||||
--replace '${pkgs.coreutils}' '${pkgs.buildPackages.coreutils}' \
|
||||
--replace '@bootPath@' './rootImage/boot'
|
||||
source extraPrepareConfig.sh
|
||||
|
||||
cat <<EOF > ./rootImage/boot/grub/grub.cfg
|
||||
set timeout=3
|
||||
set default=0
|
||||
|
|
|
@ -31,7 +31,7 @@ in {
|
|||
};
|
||||
|
||||
genode.boot.storePaths =
|
||||
lib.optional (config.genode.boot.storeBackend != "tarball") bootDir;
|
||||
lib.optional (config.genode.boot.storeBackend != "memory") bootDir;
|
||||
|
||||
virtualisation.qemu.options =
|
||||
lib.optionals (!config.virtualisation.useBootLoader) [
|
||||
|
@ -52,9 +52,9 @@ in {
|
|||
menuentry 'Genode on NOVA' {
|
||||
insmod multiboot2
|
||||
insmod gzio
|
||||
multiboot2 /bender.gz serial_fallback
|
||||
module2 /hypervisor.gz hypervisor iommu logmem novga novpid serial
|
||||
module2 /image.elf.gz image.elf
|
||||
multiboot2 /boot/bender.gz serial_fallback
|
||||
module2 /boot/hypervisor.gz hypervisor iommu logmem novga novpid serial
|
||||
module2 /boot/image.elf.gz image.elf
|
||||
}
|
||||
'';
|
||||
extraFiles = {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
device = 0;
|
||||
partition = 1;
|
||||
};
|
||||
genode.boot.storeBackend = "fs";
|
||||
genode.init.children.hello = {
|
||||
inputs = [ pkgs.hello pkgs.genodePackages.vfs.lib ];
|
||||
configFile = pkgs.writeText "ahci-hello.child.dhall" ''
|
||||
|
|
Loading…
Reference in New Issue