forked from Fediversity/Fediversity
84 lines
2 KiB
Nix
84 lines
2 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
inherit (lib)
|
|
attrNames
|
|
mapAttrs
|
|
mkOption
|
|
genAttrs
|
|
;
|
|
inherit (lib.types)
|
|
attrsOf
|
|
attrTag
|
|
deferredModule
|
|
mergeTypes
|
|
submoduleWith
|
|
submodule
|
|
;
|
|
runtime-configuration = mkOption {
|
|
description = "The NixOS module of a run-time environment";
|
|
type = deferredModule;
|
|
default = {
|
|
_class = "nixos";
|
|
};
|
|
};
|
|
runtime-environment = attrTag (
|
|
mapAttrs
|
|
(
|
|
name:
|
|
option@{ type, ... }:
|
|
mkOption (
|
|
option
|
|
// {
|
|
type = mergeTypes type (submodule {
|
|
options.module = mkOption {
|
|
description = "The NixOS module of the run-time environment";
|
|
type = deferredModule;
|
|
default = config.runtime-configurations.${name};
|
|
readOnly = true;
|
|
};
|
|
});
|
|
}
|
|
)
|
|
)
|
|
{
|
|
nixos = {
|
|
description = "A NixOS instance to deploy to.";
|
|
type = submodule {
|
|
};
|
|
};
|
|
}
|
|
);
|
|
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;
|
|
};
|
|
};
|
|
}
|