71 lines
1.9 KiB
Nix
71 lines
1.9 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
with lib; {
|
|
|
|
options.systemd.services = lib.mkOption {
|
|
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.";
|
|
};
|
|
|
|
interface = lib.mkOption {
|
|
type = with types; nullOr str;
|
|
default = null;
|
|
example = "eth0";
|
|
description = ''
|
|
Grant access to an IP stack for this interface.
|
|
Only UDP and TCP are supported. No raw device access.
|
|
'';
|
|
};
|
|
|
|
};
|
|
}));
|
|
};
|
|
|
|
config = {
|
|
|
|
services.klogd.enable = false;
|
|
# The default is determined by checking the Linux version
|
|
# which cannot be evaluated here.
|
|
|
|
genode.init.children = mapAttrs' (name: service:
|
|
let name' = "services." + name;
|
|
in {
|
|
name = name';
|
|
value = {
|
|
inputs = with pkgs;
|
|
with genodePackages; [
|
|
bash
|
|
cached_fs_rom
|
|
libc
|
|
posix
|
|
vfs
|
|
vfs_pipe
|
|
];
|
|
configFile = let
|
|
args = ''[ "'' + concatStringsSep ''", "''
|
|
((lib.strings.splitString " ")
|
|
(toString service.serviceConfig.ExecStart)) + ''" ]'';
|
|
# TODO: service.environment;
|
|
interface = if service.genode.interface == null then
|
|
"None Text"
|
|
else
|
|
''Some "${service.genode.interface}"'';
|
|
in pkgs.writeText "${name'}.dhall" ''
|
|
${./systemd-runner.dhall} {
|
|
, args = ${args}
|
|
, coreutils = "${pkgs.coreutils}"
|
|
, interface = ${interface}
|
|
}
|
|
'';
|
|
};
|
|
}) (filterAttrs (name: service: service.genode.enable)
|
|
config.systemd.services);
|
|
|
|
};
|
|
|
|
}
|