{ lib, config, ... }: let inherit (lib) attrNames mkOption genAttrs; inherit (lib.types) attrsOf attrTag deferredModule submoduleWith ; runtime-configuration = mkOption { description = "The NixOS module of a run-time environment"; type = deferredModule; default = { _class = "nixos"; }; }; runtime-environment = attrTag ( mapAttrs ( name: options: mkOption { type = submoduleWith { modules = [ { options = options // { module = mkOption { description = "The NixOS module of the run-time environment"; type = deferredModule; default = config.runtime-configurations.${name}; readOnly = true; }; }; } ]; }; } ) { nixos = { }; } ); application = submoduleWith { description = "A Fediversity application"; modules = [ { options = { module = mkOption { description = "The NixOS module for that application, for configuring that application"; type = deferredModule; }; }; } ]; }; in { options = { runtime-configurations = mkOption { description = "Collection of runtime environments into which applications can be deployed"; type = attrTag (genAttrs (attrNames runtime-environment.nestedTypes) (_: runtime-configuration)); }; runtime-environments = mkOption { description = "Collection of runtime environments into which applications can be deployed"; type = attrsOf runtime-environment; }; applications = mkOption { description = "Collection of Fediversity applications"; type = attrsOf application; }; }; }