Fediversity/deployment/data-model-test.nix
Kiara Grouwstra fd3b71c8df
various failed attempts to type-check deployment application configurations using config-level applications
as a result of these failures, i instead opted to move applications from
the config to the options layer, see branch `data-model-revamp`.
2025-07-01 14:56:55 +02:00

77 lines
2 KiB
Nix

let
inherit (import ../default.nix { }) pkgs;
inherit (pkgs) lib;
eval =
module:
(lib.evalModules {
modules = [
module
./data-model.nix
];
}).config;
in
{
_class = "nix-unit";
test-eval = {
expr =
let
example = eval (
{ config, ... }:
let
inherit (config.resources.bar.runtime-environment) runtime-environment;
in
{
providers.ssh-host =
{ ... }:
{
system.stateVersion = "25.05";
};
resources.bar.runtime-environment.ssh-host = {
ssh = {
host = "localhost";
username = "root";
authentication.password = "";
};
};
applications.foo.module =
{ pkgs, ... }:
{
options.doll = lib.mkOption {
type = lib.types.str;
};
config.environment.systemPackages = [
pkgs.hello
];
};
deployments.baz = {
inherit runtime-environment;
application-configuration = {
foo = {
doll = 123;
};
};
};
migrations.boo = {
inherit runtime-environment;
deployment = config.deployments.baz;
};
}
);
in
{
has-provider = lib.isAttrs example.providers.ssh-host;
has-resource = lib.isAttrs example.resources.bar.runtime-environment.ssh-host.module;
has-application = lib.isAttrs example.applications.foo.module;
has-deployment = lib.isAttrs example.deployments.baz.application-configuration.foo.doll;
has-migration = lib.isAttrs example.migrations.boo.deployment;
};
expected = {
has-provider = true;
has-resource = true;
has-application = true;
has-deployment = true;
has-migration = true;
};
};
}