mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-20 21:38:15 -04:00
refactor(nix): replace sync nix options with direct md generation to … (#1)
* refactor(nix): replace sync nix options with direct md generation to docs * fix(docs): add trailing comman in meta * fix(ci): sort nix options and fix default value check
This commit is contained in:
parent
0a687f808d
commit
c3ec4c6142
6 changed files with 139 additions and 61 deletions
58
.github/workflows/generate-nix-options-docs.yml
vendored
Normal file
58
.github/workflows/generate-nix-options-docs.yml
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
name: Generate Nix Options Docs
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'nix/**-modules.nix'
|
||||
- 'nix/generate-options.nix'
|
||||
- 'flake.nix'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'nix/**-modules.nix'
|
||||
|
||||
jobs:
|
||||
update-docs:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v30
|
||||
with:
|
||||
extra_nix_config: |
|
||||
experimental-features = nix-command flakes
|
||||
|
||||
- name: Build Options JSON
|
||||
run: |
|
||||
nix build .#nixos-options-json --out-link result-nixos
|
||||
nix build .#hm-options-json --out-link result-hm
|
||||
|
||||
- name: Format to Markdown
|
||||
run: |
|
||||
OUTPUT_FILE="docs/nix-options.md"
|
||||
|
||||
cat << 'EOF' > $OUTPUT_FILE
|
||||
---
|
||||
title: Nix Module Options
|
||||
description: NixOS and Home Manager configuration options for mangowm.
|
||||
---
|
||||
|
||||
> **Note:** This document is automatically generated from the Nix module source code.
|
||||
|
||||
EOF
|
||||
|
||||
python3 ./.github/scripts/generate-nix-options-docs.py result-nixos/share/doc/nixos/options.json $OUTPUT_FILE "NixOS Module Options"
|
||||
python3 ./.github/scripts/generate-nix-options-docs.py result-hm/share/doc/nixos/options.json $OUTPUT_FILE "Home Manager Options"
|
||||
|
||||
- name: Auto-commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: "docs: auto-generate Nix module options"
|
||||
file_pattern: 'docs/*-options.md'
|
||||
branch: ${{ github.head_ref }}
|
||||
59
.github/workflows/sync-nix-options.yml
vendored
59
.github/workflows/sync-nix-options.yml
vendored
|
|
@ -1,59 +0,0 @@
|
|||
name: Sync Nix module options
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- nix/hm-modules.nix
|
||||
- nix/nixos-modules.nix
|
||||
- nix/generate-options.nix
|
||||
- flake.nix
|
||||
- flake.lock
|
||||
|
||||
concurrency:
|
||||
group: sync-nix-options
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
sync-nix-options:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- uses: cachix/install-nix-action@v30
|
||||
with:
|
||||
extra_nix_config: |
|
||||
experimental-features = nix-command flakes
|
||||
|
||||
- name: Build options JSONs
|
||||
run: |
|
||||
HM_OUT=$(nix build .#hm-options-json --no-link --print-out-paths)
|
||||
NIXOS_OUT=$(nix build .#nixos-options-json --no-link --print-out-paths)
|
||||
cp "$HM_OUT/share/doc/nixos/options.json" /tmp/hm-options.json
|
||||
cp "$NIXOS_OUT/share/doc/nixos/options.json" /tmp/nixos-options.json
|
||||
|
||||
- name: Checkout website
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: mangowm/mangowm.github.io
|
||||
path: website
|
||||
token: ${{ secrets.WEBSITE_SYNC_TOKEN }}
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Copy JSONs to website
|
||||
run: |
|
||||
cp /tmp/hm-options.json website/apps/web/src/hm-options.json
|
||||
cp /tmp/nixos-options.json website/apps/web/src/nixos-options.json
|
||||
|
||||
- name: Commit and push
|
||||
working-directory: website
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add apps/web/src/hm-options.json apps/web/src/nixos-options.json
|
||||
git diff --staged --quiet || git commit \
|
||||
-m "nix: update module options JSON" \
|
||||
-m "${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}"
|
||||
git push
|
||||
Loading…
Add table
Add a link
Reference in a new issue