104 lines
2.9 KiB
Nix
104 lines
2.9 KiB
Nix
# genodeInit.children is an attrset of nixos configurations, like containers
|
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
{
|
|
imports = [ ];
|
|
|
|
options.genode.init = {
|
|
|
|
config = mkOption {
|
|
description = "Dhall configuration of this init instance";
|
|
type = types.nullOr types.str;
|
|
default = null;
|
|
};
|
|
|
|
inputs = mkOption {
|
|
description = "List of packages to build a ROM store with.";
|
|
type = types.listOf types.package;
|
|
};
|
|
|
|
children = mkOption {
|
|
type = let
|
|
childOptions = { name, ... }: {
|
|
name = mkOption { type = types.str; };
|
|
dhallAttrs = mkOption { type = types.str; };
|
|
};
|
|
in types.attrsOf (types.submodule childOptions);
|
|
};
|
|
|
|
subinits = mkOption {
|
|
type = types.attrsOf (types.submodule ({ config, options, name, ... }: {
|
|
options = {
|
|
|
|
config = mkOption {
|
|
description = ''
|
|
A specification of the desired configuration of this sub-init, as a NixOS module.
|
|
'';
|
|
type =
|
|
let confPkgs = if config.pkgs == null then pkgs else config.pkgs;
|
|
in lib.mkOptionType {
|
|
name = "Toplevel NixOS config";
|
|
merge = loc: defs:
|
|
(import (confPkgs.path + "/nixos/lib/eval-config.nix") {
|
|
inherit system;
|
|
pkgs = confPkgs;
|
|
baseModules =
|
|
import (confPkgs.path + "/nixos/modules/module-list.nix");
|
|
inherit (confPkgs) lib;
|
|
modules = let
|
|
extraConfig = {
|
|
_file = "module at ${__curPos.file}:${
|
|
toString __curPos.line
|
|
}";
|
|
config = { };
|
|
};
|
|
in [ extraConfig ] ++ (map (x: x.value) defs);
|
|
prefix = [ "containers" name ];
|
|
}).config;
|
|
};
|
|
};
|
|
|
|
pkgs = mkOption {
|
|
type = types.nullOr types.attrs;
|
|
default = null;
|
|
example = literalExample "pkgs";
|
|
description = ''
|
|
Customise which nixpkgs to use for this container.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
config = mkMerge [
|
|
(mkIf options.config.isDefined {
|
|
path = config.config.system.build.toplevel;
|
|
})
|
|
];
|
|
}));
|
|
|
|
default = { };
|
|
};
|
|
|
|
};
|
|
|
|
config = {
|
|
|
|
system.build.initXml = pkgs.buildPackages.runCommand "init.xml" {
|
|
nativeBuildInputs = with pkgs.buildPackages; [ dhall xorg.lndir ];
|
|
DHALL_GENODE = "${pkgs.genodePackages.dhallGenode}/binary.dhall";
|
|
INIT_CONFIG = config.genode.init.config;
|
|
} ''
|
|
export XDG_CACHE_HOME=$NIX_BUILD_TOP
|
|
lndir -silent \
|
|
${pkgs.genodePackages.dhallGenode}/.cache \
|
|
$XDG_CACHE_HOME
|
|
dhall text <<< "(env:DHALL_GENODE).Init.render (env:INIT_CONFIG)" > $out
|
|
'';
|
|
|
|
};
|
|
|
|
}
|