nixpkgs/lib/tests/teams.nix
Silvan Mosberger 7636389851 lib.teams: Add githubId from associated github teams
This will allow the code for https://github.com/NixOS/nixpkgs/issues/447514
to make sure that the right team is requested for review,
even if it has been renamed in the meantime.

While the matching is currently based on the teams slug/name and not the
id, renames won't cause problems with `lib.teams`, because CI would
error if there's no match. Changing this can be future work.
2025-10-28 00:01:51 +01:00

70 lines
1.5 KiB
Nix

# to run these tests:
# nix-build nixpkgs/lib/tests/teams.nix
# If it builds, all tests passed
{
pkgs ? import ../.. { },
lib ? pkgs.lib,
}:
let
inherit (lib) types;
teamModule =
{ config, ... }:
{
options = {
shortName = lib.mkOption {
type = types.str;
};
scope = lib.mkOption {
type = types.str;
};
enableFeatureFreezePing = lib.mkOption {
type = types.bool;
default = false;
};
members = lib.mkOption {
type = types.listOf (types.submodule ./maintainer-module.nix);
default = [ ];
};
github = lib.mkOption {
type = types.str;
default = "";
};
githubId = lib.mkOption {
type = types.int;
default = 0;
};
githubMaintainers = lib.mkOption {
type = types.listOf (types.submodule ./maintainer-module.nix);
default = [ ];
};
};
};
checkTeam =
team: uncheckedAttrs:
let
prefix = [
"lib"
"maintainer-team"
team
];
checkedAttrs =
(lib.modules.evalModules {
inherit prefix;
modules = [
teamModule
{
_file = toString ../../maintainers/team-list.nix;
config = uncheckedAttrs;
}
];
}).config;
in
checkedAttrs;
checkedTeams = lib.mapAttrs checkTeam lib.teams;
in
pkgs.writeTextDir "maintainer-teams.json" (builtins.toJSON checkedTeams)