Skip to content

Commit

Permalink
main.nu: implement rereadme
Browse files Browse the repository at this point in the history
  • Loading branch information
colemickens committed Nov 1, 2022
1 parent 1d3b395 commit b21e696
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ These packages were mostly recently built (and cached) against:
| [wshowkeys](https://github.com/ammgws/wshowkeys) | Displays keys being pressed on a Wayland session |
| [wtype](https://github.com/atx/wtype) | xdotool type for wayland |
| [xdg-desktop-portal-wlr](https://github.com/emersion/xdg-desktop-portal-wlr) | xdg-desktop-portal backend for wlroots |
<!--pkgs-->
<!--end-pkgs-->

</details>

Expand Down
32 changes: 31 additions & 1 deletion main.nu
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,35 @@ def buildDrv [ drvRef: string ] {
$output
}

def "main rereadme" [] {
let packageNames = (nix eval --json $".#packages.($system)" --apply 'x: builtins.attrNames x' | str trim | from json)
let pkgList = ($packageNames | where ($it != "default"))
let rows = [
"| Package | Description |"
"| --- | --- |"
]
let pkgrows = ($pkgList | each { |packageName|
print -e $packageName
let meta = (do -c {
nix eval --json $".#packages.($system).($packageName).meta" | str trim | from json
})
let home = (if "homepage" in ($meta | transpose | get column0) {
$meta.homepage
} else { "__missing__" })
($"| [($packageName)]\(($home)\) | ($meta.description) |")
})
let tableText = ([ $rows $pkgrows ] | flatten | str join "\n")

print -e $tableText

^rg --multiline '(?s)(.*)<!--pkgs-->(.*)<!--end-pkgs-->(.*)' "README.md" --replace $"\$1($tableText)\$3" | save --raw README2.md
mv README2.md README.md

(do -c {
^git commit -m "auto-update: updated readme" "./README.md"
})
}

def "main build" [] {
buildDrv $"packages.($system)"
}
Expand All @@ -69,7 +98,8 @@ def "main update" [] {
./pkgs-update.nu
}
main build
^git commit -m "auto-update: updated readme"
main rereadme
^git push origin HEAD
})
}

Expand Down

0 comments on commit b21e696

Please sign in to comment.