Boot from USB
This commit is contained in:
parent
16f62030f4
commit
517080b3dd
|
@ -25,14 +25,22 @@ in {
|
||||||
prefix = mkOption {
|
prefix = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
example = "hw-pc-";
|
example = "hw-pc-";
|
||||||
|
description = "String prefix signifying the Genode core in use.";
|
||||||
};
|
};
|
||||||
|
|
||||||
supportedSystems = mkOption {
|
supportedSystems = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
example = [ "i686-genode" "x86_64-genode" ];
|
example = [ "i686-genode" "x86_64-genode" ];
|
||||||
|
description = "Hardware supported by this core.";
|
||||||
};
|
};
|
||||||
|
|
||||||
basePackages = mkOption { type = types.listOf types.package; };
|
basePackages = mkOption {
|
||||||
|
type = types.listOf types.package;
|
||||||
|
description = ''
|
||||||
|
List of packages to make availabe before the Nix store is ready.
|
||||||
|
These are baked into <option>config.genode.core.image</option>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
children = mkOption {
|
children = mkOption {
|
||||||
type = with types;
|
type = with types;
|
||||||
|
@ -57,17 +65,6 @@ in {
|
||||||
|
|
||||||
boot = {
|
boot = {
|
||||||
|
|
||||||
kernel = mkOption {
|
|
||||||
type = types.path;
|
|
||||||
default = "${pkgs.genodePackages.bender}/bender";
|
|
||||||
};
|
|
||||||
|
|
||||||
initrd = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "${pkgs.genodePackages.bender}/bender";
|
|
||||||
description = "Path to an image or a command-line arguments";
|
|
||||||
};
|
|
||||||
|
|
||||||
configFile = mkOption {
|
configFile = mkOption {
|
||||||
type = types.path;
|
type = types.path;
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -87,6 +84,18 @@ in {
|
||||||
description = "Attr set of initial ROM modules";
|
description = "Attr set of initial ROM modules";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
storeFsUuid = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = import ./store-fs-uuid;
|
||||||
|
description = "Custom partition type of the nix-store file-system.";
|
||||||
|
};
|
||||||
|
|
||||||
|
storePartUuid = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = import ./partition-type;
|
||||||
|
description = "Custom partition type of the nix-store file-system.";
|
||||||
|
};
|
||||||
|
|
||||||
storeBackend = mkOption {
|
storeBackend = mkOption {
|
||||||
type = types.enum [ "tarball" "usb" ]; # "parent"?
|
type = types.enum [ "tarball" "usb" ]; # "parent"?
|
||||||
default = "tarball";
|
default = "tarball";
|
||||||
|
@ -119,7 +128,6 @@ in {
|
||||||
|
|
||||||
storePaths = mkOption {
|
storePaths = mkOption {
|
||||||
type = with types; listOf package;
|
type = with types; listOf package;
|
||||||
example = literalExample "[ pkgs.genodePackages.vfs_lwp ]";
|
|
||||||
description = ''
|
description = ''
|
||||||
Derivations to be included in the Nix store in the generated boot image.
|
Derivations to be included in the Nix store in the generated boot image.
|
||||||
'';
|
'';
|
||||||
|
@ -148,9 +156,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
mergeManifests = inputs:
|
mergeManifests = inputs:
|
||||||
localPackages.writeTextFile {
|
with builtins;
|
||||||
name = "manifest.dhall";
|
|
||||||
text = with builtins;
|
|
||||||
let
|
let
|
||||||
f = head: input:
|
f = head: input:
|
||||||
if hasAttr "manifest" input then
|
if hasAttr "manifest" input then
|
||||||
|
@ -161,7 +167,6 @@ in {
|
||||||
else
|
else
|
||||||
abort "${input.pname} does not have a manifest";
|
abort "${input.pname} does not have a manifest";
|
||||||
in (foldl' f "[" inputs) + "]";
|
in (foldl' f "[" inputs) + "]";
|
||||||
};
|
|
||||||
|
|
||||||
romDirectories = filterAttrs (_: value: value != null) (mapAttrs
|
romDirectories = filterAttrs (_: value: value != null) (mapAttrs
|
||||||
(name: value:
|
(name: value:
|
||||||
|
@ -181,7 +186,41 @@ in {
|
||||||
message = "invalid Genode core for this system";
|
message = "invalid Genode core for this system";
|
||||||
}];
|
}];
|
||||||
|
|
||||||
genode.core.children.store_fs.configFile = let
|
genode.core.basePackages =
|
||||||
|
lib.optional (config.genode.boot.storeBackend == "usb")
|
||||||
|
pkgs.genodePackages.part_block;
|
||||||
|
|
||||||
|
genode.core.children =
|
||||||
|
# Component to steer the store_fs to a specific partition
|
||||||
|
(if config.genode.boot.storeBackend == "usb" then {
|
||||||
|
part_block.configFile = builtins.toFile "part_block.dhall" ''
|
||||||
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
|
let Init = Genode.Init
|
||||||
|
|
||||||
|
in Init.Child.flat
|
||||||
|
Init.Child.Attributes::{
|
||||||
|
, binary = "part_block"
|
||||||
|
, resources = Init.Resources::{ ram = Genode.units.MiB 8 }
|
||||||
|
, config = Init.Config::{
|
||||||
|
, attributes = toMap { ignore_mbr = "yes" }
|
||||||
|
, policies =
|
||||||
|
[ Init.Config.Policy::{
|
||||||
|
, service = "Block"
|
||||||
|
, label = Init.LabelSelector.prefix "store_fs"
|
||||||
|
, attributes = toMap
|
||||||
|
{ partition = "1"
|
||||||
|
, writeable = "yes"
|
||||||
|
, TODO = "select by partition UUID"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
} else
|
||||||
|
{ }) // {
|
||||||
|
store_fs.configFile = let
|
||||||
|
|
||||||
storeVfsConfig = {
|
storeVfsConfig = {
|
||||||
tarball = ''
|
tarball = ''
|
||||||
|
@ -223,9 +262,9 @@ in {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
, provides = [ "File_system" ]
|
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
genode.boot.configFile = let
|
genode.boot.configFile = let
|
||||||
tarball =
|
tarball =
|
||||||
|
@ -236,9 +275,21 @@ in {
|
||||||
usb = [ pkgs.genodePackages.rump ];
|
usb = [ pkgs.genodePackages.rump ];
|
||||||
}.${config.genode.boot.storeBackend};
|
}.${config.genode.boot.storeBackend};
|
||||||
|
|
||||||
manifest = mergeManifests (map addManifest (with pkgs.genodePackages;
|
coreInputs = with builtins;
|
||||||
|
concatMap (getAttr "inputs") (attrValues config.genode.core.children);
|
||||||
|
|
||||||
|
manifest =
|
||||||
|
# Manifests are Dhall metadata to be attached to every
|
||||||
|
# package to be used for dynamically buildings enviroments
|
||||||
|
# using Dhall expressions. Probably not worth pursuing.
|
||||||
|
pkgs.writeText "manifest.dhall" (mergeManifests (map addManifest
|
||||||
|
(with pkgs.genodePackages;
|
||||||
config.genode.core.basePackages ++ storeBackendInputs
|
config.genode.core.basePackages ++ storeBackendInputs
|
||||||
++ [ init cached_fs_rom jitter_sponge report_rom vfs ]));
|
++ [ init cached_fs_rom jitter_sponge report_rom vfs ]
|
||||||
|
++ coreInputs)) + ''# [ { mapKey = "romModules", mapValue = [ ''
|
||||||
|
+ (toString
|
||||||
|
(mapAttrsToList (k: v: '', { mapKey = "${k}", mapValue = "${v}" }'')
|
||||||
|
config.genode.boot.romModules)) + " ] } ]");
|
||||||
|
|
||||||
storeRomPolicies = mapAttrsToList
|
storeRomPolicies = mapAttrsToList
|
||||||
(name: value: '', { mapKey = "${name}", mapValue = "${value}" }'')
|
(name: value: '', { mapKey = "${name}", mapValue = "${value}" }'')
|
||||||
|
@ -253,7 +304,7 @@ in {
|
||||||
Genode.Init.LabelSelector.Type.Partial
|
Genode.Init.LabelSelector.Type.Partial
|
||||||
{ prefix = Some "nixos -> ${name}", suffix = Some "${suffix}" }
|
{ prefix = Some "nixos -> ${name}", suffix = Some "${suffix}" }
|
||||||
}
|
}
|
||||||
, route = Genode.Init.Route.parent (Some "${suffix}")
|
, route = Genode.Init.Route.parentLabel "${suffix}"
|
||||||
}
|
}
|
||||||
'') value.coreROMs) config.genode.init.children));
|
'') value.coreROMs) config.genode.init.children));
|
||||||
|
|
||||||
|
@ -282,8 +333,8 @@ in {
|
||||||
EOF
|
EOF
|
||||||
'';
|
'';
|
||||||
|
|
||||||
genode.boot.storePaths = [ config.genode.init.configFile ]
|
genode.boot.storePaths = with builtins;
|
||||||
++ (builtins.attrValues romDirectories);
|
[ config.genode.init.configFile ] ++ (attrValues romDirectories);
|
||||||
|
|
||||||
# Create the tarball of the store to live in core ROM
|
# Create the tarball of the store to live in core ROM
|
||||||
system.build.tarball =
|
system.build.tarball =
|
||||||
|
@ -316,17 +367,21 @@ in {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
system.build.bootDriveImage = let
|
system.build.bootDriveImage = let
|
||||||
storeFsImage = pkgs.callPackage ./lib/make-ext2-fs.nix {
|
espImage = import ./lib/make-esp-fs.nix { inherit config pkgs; };
|
||||||
inherit (config.genode.boot) storePaths;
|
storeFsImage =
|
||||||
inherit (config.system.build) qemu;
|
pkgs.callPackage ./lib/make-ext2-fs.nix { inherit config pkgs; };
|
||||||
volumeLabel = "NIXOS_GENODE";
|
bootDriveImage = import ./lib/make-bootable-image.nix {
|
||||||
|
inherit config pkgs espImage storeFsImage;
|
||||||
};
|
};
|
||||||
in storeFsImage;
|
in bootDriveImage;
|
||||||
|
|
||||||
|
# virtualisation.useEFIBoot = config.genode.boot.storeBackend == "usb";
|
||||||
|
|
||||||
virtualisation.qemu.options =
|
virtualisation.qemu.options =
|
||||||
lib.optionals (config.genode.boot.storeBackend == "usb") [
|
lib.optionals (config.genode.boot.storeBackend == "usb") [
|
||||||
"-usb"
|
"-bios ${pkgs.buildPackages.OVMF.fd}/FV/OVMF.fd"
|
||||||
"-drive id=usbdisk,file=${config.system.build.bootDriveImage},if=none,readonly"
|
"-drive id=usbdisk,file=${config.system.build.bootDriveImage},if=none,readonly"
|
||||||
|
"-usb"
|
||||||
"-device usb-storage,drive=usbdisk"
|
"-device usb-storage,drive=usbdisk"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user