···11+#!/usr/bin/env nix-shell
22+#!nix-shell -i bash -p jq parallel
33+44+# Example how to work with the `lib.maintainers` attrset.
55+# Can be used to check whether all user handles are still valid.
66+77+set -e
88+99+# nixpkgs='<nixpkgs>'
1010+# if [ -n "$1" ]; then
1111+1212+function checkCommits {
1313+ local user="$1"
1414+ local tmp=$(mktemp)
1515+ curl --silent -w "%{http_code}" \
1616+ "https://github.com/NixOS/nixpkgs/commits?author=$user" \
1717+ > "$tmp"
1818+ # the last line of tmp contains the http status
1919+ local status=$(tail -n1 "$tmp")
2020+ local ret=
2121+ case $status in
2222+ 200) if <"$tmp" grep -i "no commits found" > /dev/null; then
2323+ ret=1
2424+ else
2525+ ret=0
2626+ fi
2727+ ;;
2828+ # because of github’s hard request limits, this can take some time
2929+ 429) sleep 2
3030+ printf "."
3131+ checkCommits "$user"
3232+ ret=$?
3333+ ;;
3434+ *) printf "BAD STATUS: $(tail -n1 $tmp) for %s\n" "$user"; ret=1
3535+ ret=1
3636+ ;;
3737+ esac
3838+ rm "$tmp"
3939+ return $ret
4040+}
4141+export -f checkCommits
4242+4343+function checkUser {
4444+ local user="$1"
4545+ local status=
4646+ status="$(curl --silent --head "https://github.com/${user}" | grep Status)"
4747+ # checks whether a user handle can be found on github
4848+ if [[ "$status" =~ 404 ]]; then
4949+ printf "%s\t\t\t\t%s\n" "$status" "$user"
5050+ # checks whether the user handle has any nixpkgs commits
5151+ elif checkCommits "$user"; then
5252+ printf "OK!\t\t\t\t%s\n" "$user"
5353+ else
5454+ printf "No Commits!\t\t\t%s\n" "$user"
5555+ fi
5656+}
5757+export -f checkUser
5858+5959+# output the maintainers set as json
6060+# and filter out the github username of each maintainer (if it exists)
6161+# then check some at the same time
6262+nix-instantiate -A lib.maintainers --eval --strict --json \
6363+ | jq -r '.[]|.github|select(.)' \
6464+ | parallel -j5 checkUser
6565+6666+# parallel -j100 checkUser ::: "eelco" "profpatsch" "Profpatsch" "a"