nixos: add file-systems options

This commit is contained in:
Emery Hemingway 2021-01-13 12:33:52 +01:00
parent 1bb05f7e57
commit 74ea4d0c12
6 changed files with 53 additions and 15 deletions

View File

@ -4,6 +4,7 @@
x86_64 = {
imports = [
./file-systems.nix
./genode-core.nix
./genode-init.nix
./gui

View File

@ -0,0 +1,29 @@
{ config, lib, pkgs, ... }:
with lib; {
options.fileSystems = lib.mkOption {
type = types.attrsOf (types.submodule ({ name, config, ... }: {
options.block = {
device = lib.mkOption { type = types.int; };
driver = lib.mkOption { type = types.enum [ "ahci" ]; };
partition = lib.mkOption { type = types.ints.positive; };
};
}));
};
config = {
assertions = [{
assertion = config.fileSystems."/".fsType == "ext2";
message = "The only supported fsType is EXT2";
}];
hardware.genode.ahci.enable =
any (fs: fs.block.driver == "ahci") (attrValues config.fileSystems);
};
}

View File

@ -220,7 +220,9 @@ in {
, service = "Block"
, label = Init.LabelSelector.prefix "store_fs"
, attributes = toMap
{ partition = "1"
{ partition = "${
toString config.fileSystems."/".block.partition
}"
, writeable = "yes"
, TODO = "select by partition UUID"
}
@ -233,17 +235,18 @@ in {
{ }) // {
store_fs.configFile = let
storeVfsConfig = let
storeVfsConfig =
if config.genode.boot.storeBackend == "tarball" then ''
VFS.vfs [ VFS.leafAttrs "tar" (toMap { name = "${config.system.build.tarball.fileName}.tar" }) ]
'' else
let
rumpExt2 = ''
VFS.vfs [ VFS.leafAttrs "rump" (toMap { fs = "ext2fs", ram="12M" }) ]
'';
in {
ahci = rumpExt2;
tarball = ''
VFS.vfs [ VFS.leafAttrs "tar" (toMap { name = "${config.system.build.tarball.fileName}.tar" }) ]
'';
usb = rumpExt2;
}.${config.genode.boot.storeBackend};
}.${config.fileSystems."/".block.driver};
storeResources = let
rumpExt2 =

View File

@ -10,8 +10,6 @@ with lib;
config = let cfg = config.hardware.genode.ahci;
in {
hardware.genode.ahci.enable = config.genode.boot.storeBackend == "ahci";
hardware.genode.platform.policies = lib.optional cfg.enable
(builtins.toFile ("ahci.platform-policy.dhall") ''
let Genode = env:DHALL_GENODE
@ -52,7 +50,9 @@ with lib;
[ Init.Config.Policy::{
, service = "Block"
, label = Init.LabelSelector.prefix "part_block"
, attributes = toMap { device = "0", writeable = "yes" }
, attributes = toMap { device = "${
toString config.fileSystems."/".block.device
}", writeable = "yes" }
}
]
}

View File

@ -1,7 +1,11 @@
{
name = "ahci";
machine = { pkgs, ... }: {
genode.boot.storeBackend = "ahci";
fileSystems."/".block = {
driver = "ahci";
device = 0;
partition = 1;
};
genode.init.children.hello = {
inputs = [ pkgs.hello pkgs.genodePackages.vfs.lib ];
configFile = pkgs.writeText "ahci-hello.child.dhall" ''

View File

@ -27,6 +27,7 @@ rec {
inherit system;
modules = configurations ++ extraConfigurations;
baseModules = (import "${modulesPath}/module-list.nix") ++ [
../../nixos-modules/file-systems.nix
../../nixos-modules/genode-core.nix
../../nixos-modules/genode-init.nix
../../nixos-modules/gui