forked from Fediversity/Fediversity
data model: add run-time configuration
This commit is contained in:
parent
486b316885
commit
8b2ee21dbe
2 changed files with 62 additions and 34 deletions
|
@ -11,17 +11,18 @@ let
|
|||
}).config;
|
||||
in
|
||||
{
|
||||
_class = "nix-unit";
|
||||
|
||||
test-eval = {
|
||||
expr =
|
||||
let
|
||||
example = eval {
|
||||
runtime-environments.bar.nixos = {
|
||||
module =
|
||||
runtime-configurations.nixos =
|
||||
{ ... }:
|
||||
{
|
||||
system.stateVersion = "25.05";
|
||||
};
|
||||
};
|
||||
runtime-environments.bar.nixos = { };
|
||||
applications.foo = {
|
||||
module =
|
||||
{ pkgs, ... }:
|
||||
|
@ -34,11 +35,13 @@ in
|
|||
};
|
||||
in
|
||||
{
|
||||
has-runtime = lib.isAttrs example.runtime-environments.bar.nixos.module;
|
||||
has-runtime-configuration = lib.isAttrs example.runtime-configurations.nixos;
|
||||
has-runtime-environment = lib.isAttrs example.runtime-environments.bar.nixos.module;
|
||||
has-application = lib.isAttrs example.applications.foo.module;
|
||||
};
|
||||
expected = {
|
||||
has-runtime = true;
|
||||
has-runtime-configuration = true;
|
||||
has-runtime-environment = true;
|
||||
has-application = true;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,32 +1,43 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) types mkOption;
|
||||
in
|
||||
with types;
|
||||
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 {
|
||||
nixos = mkOption {
|
||||
type = submoduleWith {
|
||||
modules = [
|
||||
{
|
||||
options = {
|
||||
runtime-environments = mkOption {
|
||||
description = "Collection of runtime environments into which applications can be deployed";
|
||||
type = attrsOf (attrTag {
|
||||
nixos = mkOption {
|
||||
description = "A single NixOS machine";
|
||||
type = submodule {
|
||||
options = {
|
||||
module = mkOption {
|
||||
description = "The NixOS module describing the base configuration for that machine";
|
||||
description = "The NixOS module of the run-time environment";
|
||||
type = deferredModule;
|
||||
default = config.runtime-configurations.nixos;
|
||||
readOnly = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
applications = mkOption {
|
||||
description = "Collection of Fediversity applications";
|
||||
type = attrsOf (submoduleWith {
|
||||
application = submoduleWith {
|
||||
description = "A Fediversity application";
|
||||
modules = [
|
||||
{
|
||||
options = {
|
||||
|
@ -37,7 +48,21 @@ with types;
|
|||
};
|
||||
}
|
||||
];
|
||||
});
|
||||
};
|
||||
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;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue