about summary refs log tree commit diff
path: root/maintainers/scripts/check-hydra-by-maintainer.nix
blob: c40729a3974ed5afeb570e2eaa6f4209a16a7252 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{ maintainer }:
let
  pkgs = import ./../../default.nix {
    config.allowAliases = false;
  };
  inherit (pkgs) lib;
  maintainer_ = pkgs.lib.maintainers.${maintainer};
  packagesWith = cond: return: prefix: set:
    (lib.flatten
      (lib.mapAttrsToList
        (name: pkg:
          let
            result = builtins.tryEval
              (
                if lib.isDerivation pkg && cond name pkg then
                # Skip packages whose closure fails on evaluation.
                # This happens for pkgs like `python27Packages.djangoql`
                # that have disabled Python pkgs as dependencies.
                  builtins.seq pkg.outPath
                    [ (return "${prefix}${name}") ]
                else if pkg.recurseForDerivations or false || pkg.recurseForRelease or false
                # then packagesWith cond return pkg
                then packagesWith cond return "${name}." pkg
                else [ ]
              );
          in
          if result.success then result.value
          else [ ]
        )
        set
      )
    );

  packages = packagesWith
    (name: pkg:
      (
        if builtins.hasAttr "meta" pkg && builtins.hasAttr "maintainers" pkg.meta
        then
          (
            if builtins.isList pkg.meta.maintainers
            then builtins.elem maintainer_ pkg.meta.maintainers
            else maintainer_ == pkg.meta.maintainers
          )
        else false
      )
    )
    (name: name)
    ""
    pkgs;

in
pkgs.stdenv.mkDerivation {
  name = "nixpkgs-update-script";
  buildInputs = [ pkgs.hydra-check ];
  buildCommand = ''
    echo ""
    echo "----------------------------------------------------------------"
    echo ""
    echo "nix-shell maintainers/scripts/check-hydra-by-maintainer.nix --argstr maintainer SuperSandro2000"
    echo ""
    echo "----------------------------------------------------------------"
    exit 1
  '';
  shellHook = ''
    unset shellHook # do not contaminate nested shells
    echo "Please stand by"
    echo nix-shell -p hydra-check --run "hydra-check ${builtins.concatStringsSep " " packages}"
    nix-shell -p hydra-check --run "hydra-check ${builtins.concatStringsSep " " packages}"
    exit $?
  '';
}