docs: add script to generate some docs from nix attrs
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2025-01-20 11:06:01 -05:00
parent 5621df5749
commit a4c953df3b
7 changed files with 45 additions and 5 deletions

View file

@ -7,14 +7,20 @@
buildApp = attrs: (pkgs.callPackage ./buildApp.nix ({} // inputs // attrs));
mkApp = file: {
mkNodeApp = file: {
program = getExe (pkgs.callPackage file ({inherit buildApp;} // inputs));
type = "app";
};
mkApps = apps: listToAttrs (map (x: nameValuePair x (mkApp ./${x})) apps);
mkNodeApps = apps: listToAttrs (map (x: nameValuePair x (mkNodeApp ./${x})) apps);
in
mkApps [
mkNodeApps [
"extract-subs"
"update-sources"
]
// {
gen-docs = {
program = getExe (pkgs.callPackage ./gen-docs {});
type = "app";
};
}

10
apps/gen-docs/default.nix Normal file
View file

@ -0,0 +1,10 @@
{
writeShellApplication,
pandoc,
...
}:
writeShellApplication {
name = "gen-docs";
runtimeInputs = [pandoc];
text = builtins.readFile ./script.sh;
}

12
apps/gen-docs/script.sh Executable file
View file

@ -0,0 +1,12 @@
substitute() {
echo '' | pandoc --metadata-file <(
nix eval \
--impure \
--json \
.#"$1" \
--apply "(x: {attrs = builtins.mapAttrs (_: v: v.meta.description or \"\") x.\${builtins.currentSystem};})" |
jq -r
) -t markdown --template "$2" -o "$3"
}
substitute "devShells" "./templates/devShells.md" "$FLAKE/devShells/README.md"

View file

@ -0,0 +1,11 @@
# devShells
This directory contains every derivations for devShells exposed by this flake.
## List of my devShells found in `self.devShells`
| Name | Description |
| ---- | ----------- |
$for(attrs/pairs)$
| $it.key$ | $it.value$ |
$endfor$

View file

@ -1,6 +1,6 @@
# nixosConfigurations
This directory keeps every device's main configuration file, their `hardware-configuration.nix` and some custom modules
This directory contains every device's main configuration file, their `hardware-configuration.nix` and some custom modules
unique to them.
## List of my Devices

View file

@ -19,6 +19,7 @@
text = ''
# this command might fail but still updates the main lockfile
npm update --package-lock-only || true
hash="$(prefetch-npm-deps ./package-lock.json)"
echo "$hash"

View file

@ -1,6 +1,6 @@
# Packages
This directory encompasses every derivations for packages exposed by my flake.
This directory contains every derivations for packages exposed by this flake.
## List of my packages found in `self.packages`