nixos: add extraVfs and ramQuota options to systemd wrapper
This commit is contained in:
parent
b7990eb365
commit
6c2ea4902d
|
@ -19,7 +19,9 @@ in λ ( params
|
||||||
: { args : List Text
|
: { args : List Text
|
||||||
, binary : Text
|
, binary : Text
|
||||||
, coreutils : Text
|
, coreutils : Text
|
||||||
|
, extraVfs : List XML.Type
|
||||||
, interface : Optional Text
|
, interface : Optional Text
|
||||||
|
, ramQuotaMiB : Natural
|
||||||
}
|
}
|
||||||
) →
|
) →
|
||||||
let socketsVfs =
|
let socketsVfs =
|
||||||
|
@ -52,40 +54,44 @@ in λ ( params
|
||||||
, config = Init.Config::{
|
, config = Init.Config::{
|
||||||
, content =
|
, content =
|
||||||
[ VFS.vfs
|
[ VFS.vfs
|
||||||
[ VFS.dir
|
( [ VFS.dir
|
||||||
"dev"
|
"dev"
|
||||||
( [ VFS.dir "pipes" [ VFS.leaf "pipe" ]
|
( [ VFS.dir "pipes" [ VFS.leaf "pipe" ]
|
||||||
, VFS.leaf "log"
|
, VFS.leaf "log"
|
||||||
, VFS.leaf "null"
|
, VFS.leaf "null"
|
||||||
, VFS.leafAttrs
|
, VFS.leafAttrs
|
||||||
"terminal"
|
"terminal"
|
||||||
( toMap
|
( toMap
|
||||||
{ name = "entropy"
|
{ name = "entropy"
|
||||||
, label = "entropy"
|
, label = "entropy"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
, VFS.leaf "rtc"
|
, VFS.leaf "rtc"
|
||||||
, VFS.leaf "zero"
|
, VFS.leaf "zero"
|
||||||
|
]
|
||||||
|
# socketsVfs
|
||||||
|
)
|
||||||
|
, VFS.dir
|
||||||
|
"usr"
|
||||||
|
[ VFS.dir
|
||||||
|
"bin"
|
||||||
|
[ VFS.symlink
|
||||||
|
"env"
|
||||||
|
"${params.coreutils}/bin/env"
|
||||||
|
]
|
||||||
]
|
]
|
||||||
# socketsVfs
|
, VFS.dir "tmp" [ VFS.leaf "ram" ]
|
||||||
)
|
, VFS.dir
|
||||||
, VFS.dir
|
"nix"
|
||||||
"usr"
|
[ VFS.dir
|
||||||
[ VFS.dir
|
"store"
|
||||||
"bin"
|
[ VFS.fs
|
||||||
[ VFS.symlink
|
VFS.FS::{ label = "nix-store" }
|
||||||
"env"
|
]
|
||||||
"${params.coreutils}/bin/env"
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, VFS.dir "tmp" [ VFS.leaf "ram" ]
|
# params.extraVfs
|
||||||
, VFS.dir
|
)
|
||||||
"nix"
|
|
||||||
[ VFS.dir
|
|
||||||
"store"
|
|
||||||
[ VFS.fs VFS.FS::{ label = "nix-store" } ]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
, policies =
|
, policies =
|
||||||
[ Init.Config.Policy::{
|
[ Init.Config.Policy::{
|
||||||
|
@ -98,7 +104,7 @@ in λ ( params
|
||||||
, service = "File_system"
|
, service = "File_system"
|
||||||
, label = Init.LabelSelector.prefix "vfs_rom"
|
, label = Init.LabelSelector.prefix "vfs_rom"
|
||||||
, attributes = toMap
|
, attributes = toMap
|
||||||
{ root = "/", writeable = "yes" }
|
{ root = "/", writeable = "no" }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -128,7 +134,7 @@ in λ ( params
|
||||||
, exitPropagate = True
|
, exitPropagate = True
|
||||||
, resources = Genode.Init.Resources::{
|
, resources = Genode.Init.Resources::{
|
||||||
, caps = 256
|
, caps = 256
|
||||||
, ram = Genode.units.MiB 8
|
, ram = Genode.units.MiB params.ramQuotaMiB
|
||||||
}
|
}
|
||||||
, config =
|
, config =
|
||||||
( Libc.toConfig
|
( Libc.toConfig
|
||||||
|
|
|
@ -5,11 +5,7 @@ with lib; {
|
||||||
type = types.attrsOf (types.submodule ({ name, config, ... }: {
|
type = types.attrsOf (types.submodule ({ name, config, ... }: {
|
||||||
options.genode = {
|
options.genode = {
|
||||||
|
|
||||||
enable = lib.mkOption {
|
enable = lib.mkEnableOption "systemd unit to a Genode subsystem translation";
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Translate this systemd unit to a Genode subsystem.";
|
|
||||||
};
|
|
||||||
|
|
||||||
interface = lib.mkOption {
|
interface = lib.mkOption {
|
||||||
type = with types; nullOr str;
|
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'}
|
, args = ${args'}
|
||||||
, binary = "${binary}"
|
, binary = "${binary}"
|
||||||
, coreutils = "${pkgs.coreutils}"
|
, coreutils = "${pkgs.coreutils}"
|
||||||
|
, extraVfs = ${
|
||||||
|
if service.genode.extraVfs == null then
|
||||||
|
"[] : List (env:DHALL_PRELUDE).XML.Type"
|
||||||
|
else
|
||||||
|
service.genode.extraVfs
|
||||||
|
}
|
||||||
, interface = ${interface}
|
, interface = ${interface}
|
||||||
|
, ramQuotaMiB = ${toString service.genode.ramQuota}
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue