Skip to content

Commit 2a57eba

Browse files
committed
lib.teams: Populate fields from synced GitHub state
The before and after of nix-instantiate --eval -A lib.teams --strict --json | jq 'walk(if type == "array" then sort else . end)' has been ensured to be negligible, only consisting of minor team shortName and scope differences (cherry picked from commit 428bd8f)
1 parent 5098220 commit 2a57eba

5 files changed

Lines changed: 52 additions & 313 deletions

File tree

ci/OWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
/lib/path/* @infinisil @hsjobeki
3434
/lib/fileset @infinisil @hsjobeki
3535
/maintainers/github-teams.json @infinisil
36+
/maintainers/computed-team-list.nix @infinisil
3637
## Standard environment–related libraries
3738
/lib/customisation.nix @alyssais @NixOS/stdenv
3839
/lib/derivations.nix @alyssais @NixOS/stdenv

lib/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ let
6363
customisation = callLibs ./customisation.nix;
6464
derivations = callLibs ./derivations.nix;
6565
maintainers = import ../maintainers/maintainer-list.nix;
66-
teams = callLibs ../maintainers/team-list.nix;
66+
teams = callLibs ../maintainers/computed-team-list.nix;
6767
meta = callLibs ./meta.nix;
6868
versions = callLibs ./versions.nix;
6969

maintainers/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ team after giving the existing members a few days to respond.
164164
*Important:* If a team says it is a closed group, do not merge additions
165165
to the team without an approval by at least one existing member.
166166

167-
168167
# Maintainer scripts
169168

170169
Various utility scripts, which are mainly useful for nixpkgs maintainers,

maintainers/computed-team-list.nix

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Extends ./team-list.nix with synced GitHub information from ./github-teams.json
2+
{ lib }:
3+
let
4+
githubTeams = lib.importJSON ./github-teams.json;
5+
teams = import ./team-list.nix { inherit lib; };
6+
7+
# A fast maintainer id lookup table
8+
maintainersById = lib.pipe lib.maintainers [
9+
lib.attrValues
10+
(lib.groupBy (attrs: toString attrs.githubId))
11+
(lib.mapAttrs (_: lib.head))
12+
];
13+
14+
maintainerSetToList =
15+
githubTeam:
16+
lib.mapAttrsToList (
17+
login: id:
18+
maintainersById.${toString id}
19+
or (throw "lib.teams: No maintainer entry for GitHub user @${login} who's part of the @NixOS/${githubTeam} team")
20+
);
21+
22+
in
23+
lib.mapAttrs (
24+
name: attrs:
25+
if attrs ? github then
26+
let
27+
githubTeam =
28+
githubTeams.${attrs.github}
29+
or (throw "lib.teams.${name}: Corresponding GitHub team ${attrs.github} not known yet, make sure to create it and wait for the regular team sync");
30+
in
31+
assert lib.assertMsg (!attrs ? shortName)
32+
"lib.teams.${name}: Both `shortName` and `github` is set, but the former is synced from the latter";
33+
assert lib.assertMsg (
34+
!attrs ? scope
35+
) "lib.teams.${name}: Both `scope` and `github` is set, but the former is synced from the latter";
36+
assert lib.assertMsg (
37+
!attrs ? members
38+
) "lib.teams.${name}: Both `members` and `github` is set, but the former is synced from the latter";
39+
attrs
40+
// {
41+
shortName = githubTeam.name;
42+
scope = githubTeam.description;
43+
members =
44+
maintainerSetToList attrs.github githubTeam.maintainers
45+
++ maintainerSetToList attrs.github githubTeam.members;
46+
}
47+
else
48+
attrs
49+
) teams

0 commit comments

Comments
 (0)