ClanModules: Add docs and api to retrieve metadata
This commit is contained in:
@@ -212,6 +212,9 @@ builtins.deepSeq deprecationWarnings {
|
||||
inherit nixosConfigurations;
|
||||
|
||||
clanInternals = {
|
||||
inherit (clan-core) clanModules;
|
||||
source = "${clan-core}";
|
||||
|
||||
meta = mergedInventory.meta;
|
||||
inventory = mergedInventory;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
evalClanModules = import ./eval-clan-modules { inherit clan-core nixpkgs lib; };
|
||||
inventory = import ./inventory { inherit lib clan-core; };
|
||||
jsonschema = import ./jsonschema { inherit lib; };
|
||||
modules = import ./description.nix { inherit clan-core lib; };
|
||||
# TODO: migrate to also use toml frontmatter
|
||||
# modules = import ./description.nix { inherit clan-core lib; };
|
||||
buildClan = import ./build-clan { inherit clan-core lib nixpkgs; };
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
{ lib, clan-core, ... }:
|
||||
{ ... }:
|
||||
|
||||
rec {
|
||||
getReadme =
|
||||
modulename:
|
||||
let
|
||||
readme = "${clan-core}/clanModules/${modulename}/README.md";
|
||||
readmeContents =
|
||||
if (builtins.pathExists readme) then
|
||||
(builtins.readFile readme)
|
||||
else
|
||||
throw "No README.md found for module ${modulename}";
|
||||
in
|
||||
readmeContents;
|
||||
# getReadme =
|
||||
# modulename:
|
||||
# let
|
||||
# readme = "${clan-core}/clanModules/${modulename}/README.md";
|
||||
# readmeContents =
|
||||
# if (builtins.pathExists readme) then
|
||||
# (builtins.readFile readme)
|
||||
# else
|
||||
# throw "No README.md found for module ${modulename}";
|
||||
# in
|
||||
# readmeContents;
|
||||
|
||||
getShortDescription =
|
||||
modulename:
|
||||
let
|
||||
content = (getReadme modulename);
|
||||
parts = lib.splitString "---" content;
|
||||
description = builtins.head parts;
|
||||
number_of_newlines = builtins.length (lib.splitString "\n" description);
|
||||
in
|
||||
if (builtins.length parts) > 1 then
|
||||
if number_of_newlines > 4 then
|
||||
throw "Short description in README.md for module ${modulename} is too long. Max 3 newlines."
|
||||
else if number_of_newlines <= 1 then
|
||||
throw "Missing short description in README.md for module ${modulename}."
|
||||
else
|
||||
description
|
||||
else
|
||||
throw "Short description delimiter `---` not found in README.md for module ${modulename}";
|
||||
# getShortDescription =
|
||||
# modulename:
|
||||
# let
|
||||
# content = (getReadme modulename);
|
||||
# parts = lib.splitString "---" content;
|
||||
# description = builtins.head parts;
|
||||
# number_of_newlines = builtins.length (lib.splitString "\n" description);
|
||||
# in
|
||||
# if (builtins.length parts) > 1 then
|
||||
# if number_of_newlines > 4 then
|
||||
# throw "Short description in README.md for module ${modulename} is too long. Max 3 newlines."
|
||||
# else if number_of_newlines <= 1 then
|
||||
# throw "Missing short description in README.md for module ${modulename}."
|
||||
# else
|
||||
# description
|
||||
# else
|
||||
# throw "Short description delimiter `---` not found in README.md for module ${modulename}";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user