2
0
Fork 0

nixos: add extraVfs and ramQuota options to systemd wrapper

This commit is contained in:
Emery Hemingway 2020-12-03 12:51:16 +01:00
parent f7b990a6ca
commit f7b08619ac
2 changed files with 62 additions and 38 deletions

View File

@ -19,7 +19,9 @@ in λ ( params
: { args : List Text
, binary : Text
, coreutils : Text
, extraVfs : List XML.Type
, interface : Optional Text
, ramQuotaMiB : Natural
}
) →
let socketsVfs =
@ -52,40 +54,44 @@ in λ ( params
, config = Init.Config::{
, content =
[ VFS.vfs
[ VFS.dir
"dev"
( [ VFS.dir "pipes" [ VFS.leaf "pipe" ]
, VFS.leaf "log"
, VFS.leaf "null"
, VFS.leafAttrs
"terminal"
( toMap
{ name = "entropy"
, label = "entropy"
}
)
, VFS.leaf "rtc"
, VFS.leaf "zero"
( [ VFS.dir
"dev"
( [ VFS.dir "pipes" [ VFS.leaf "pipe" ]
, VFS.leaf "log"
, VFS.leaf "null"
, VFS.leafAttrs
"terminal"
( toMap
{ name = "entropy"
, label = "entropy"
}
)
, VFS.leaf "rtc"
, VFS.leaf "zero"
]
# socketsVfs
)
, VFS.dir
"usr"
[ VFS.dir
"bin"
[ VFS.symlink
"env"
"${params.coreutils}/bin/env"
]
]
# socketsVfs
)
, VFS.dir
"usr"
[ VFS.dir
"bin"
[ VFS.symlink
"env"
"${params.coreutils}/bin/env"
, VFS.dir "tmp" [ VFS.leaf "ram" ]
, VFS.dir
"nix"
[ VFS.dir
"store"
[ VFS.fs
VFS.FS::{ label = "nix-store" }
]
]
]
, VFS.dir "tmp" [ VFS.leaf "ram" ]
, VFS.dir
"nix"
[ VFS.dir
"store"
[ VFS.fs VFS.FS::{ label = "nix-store" } ]
]
]
# params.extraVfs
)
]
, policies =
[ Init.Config.Policy::{
@ -98,7 +104,7 @@ in λ ( params
, service = "File_system"
, label = Init.LabelSelector.prefix "vfs_rom"
, attributes = toMap
{ root = "/", writeable = "yes" }
{ root = "/", writeable = "no" }
}
]
}
@ -128,7 +134,7 @@ in λ ( params
, exitPropagate = True
, resources = Genode.Init.Resources::{
, caps = 256
, ram = Genode.units.MiB 8
, ram = Genode.units.MiB params.ramQuotaMiB
}
, config =
( Libc.toConfig

View File

@ -5,11 +5,7 @@ with lib; {
type = types.attrsOf (types.submodule ({ name, config, ... }: {
options.genode = {
enable = lib.mkOption {
type = types.bool;
default = false;
description = "Translate this systemd unit to a Genode subsystem.";
};
enable = lib.mkEnableOption "systemd unit to a Genode subsystem translation";
interface = lib.mkOption {
type = with types; nullOr str;
@ -21,6 +17,21 @@ with lib; {
'';
};
extraVfs = lib.mkOption {
type = with types; nullOr path;
default = null;
description = ''
Extra configuration to be appended to the VFS of the service.
Dhall type is Prelude/XML/Type.
'';
};
ramQuota = lib.mkOption {
type = types.ints.unsigned;
default = 16;
description = "RAM quota in MiB";
};
};
}));
};
@ -60,7 +71,14 @@ with lib; {
, args = ${args'}
, binary = "${binary}"
, coreutils = "${pkgs.coreutils}"
, extraVfs = ${
if service.genode.extraVfs == null then
"[] : List (env:DHALL_PRELUDE).XML.Type"
else
service.genode.extraVfs
}
, interface = ${interface}
, ramQuotaMiB = ${toString service.genode.ramQuota}
}
'';
};