1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p jq parallel
4 # Example how to work with the `lib.maintainers` attrset.
5 # Can be used to check whether all user handles are still valid.
7 set -o errexit
-o noclobber
-o nounset
-o pipefail
8 shopt -s failglob inherit_errexit
10 function checkCommits
{
11 local ret status tmp user
14 curl
--silent -w "%{http_code}" \
15 "https://github.com/NixOS/nixpkgs/commits?author=$user" \
17 # the last line of tmp contains the http status
18 status
=$
(tail -n1 "$tmp")
21 200) if <"$tmp" grep -i "no commits found" > /dev
/null
; then
27 # because of github’s hard request limits, this can take some time
33 *) printf "BAD STATUS: $(tail -n1 "$tmp") for %s\n" "$user"; ret
=1
40 export -f checkCommits
45 status
="$(curl --silent --head "https
://github.com
/${user}" | grep Status)"
46 # checks whether a user handle can be found on github
47 if [[ "$status" =~
404 ]]; then
48 printf "%s\t\t\t\t%s\n" "$status" "$user"
49 # checks whether the user handle has any nixpkgs commits
50 elif checkCommits
"$user"; then
51 printf "OK!\t\t\t\t%s\n" "$user"
53 printf "No Commits!\t\t\t%s\n" "$user"
58 # output the maintainers set as json
59 # and filter out the github username of each maintainer (if it exists)
60 # then check some at the same time
61 nix-instantiate
-A lib.maintainers
--eval --strict --json \
62 | jq
-r '.[]|.github|select(.)' \
63 | parallel
-j5 checkUser
65 # To check some arbitrary users:
66 # parallel -j100 checkUser ::: "eelco" "profpatsch" "Profpatsch" "a"