clan-core/checks/schemas.nix

49 lines
991 B
Nix
Raw Normal View History

2024-03-17 18:48:49 +00:00
{
self,
runCommand,
check-jsonschema,
pkgs,
lib,
...
}:
let
2023-08-30 13:29:05 +00:00
clanModules.clanCore = self.nixosModules.clanCore;
baseModule = {
2024-03-17 18:48:49 +00:00
imports = (import (pkgs.path + "/nixos/modules/module-list.nix")) ++ [
{
nixpkgs.hostPlatform = "x86_64-linux";
2024-01-11 17:02:50 +00:00
clanCore.clanName = "dummy";
2024-03-17 18:48:49 +00:00
}
];
};
2024-03-17 18:48:49 +00:00
optionsFromModule =
module:
let
evaled = lib.evalModules {
2024-03-17 18:48:49 +00:00
modules = [
module
baseModule
];
};
in
2023-08-30 13:29:05 +00:00
evaled.options.clan;
2024-03-17 18:48:49 +00:00
clanModuleSchemas = lib.mapAttrs (
_: module: self.lib.jsonschema.parseOptions (optionsFromModule module)
) clanModules;
2024-03-17 18:48:49 +00:00
mkTest =
name: schema:
runCommand "schema-${name}" { } ''
${check-jsonschema}/bin/check-jsonschema \
--check-metaschema ${builtins.toFile "schema-${name}" (builtins.toJSON schema)}
touch $out
'';
in
2024-03-17 18:48:49 +00:00
lib.mapAttrs' (name: schema: {
name = "schema-${name}";
value = mkTest name schema;
}) clanModuleSchemas