Skip to content

feat(overlay): add

feat(overlay): add #4

Workflow file for this run

name: Update docs
on:
push:
branches: [main]
paths:
- 'pkgs/**'
- 'modules/**'
- 'flake.nix'
- 'flake.lock'
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
update-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- name: Generate package and module tables
run: |
set -euo pipefail
# --- Packages ---
pkg_json=$(nix eval .#packages.x86_64-linux \
--apply 'pkgs: builtins.mapAttrs (name: pkg: pkg.version or "N/A") pkgs' \
--json)
pkg_table=$(echo "$pkg_json" | jq -r '
to_entries
| sort_by(.key)
| ["| Package | Version |", "|---|---|"]
+ map("| `\(.key)` | `\(.value)` |")
| .[]
')
# --- Modules ---
mod_table="| Module | Docs |"
mod_table+=$'\n'"|---|---|"
while IFS= read -r nix_file; do
# Derive the module attribute path from the file path
# e.g. modules/nixos/services/booklore/default.nix -> services.booklore
rel="${nix_file#modules/nixos/}"
dir="$(dirname "$rel")"
# For default.nix, use the parent directory path; for name.nix, append the name
basename="$(basename "$rel")"
if [ "$basename" = "default.nix" ]; then
mod_path="$dir"
else
mod_path="$dir/$(echo "$basename" | sed 's/\.nix$//')"
fi
# Convert slashes to dots for the attribute path
attr_path=$(echo "$mod_path" | tr '/' '.')
# Check if a README.md exists alongside the module
mod_dir="$(dirname "$nix_file")"
if [ -f "$mod_dir/README.md" ]; then
docs="[README]($mod_dir/README.md)"
else
docs="-"
fi
mod_table+=$'\n'"| \`$attr_path\` | $docs |"
done < <(find modules/nixos -name '*.nix' | sort)
# --- Patch README.md ---
# Replace content between markers
awk -v pkg="$pkg_table" -v mod="$mod_table" '
/<!-- BEGIN PACKAGES -->/ { print; print pkg; skip=1; next }
/<!-- END PACKAGES -->/ { skip=0 }
/<!-- BEGIN MODULES -->/ { print; print mod; skip=1; next }
/<!-- END MODULES -->/ { skip=0 }
!skip { print }
' README.md > README.md.tmp
mv README.md.tmp README.md
- name: Create pull request
uses: peter-evans/create-pull-request@v7
with:
commit-message: "docs: update package and module listings"
title: "docs: update package and module listings"
body: |
Automated update of README.md package and module tables.
This PR was generated by the `update-docs` workflow.
branch: docs/update-listings
delete-branch: true