1 # to run these tests (and the others)
2 # nix-build nixpkgs/lib/tests/release.nix
3 # These tests should stay in sync with the comment in maintainers/maintainers-list.nix
4 { # The pkgs used for dependencies for the testing itself
10 checkMaintainer = handle: uncheckedAttrs:
12 prefix = [ "lib" "maintainers" handle ];
13 checkedAttrs = (lib.modules.evalModules {
16 ./maintainer-module.nix
18 _file = toString ../../maintainers/maintainer-list.nix;
19 config = uncheckedAttrs;
24 checks = lib.optional (checkedAttrs.github != null && checkedAttrs.githubId == null) ''
25 echo ${lib.escapeShellArg (lib.showOption prefix)}': If `github` is specified, `githubId` must be too.'
26 # Calling this too often would hit non-authenticated API limits, but this
27 # shouldn't happen since such errors will get fixed rather quickly
28 info=$(curl -sS https://api.github.com/users/${checkedAttrs.github})
29 id=$(jq -r '.id' <<< "$info")
30 echo "The GitHub ID for GitHub user ${checkedAttrs.github} is $id:"
31 echo -e " githubId = $id;\n"
32 '' ++ lib.optional (checkedAttrs.email == null && checkedAttrs.github == null && checkedAttrs.matrix == null) ''
33 echo ${lib.escapeShellArg (lib.showOption prefix)}': At least one of `email`, `github` or `matrix` must be specified, so that users know how to reach you.'
34 '' ++ lib.optional (checkedAttrs.email != null && lib.hasSuffix "noreply.github.com" checkedAttrs.email) ''
35 echo ${lib.escapeShellArg (lib.showOption prefix)}': If an email address is given, it should allow people to reach you. If you do not want that, you can just provide `github` or `matrix` instead.'
37 in lib.deepSeq checkedAttrs checks;
39 missingGithubIds = lib.concatLists (lib.mapAttrsToList checkMaintainer lib.maintainers);
41 success = pkgs.runCommand "checked-maintainers-success" {} ">$out";
43 failure = pkgs.runCommand "checked-maintainers-failure" {
44 nativeBuildInputs = [ pkgs.curl pkgs.jq ];
45 outputHash = "sha256:${lib.fakeSha256}";
46 outputHAlgo = "sha256";
47 outputHashMode = "flat";
48 SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
50 ${lib.concatStringsSep "\n" missingGithubIds}
53 in if missingGithubIds == [] then success else failure