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;
|
}).config;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
_class = "nix-unit";
|
||||||
|
|
||||||
test-eval = {
|
test-eval = {
|
||||||
expr =
|
expr =
|
||||||
let
|
let
|
||||||
example = eval {
|
example = eval {
|
||||||
runtime-environments.bar.nixos = {
|
runtime-configurations.nixos =
|
||||||
module =
|
|
||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
system.stateVersion = "25.05";
|
system.stateVersion = "25.05";
|
||||||
};
|
};
|
||||||
};
|
runtime-environments.bar.nixos = { };
|
||||||
applications.foo = {
|
applications.foo = {
|
||||||
module =
|
module =
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
|
@ -34,11 +35,13 @@ in
|
||||||
};
|
};
|
||||||
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;
|
has-application = lib.isAttrs example.applications.foo.module;
|
||||||
};
|
};
|
||||||
expected = {
|
expected = {
|
||||||
has-runtime = true;
|
has-runtime-configuration = true;
|
||||||
|
has-runtime-environment = true;
|
||||||
has-application = true;
|
has-application = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,32 +1,43 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
|
config,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib) types mkOption;
|
inherit (lib) attrNames mkOption genAttrs;
|
||||||
in
|
inherit (lib.types)
|
||||||
with types;
|
attrsOf
|
||||||
{
|
attrTag
|
||||||
options = {
|
deferredModule
|
||||||
runtime-environments = mkOption {
|
submoduleWith
|
||||||
description = "Collection of runtime environments into which applications can be deployed";
|
;
|
||||||
type = attrsOf (attrTag {
|
runtime-configuration = mkOption {
|
||||||
|
description = "The NixOS module of a run-time environment";
|
||||||
|
type = deferredModule;
|
||||||
|
default = {
|
||||||
|
_class = "nixos";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
runtime-environment = attrTag {
|
||||||
nixos = mkOption {
|
nixos = mkOption {
|
||||||
description = "A single NixOS machine";
|
type = submoduleWith {
|
||||||
type = submodule {
|
modules = [
|
||||||
|
{
|
||||||
options = {
|
options = {
|
||||||
module = mkOption {
|
module = mkOption {
|
||||||
description = "The NixOS module describing the base configuration for that machine";
|
description = "The NixOS module of the run-time environment";
|
||||||
type = deferredModule;
|
type = deferredModule;
|
||||||
|
default = config.runtime-configurations.nixos;
|
||||||
|
readOnly = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
application = submoduleWith {
|
||||||
});
|
description = "A Fediversity application";
|
||||||
};
|
|
||||||
applications = mkOption {
|
|
||||||
description = "Collection of Fediversity applications";
|
|
||||||
type = attrsOf (submoduleWith {
|
|
||||||
modules = [
|
modules = [
|
||||||
{
|
{
|
||||||
options = {
|
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