{ writeShellScriptBin, jq, }: writeShellScriptBin "homelab-docs-nodes" '' #!/usr/bin/env bash set -euo pipefail cat << EOF # Node Configurations > Detailed per-node configuration > > Generated on: $(date -R) EOF # Get all node information node_info=$(colmena eval -E '{ nodes, pkgs, lib, ... }: lib.mapAttrs (name: node: { # Basic system info nixosVersion = node.config.system.nixos.version; hostName = node.config.networking.hostName; system = node.config.nixpkgs.system; # Homelab config (safe extraction) homelab = if (node.config.homelab.enable or false) then { enabled = true; hostname = node.config.homelab.hostname or null; domain = node.config.homelab.domain or null; externalDomain = node.config.homelab.externalDomain or null; environment = node.config.homelab.environment or null; location = node.config.homelab.location or null; tags = node.config.homelab.tags or []; } else { enabled = false; }; # Services (safe extraction) services = if (node.config.homelab.enable or false) then lib.mapAttrs (svcName: svc: { enabled = svc.enable or false; port = svc.port or null; description = svc.description or svcName; tags = svc.tags or []; }) (node.config.homelab.services or {}) else {}; }) nodes') echo "$node_info" | ${jq}/bin/jq -r 'to_entries[] | .key' | while read -r node; do echo "## Node: $node" echo # Basic system information echo "### System Information" echo nixos_version=$(echo "$node_info" | ${jq}/bin/jq -r ".[\"$node\"].nixosVersion") hostname=$(echo "$node_info" | ${jq}/bin/jq -r ".[\"$node\"].hostName") system=$(echo "$node_info" | ${jq}/bin/jq -r ".[\"$node\"].system") echo "| Property | Value |" echo "|----------|-------|" echo "| NixOS Version | \`$nixos_version\` |" echo "| Hostname | \`$hostname\` |" echo "| System | \`$system\` |" echo # Homelab configuration homelab_enabled=$(echo "$node_info" | ${jq}/bin/jq -r ".[\"$node\"].homelab.enabled") if [[ "$homelab_enabled" == "true" ]]; then echo "### Homelab Configuration" echo hl_hostname=$(echo "$node_info" | ${jq}/bin/jq -r ".[\"$node\"].homelab.hostname // \"N/A\"") hl_domain=$(echo "$node_info" | ${jq}/bin/jq -r ".[\"$node\"].homelab.domain // \"N/A\"") hl_external=$(echo "$node_info" | ${jq}/bin/jq -r ".[\"$node\"].homelab.externalDomain // \"N/A\"") hl_env=$(echo "$node_info" | ${jq}/bin/jq -r ".[\"$node\"].homelab.environment // \"N/A\"") hl_location=$(echo "$node_info" | ${jq}/bin/jq -r ".[\"$node\"].homelab.location // \"N/A\"") hl_tags=$(echo "$node_info" | ${jq}/bin/jq -r ".[\"$node\"].homelab.tags | join(\", \")") echo "| Property | Value |" echo "|----------|-------|" echo "| Homelab Hostname | \`$hl_hostname\` |" echo "| Domain | \`$hl_domain\` |" echo "| External Domain | \`$hl_external\` |" echo "| Environment | \`$hl_env\` |" echo "| Location | \`$hl_location\` |" echo "| Tags | $hl_tags |" echo # Services echo "### Services" echo services_data=$(echo "$node_info" | ${jq}/bin/jq -r ".[\"$node\"].services") service_count=$(echo "$services_data" | ${jq}/bin/jq 'length') if [[ "$service_count" -gt 0 ]]; then echo "| Service | Enabled | Port | Description | Tags |" echo "|---------|---------|------|-------------|------|" echo "$services_data" | ${jq}/bin/jq -r 'to_entries[] | [.key, (.value.enabled | tostring), (.value.port // "N/A" | tostring), (.value.description // "N/A"), (.value.tags | join(", "))] | @tsv' | while IFS=$'\t' read -r service enabled port description tags; do enabled_icon=$(if [[ "$enabled" == "true" ]]; then echo "✅"; else echo "❌"; fi) echo "| \`$service\` | $enabled_icon | $port | $description | $tags |" done else echo "No services configured." fi else echo "### Homelab Configuration" echo echo "❌ Homelab is not enabled on this node." fi echo echo "---" echo done ''