diff --git a/deployment/data-model-test.nix b/deployment/data-model-test.nix index 17c85f77..cc9b83fa 100644 --- a/deployment/data-model-test.nix +++ b/deployment/data-model-test.nix @@ -11,17 +11,18 @@ let }).config; in { + _class = "nix-unit"; + test-eval = { expr = let example = eval { - runtime-environments.bar.nixos = { - module = - { ... }: - { - system.stateVersion = "25.05"; - }; - }; + 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; }; }; diff --git a/deployment/data-model.nix b/deployment/data-model.nix index af867d55..81738e45 100644 --- a/deployment/data-model.nix +++ b/deployment/data-model.nix @@ -1,43 +1,68 @@ { lib, + config, ... }: let - inherit (lib) types mkOption; -in -with types; -{ - 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"; - type = deferredModule; - }; - }; - }; - }; - }); + 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"; }; - applications = mkOption { - description = "Collection of Fediversity applications"; - type = attrsOf (submoduleWith { + }; + runtime-environment = attrTag { + nixos = mkOption { + type = submoduleWith { modules = [ { options = { module = mkOption { - description = "The NixOS module for that application, for configuring that application"; + description = "The NixOS module of the run-time environment"; type = deferredModule; + default = config.runtime-configurations.nixos; + readOnly = true; }; }; } ]; - }); + }; + }; + }; + 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; }; }; }