feat(gen-docs): write nix code outside script
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
5194199d25
commit
20e5b7dac4
5 changed files with 34 additions and 22 deletions
12
apps/gen-docs/getConfigMeta.nix
Normal file
12
apps/gen-docs/getConfigMeta.nix
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
configs: let
|
||||||
|
inherit (builtins) mapAttrs replaceStrings;
|
||||||
|
|
||||||
|
trimNewlines = s: replaceStrings ["\n"] [" "] s;
|
||||||
|
in {
|
||||||
|
attrs =
|
||||||
|
mapAttrs (_: v: {
|
||||||
|
roleDesc = trimNewlines (v.config.meta.roleDescription or "");
|
||||||
|
hwDesc = trimNewlines (v.config.meta.hardwareDescription or "");
|
||||||
|
})
|
||||||
|
configs;
|
||||||
|
}
|
13
apps/gen-docs/getPackageMeta.nix
Normal file
13
apps/gen-docs/getPackageMeta.nix
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
x: let
|
||||||
|
inherit (builtins) currentSystem mapAttrs removeAttrs replaceStrings;
|
||||||
|
|
||||||
|
trimNewlines = s: replaceStrings ["\n"] [" "] s;
|
||||||
|
packages = removeAttrs x.${currentSystem} ["default"];
|
||||||
|
in {
|
||||||
|
attrs =
|
||||||
|
mapAttrs (_: v: {
|
||||||
|
desc = trimNewlines (v.meta.description or "");
|
||||||
|
homepage = v.meta.homepage or "";
|
||||||
|
})
|
||||||
|
packages;
|
||||||
|
}
|
|
@ -1,29 +1,16 @@
|
||||||
getMetaFunc=$(cat << EOF
|
|
||||||
(x: {
|
|
||||||
attrs = builtins.mapAttrs (_: v: {
|
|
||||||
desc = builtins.replaceStrings ["\n"] [" "] (v.meta.description or "");
|
|
||||||
homepage = v.meta.homepage or "";
|
|
||||||
roleDesc = builtins.replaceStrings ["\n"] [" "] (v.config.meta.roleDescription or "");
|
|
||||||
hwDesc = builtins.replaceStrings ["\n"] [" "] (v.config.meta.hardwareDescription or "");
|
|
||||||
}) (builtins.removeAttrs (x.\${builtins.currentSystem} or x) ["default"]);
|
|
||||||
})
|
|
||||||
EOF
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
substitute() {
|
substitute() {
|
||||||
echo '' | pandoc --metadata-file <(
|
echo '' | pandoc --metadata-file <(
|
||||||
nix eval \
|
nix eval \
|
||||||
--impure \
|
--impure \
|
||||||
--json \
|
--json \
|
||||||
"$FLAKE"#"$1" \
|
"$FLAKE"#"$1" \
|
||||||
--apply "$getMetaFunc" |
|
--apply "import \"$FLAKE/apps/gen-docs/$3.nix\"" |
|
||||||
jq -r
|
jq -r
|
||||||
) -t markdown --template "$FLAKE/apps/gen-docs/templates/$2.md" -o "$FLAKE/$2/README.md"
|
) -t markdown --template "$FLAKE/apps/gen-docs/templates/$2.md" -o "$FLAKE/$2/README.md"
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: add homeManagerModules, lib, modules, nixFastChecks, overlays, scopedPackages
|
# TODO: add homeManagerModules, lib, modules, nixFastChecks, overlays, scopedPackages
|
||||||
substitute "appsPackages" "apps"
|
substitute "appsPackages" "apps" "getPackageMeta"
|
||||||
substitute "nixosConfigurations" "configurations"
|
substitute "nixosConfigurations" "configurations" "getConfigMeta"
|
||||||
substitute "devShells" "devShells"
|
substitute "devShells" "devShells" "getPackageMeta"
|
||||||
substitute "packages" "packages"
|
substitute "packages" "packages" "getPackageMeta"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
This directory contains 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.
|
unique to them.
|
||||||
|
|
||||||
## List of my Devices
|
## List of my devices
|
||||||
|
|
||||||
| Name | Model / Specs | Description |
|
| Name | Model / Specs | Description |
|
||||||
| --------- | ------------- | ------------------------------------------------------------------------------------------------ |
|
| --------- | ------------- | ------------------------------------------------------------------------------------------------ |
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
This directory contains 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.
|
unique to them.
|
||||||
|
|
||||||
## List of my Devices
|
## List of my devices
|
||||||
|
|
||||||
| Name | Model / Specs | Description |
|
| Name | Model / Specs | Description |
|
||||||
| --------- | ------------- | ------------------------------------------------------------------------------------------------ |
|
| --------- | ------------- | ------------------------------------------------------------------------------------------------ |
|
||||||
|
@ -14,6 +14,6 @@ unique to them.
|
||||||
| `live-image` | USB key | Basic configuration that serves as my custom ISO target |
|
| `live-image` | USB key | Basic configuration that serves as my custom ISO target |
|
||||||
| `nos` | NVIDIA 3060 with i5-3600 | Custom built NAS and seedbox for Linux ISOs ;) |
|
| `nos` | NVIDIA 3060 with i5-3600 | Custom built NAS and seedbox for Linux ISOs ;) |
|
||||||
| `servivi` | Headless Ryzen 5 3600 | Gaming PC in a previous life, it is now used as a build farm and hosts game servers |
|
| `servivi` | Headless Ryzen 5 3600 | Gaming PC in a previous life, it is now used as a build farm and hosts game servers |
|
||||||
| `thingone` | Lenovo ThinkCentre M900 | Mini PC that makes use of [NixOS-pcsd](https://github.com/matt1432/nixos-pcsd) to form a cluster with its twin |
|
| `thingone` | Lenovo ThinkCentre M900 | Mini PC that makes use of [NixOS-pcsd](https://github.com/matt1432/nixos-pcsd) to form a cluster with its twin. Files located in `cluster` |
|
||||||
| `thingtwo` | Lenovo ThinkCentre M900 | Mini PC that makes use of [NixOS-pcsd](https://github.com/matt1432/nixos-pcsd) to form a cluster with its twin |
|
| `thingtwo` | Lenovo ThinkCentre M900 | Mini PC that makes use of [NixOS-pcsd](https://github.com/matt1432/nixos-pcsd) to form a cluster with its twin. Files located in `cluster` |
|
||||||
| `wim` | ThinkPad L13 Yoga Gen 3 (Ryzen 7 PRO 5875U) | 2-1 Lenovo Laptop that I use for university |
|
| `wim` | ThinkPad L13 Yoga Gen 3 (Ryzen 7 PRO 5875U) | 2-1 Lenovo Laptop that I use for university |
|
||||||
|
|
Loading…
Reference in a new issue