1# to run these tests (and the others)
2# nix-build nixpkgs/lib/tests/release.nix
3{ # The pkgs used for dependencies for the testing itself
4 pkgs ? import ../.. {}
5, lib ? pkgs.lib
6}:
7
8let
9 checkMaintainer = handle: uncheckedAttrs:
10 let
11 prefix = [ "lib" "maintainers" handle ];
12 checkedAttrs = (lib.modules.evalModules {
13 inherit prefix;
14 modules = [
15 ./maintainer-module.nix
16 {
17 _file = toString ../../maintainers/maintainer-list.nix;
18 config = uncheckedAttrs;
19 }
20 ];
21 }).config;
22
23 checkGithubId = lib.optional (checkedAttrs.github != null && checkedAttrs.githubId == null) ''
24 echo ${lib.escapeShellArg (lib.showOption prefix)}': If `github` is specified, `githubId` must be too.'
25 # Calling this too often would hit non-authenticated API limits, but this
26 # shouldn't happen since such errors will get fixed rather quickly
27 info=$(curl -sS https://api.github.com/users/${checkedAttrs.github})
28 id=$(jq -r '.id' <<< "$info")
29 echo "The GitHub ID for GitHub user ${checkedAttrs.github} is $id:"
30 echo -e " githubId = $id;\n"
31 '';
32 in lib.deepSeq checkedAttrs checkGithubId;
33
34 missingGithubIds = lib.concatLists (lib.mapAttrsToList checkMaintainer lib.maintainers);
35
36 success = pkgs.runCommand "checked-maintainers-success" {} ">$out";
37
38 failure = pkgs.runCommand "checked-maintainers-failure" {
39 nativeBuildInputs = [ pkgs.curl pkgs.jq ];
40 outputHash = "sha256:${lib.fakeSha256}";
41 outputHAlgo = "sha256";
42 outputHashMode = "flat";
43 SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
44 } ''
45 ${lib.concatStringsSep "\n" missingGithubIds}
46 exit 1
47 '';
48in if missingGithubIds == [] then success else failure