lol

maintainers-list.nix: Document (current) invitation process, add get-maintainer.sh (#267084)

* maintainer-list: Document automatic invites to @NixOS/nixpkgs-maintainers

* maintainers/scripts: Add `get-maintainer.sh`

Supports querying `maintainers-list.nix` by Nix attribute,
email address, github name or id, matrix account, or name.

* maintainers/scripts/get-maintainer.sh: More verbose help message

* maintainers/scripts/get-maintainer.sh: Fix (some) `shellcheck` lints

* maintainers/scripts: Add README

* maintainers/scripts/get-maintainer.sh: Put inline documentation at the top of the file

* maintainers/scripts: Document this is not a stable interfact to nixpkgs

Co-authored-by: Silvan Mosberger <github@infinisil.com>

* scripts/README: Add example for `get-maintainer.sh`

---------

Co-authored-by: Silvan Mosberger <github@infinisil.com>

authored by

nicoo
Silvan Mosberger
and committed by
GitHub
1d7f1465 09dc0405

+142 -2
+7
maintainers/README.md
··· 165 165 166 166 *Important:* If a team says it is a closed group, do not merge additions 167 167 to the team without an approval by at least one existing member. 168 + 169 + 170 + # Maintainer scripts 171 + 172 + Various utility scripts, which are mainly useful for nixpkgs maintainers, 173 + are available under `./scripts/`. See its [README](./scripts/README.md) 174 + for further information.
+4 -2
maintainers/maintainer-list.nix
··· 26 26 - `githubId` is your GitHub user ID, which can be found at `https://api.github.com/users/<userhandle>`, 27 27 - `keys` is a list of your PGP/GPG key fingerprints. 28 28 29 - Specifying a GitHub account ensures that you automatically get a review request on 30 - pull requests that modify a package for which you are a maintainer. 29 + Specifying a GitHub account ensures that you automatically: 30 + - get invited to the @NixOS/nixpkgs-maintainers team ; 31 + - once you are part of the @NixOS org, OfBorg will request you review 32 + pull requests that modify a package for which you are a maintainer. 31 33 32 34 `handle == github` is strongly preferred whenever `github` is an acceptable attribute name and is short and convenient. 33 35
+58
maintainers/scripts/README.md
··· 1 + # Maintainer scripts 2 + 3 + This folder contains various executable scripts for nixpkgs maintainers, 4 + and supporting data or nixlang files as needed. 5 + These scripts generally aren't a stable interface and may changed or be removed. 6 + 7 + What follows is a (very incomplete) overview of available scripts. 8 + 9 + 10 + ## Metadata 11 + 12 + ### `get-maintainer.sh` 13 + 14 + `get-maintainer.sh [selector] value` returns a JSON object describing 15 + a given nixpkgs maintainer, equivalent to `lib.maintainers.${x} // { handle = x; }`. 16 + 17 + This allows looking up a maintainer's attrset (including GitHub and Matrix 18 + handles, email address etc.) based on any of their handles, more correctly and 19 + robustly than text search through `maintainers-list.nix`. 20 + 21 + ``` 22 + ❯ ./get-maintainer.sh nicoo 23 + { 24 + "email": "nicoo@debian.org", 25 + "github": "nbraud", 26 + "githubId": 1155801, 27 + "keys": [ 28 + { 29 + "fingerprint": "E44E 9EA5 4B8E 256A FB73 49D3 EC9D 3708 72BC 7A8C" 30 + } 31 + ], 32 + "name": "nicoo", 33 + "handle": "nicoo" 34 + } 35 + 36 + ❯ ./get-maintainer.sh name 'Silvan Mosberger' 37 + { 38 + "email": "contact@infinisil.com", 39 + "github": "infinisil", 40 + "githubId": 20525370, 41 + "keys": [ 42 + { 43 + "fingerprint": "6C2B 55D4 4E04 8266 6B7D DA1A 422E 9EDA E015 7170" 44 + } 45 + ], 46 + "matrix": "@infinisil:matrix.org", 47 + "name": "Silvan Mosberger", 48 + "handle": "infinisil" 49 + } 50 + ``` 51 + 52 + The maintainer is designated by a `selector` which must be one of: 53 + - `handle` (default): the maintainer's attribute name in `lib.maintainers`; 54 + - `email`, `name`, `github`, `githubId`, `matrix`, `name`: 55 + attributes of the maintainer's object, matched exactly; 56 + see [`maintainer-list.nix`] for the fields' definition. 57 + 58 + [`maintainer-list.nix`]: ../maintainer-list.nix
+73
maintainers/scripts/get-maintainer.sh
··· 1 + #!/usr/bin/env nix-shell 2 + #!nix-shell -i bash -p jq ncurses 3 + # shellcheck shell=bash 4 + 5 + # Get a nixpkgs maintainer's metadata as a JSON object 6 + # see HELP_MESSAGE just below, or README.md. 7 + 8 + set -euo pipefail 9 + 10 + declare -A SELECTORS=( [handle]= [email]= [github]= [githubId]= [matrix]= [name]= ) 11 + HELP_MESSAGE="usage: '$0' [selector] value 12 + examples: 13 + get-maintainer.sh nicoo 14 + get-maintainer.sh githubId 1155801 15 + 16 + \`selector\` defaults to 'handle', can be one of: 17 + ${!SELECTORS[*]} 18 + " 19 + 20 + MAINTAINERS_DIR="$(dirname "$0")/.." 21 + 22 + die() { 23 + tput setaf 1 # red 24 + echo "'$0': $*" 25 + tput setaf 0 # back to black 26 + exit 1 27 + } 28 + 29 + listAsJSON() { 30 + nix-instantiate --eval --strict --json "${MAINTAINERS_DIR}/maintainer-list.nix" 31 + } 32 + 33 + parseArgs() { 34 + [ $# -gt 0 -a $# -lt 3 ] || { 35 + echo "$HELP_MESSAGE" 36 + die "invalid number of arguments (must be 1 or 2)" 37 + } 38 + 39 + if [ $# -eq 1 ]; then 40 + selector=handle 41 + else 42 + selector="$1" 43 + shift 44 + fi 45 + [ -z "${SELECTORS[$selector]-n}" ] || { 46 + echo "Valid selectors are:" "${!SELECTORS[@]}" >&2 47 + die "invalid selector '$selector'" 48 + } 49 + 50 + value="$1" 51 + shift 52 + } 53 + 54 + query() { 55 + # explode { a: A, b: B, ... } into A + {handle: a}, B + {handle: b}, ... 56 + local explode="to_entries[] | .value + { \"handle\": .key }" 57 + 58 + # select matching items from the list 59 + # TODO(nicoo): Support approximate matching for `name` ? 60 + local select 61 + case "$selector" in 62 + githubId) 63 + select="select(.${selector} == $value)" 64 + ;; 65 + *) 66 + select="select(.${selector} == \"$value\")" 67 + esac 68 + 69 + echo "$explode | $select" 70 + } 71 + 72 + parseArgs "$@" 73 + listAsJSON | jq -e "$(query)"