2024-05-01 21:16:17 +00:00
|
|
|
{ self, ... }:
|
|
|
|
{
|
|
|
|
perSystem =
|
|
|
|
{ pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
clanModules = self.clanModules;
|
|
|
|
|
|
|
|
# Uncomment if you only want one module to be available
|
|
|
|
# clanModules = {
|
2024-05-03 17:36:59 +00:00
|
|
|
# borgbackup = self.clanModules.borgbackup;
|
2024-05-01 21:16:17 +00:00
|
|
|
# };
|
|
|
|
|
|
|
|
optionsFromModule =
|
2024-06-24 13:47:25 +00:00
|
|
|
mName:
|
2024-05-01 21:16:17 +00:00
|
|
|
let
|
2024-06-24 13:47:25 +00:00
|
|
|
eval = self.lib.evalClanModules [ mName ];
|
2024-05-01 21:16:17 +00:00
|
|
|
in
|
2024-06-24 13:47:25 +00:00
|
|
|
if (eval.options.clan ? "${mName}") then eval.options.clan.${mName} else { };
|
2024-05-01 21:16:17 +00:00
|
|
|
|
|
|
|
clanModuleSchemas = lib.mapAttrs (
|
2024-06-24 13:47:25 +00:00
|
|
|
modulename: _: self.lib.jsonschema.parseOptions (optionsFromModule modulename)
|
2024-05-01 21:16:17 +00:00
|
|
|
) clanModules;
|
|
|
|
|
2024-06-24 13:47:25 +00:00
|
|
|
clanModuleFunctionSchemas = lib.mapAttrsFlatten (modulename: _: {
|
2024-05-01 21:16:17 +00:00
|
|
|
name = modulename;
|
2024-05-01 21:35:14 +00:00
|
|
|
description = self.lib.modules.getShortDescription modulename;
|
2024-06-24 13:47:25 +00:00
|
|
|
parameters = self.lib.jsonschema.parseOptions (optionsFromModule modulename);
|
2024-05-01 21:16:17 +00:00
|
|
|
}) clanModules;
|
|
|
|
in
|
|
|
|
rec {
|
|
|
|
checks = {
|
|
|
|
module-schema = pkgs.runCommand "schema-checks" { } ''
|
|
|
|
${pkgs.check-jsonschema}/bin/check-jsonschema \
|
2024-05-03 16:22:20 +00:00
|
|
|
--check-metaschema ${packages.module-schema}
|
2024-05-01 21:16:17 +00:00
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
packages = {
|
|
|
|
module-schema = pkgs.runCommand "jsonschema" { } ''
|
|
|
|
MSCHEMA=${builtins.toFile "module-schemas.json" (builtins.toJSON clanModuleSchemas)}
|
|
|
|
cp "$MSCHEMA" $out
|
|
|
|
'';
|
|
|
|
|
|
|
|
function-schema = pkgs.runCommand "function-schema" { } ''
|
|
|
|
FSCHEMA=${builtins.toFile "function-schemas.json" (builtins.toJSON clanModuleFunctionSchemas)}
|
|
|
|
cp "$FSCHEMA" $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|