Files
logos-module-builder/lib/parseMetadata.nix
T
Khushboo Mehta aff10448b2 feat: consolidate module config into metadata.json as single source of truth
Remove module.yaml and use metadata.json exclusively for both runtime
and Nix build configuration. The nix block in metadata.json replaces
module.yaml for build-time settings. Updates all docs, skills, templates,
lib/*.nix files, and the waku-module-migrated example.
2026-03-24 20:06:12 +01:00

41 lines
1.7 KiB
Nix

# Parse metadata.json as the single source of truth for a module.
# Runtime fields (name, type, dependencies, icon, main…) live at the top level
# and are read by Qt, logos-standalone-app, the nix bundler and the Nix build system.
# Nix/build-only fields live under the "nix" key and are ignored at runtime.
{ lib }:
{
parseModuleConfig = jsonContent:
let
raw = builtins.fromJSON jsonContent;
nix = raw.nix or {};
safeList = val: if builtins.isList val then val else [];
in {
# Runtime fields
name = raw.name or (throw "metadata.json must specify 'name'");
version = raw.version or "1.0.0";
type = raw.type or "core";
category = raw.category or "general";
description = raw.description or "A Logos module";
main = raw.main or null;
icon = raw.icon or null;
dependencies = safeList (raw.dependencies or []);
include = safeList (raw.include or []);
# Nix/build-only fields (nested under "nix" in metadata.json)
nix_packages = {
build = safeList ((nix.packages or {}).build or []);
runtime = safeList ((nix.packages or {}).runtime or []);
};
external_libraries = safeList (nix.external_libraries or []);
cmake = {
find_packages = safeList ((nix.cmake or {}).find_packages or []);
extra_sources = safeList ((nix.cmake or {}).extra_sources or []);
extra_include_dirs = safeList ((nix.cmake or {}).extra_include_dirs or []);
extra_link_libraries = safeList ((nix.cmake or {}).extra_link_libraries or []);
};
_raw = raw;
};
}