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
|
|
|
# };
|
|
|
|
|
|
|
|
baseModule = {
|
|
|
|
imports = (import (pkgs.path + "/nixos/modules/module-list.nix")) ++ [
|
|
|
|
{
|
|
|
|
nixpkgs.hostPlatform = "x86_64-linux";
|
|
|
|
clanCore.clanName = "dummy";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
optionsFromModule =
|
|
|
|
modulename: module:
|
|
|
|
let
|
|
|
|
evaled = lib.evalModules {
|
|
|
|
modules = [
|
|
|
|
module
|
|
|
|
baseModule
|
|
|
|
self.nixosModules.clanCore
|
|
|
|
];
|
|
|
|
};
|
|
|
|
in
|
2024-05-03 17:36:59 +00:00
|
|
|
# Filter out "injected" options that are not part of the module
|
2024-05-01 21:16:17 +00:00
|
|
|
if (evaled.options.clan ? "${modulename}") then evaled.options.clan.${modulename} else { };
|
|
|
|
|
|
|
|
clanModuleSchemas = lib.mapAttrs (
|
|
|
|
modulename: module: self.lib.jsonschema.parseOptions (optionsFromModule modulename module)
|
|
|
|
) clanModules;
|
|
|
|
|
|
|
|
clanModuleFunctionSchemas = lib.mapAttrsFlatten (modulename: module: {
|
|
|
|
name = modulename;
|
2024-05-01 21:35:14 +00:00
|
|
|
description = self.lib.modules.getShortDescription modulename;
|
2024-05-01 21:16:17 +00:00
|
|
|
parameters = self.lib.jsonschema.parseOptions (optionsFromModule modulename module);
|
|
|
|
}) 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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|