checks: ensure clanModules are clan-config compatible
All checks were successful
build / test (pull_request) Successful in 21s

This commit is contained in:
DavHau 2023-08-09 18:42:03 +02:00
parent a2648f2afb
commit 00826d848e
3 changed files with 56 additions and 1 deletions

5
checks/flake-module.nix Normal file
View File

@ -0,0 +1,5 @@
{
imports = [
./schema.nix
];
}

50
checks/schema.nix Normal file
View File

@ -0,0 +1,50 @@
{ self, lib, inputs, ... }:
let
inherit (builtins)
mapAttrs
toJSON
toFile
;
inherit (lib)
mapAttrs'
;
clanLib = self.lib;
clanModules = self.clanModules;
baseModule = {
imports =
(import (inputs.nixpkgs + "/nixos/modules/module-list.nix"))
++ [{
nixpkgs.hostPlatform = "x86_64-linux";
}];
};
optionsFromModule = module:
let
evaled = lib.evalModules {
modules = [ module baseModule ];
};
in
evaled.options.clan.networking;
clanModuleSchemas = mapAttrs (_: module: clanLib.jsonschema.parseOptions (optionsFromModule module)) clanModules;
in
{
perSystem = { pkgs, ... }:
let
mkTest = name: schema: pkgs.runCommand "schema-${name}" { } ''
${pkgs.check-jsonschema}/bin/check-jsonschema \
--check-metaschema ${toFile "schema-${name}" (toJSON schema)}
touch $out
'';
in
{
checks = mapAttrs'
(name: schema: {
name = "schema-${name}";
value = mkTest name schema;
})
clanModuleSchemas;
};
}

View File

@ -22,7 +22,7 @@
"aarch64-linux"
];
imports = [
# ./checks/flake-module.nix
./checks/flake-module.nix
./devShell.nix
./formatter.nix
./templates/flake-module.nix