nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 maintainer, # --argstr
3 short ? false, # use --arg short true
4 extra ? "", # --argstr
5}:
6let
7 pkgs = import ./../../default.nix {
8 config.allowAliases = false;
9 };
10 inherit (pkgs) lib;
11 maintainer_ = pkgs.lib.maintainers.${maintainer};
12 packagesWith =
13 cond: return: prefix: set:
14 (lib.flatten (
15 lib.mapAttrsToList (
16 name: pkg:
17 let
18 result = builtins.tryEval (
19 if lib.isDerivation pkg && cond name pkg then
20 # Skip packages whose closure fails on evaluation.
21 # This happens for pkgs like `python27Packages.djangoql`
22 # that have disabled Python pkgs as dependencies.
23 builtins.seq pkg.outPath [ (return "${prefix}${name}") ]
24 else if
25 pkg.recurseForDerivations or false || pkg.recurseForRelease or false
26 # then packagesWith cond return pkg
27 then
28 packagesWith cond return "${name}." pkg
29 else
30 [ ]
31 );
32 in
33 if result.success then result.value else [ ]
34 ) set
35 ));
36
37 packages = builtins.trace "evaluating list of packages for maintainer: ${maintainer}" packagesWith (
38 name: pkg:
39 (
40 if builtins.hasAttr "meta" pkg && builtins.hasAttr "maintainers" pkg.meta then
41 (
42 if builtins.isList pkg.meta.maintainers then
43 builtins.elem maintainer_ pkg.meta.maintainers
44 else
45 maintainer_ == pkg.meta.maintainers
46 )
47 else
48 false
49 )
50 ) (name: name) "" pkgs;
51
52in
53pkgs.stdenvNoCC.mkDerivation {
54 name = "check-hydra-by-maintainer";
55 buildInputs = [ pkgs.hydra-check ];
56 buildCommand = ''
57 echo ""
58 echo "----------------------------------------------------------------"
59 echo ""
60 echo "nix-shell maintainers/scripts/check-hydra-by-maintainer.nix --argstr maintainer yourname"
61 echo ""
62 echo "nix-shell maintainers/scripts/check-hydra-by-maintainer.nix --argstr maintainer yourname --arg short true"
63 echo ""
64 echo "nix-shell maintainers/scripts/check-hydra-by-maintainer.nix --argstr maintainer yourname --argstr extra \"--json\""
65 echo ""
66 echo "----------------------------------------------------------------"
67 exit 1
68 '';
69 shellHook =
70 let
71 # trying to only add spaces as necessary for optional args
72 # with optStr don't need spaces between nix templating
73 optStr = cond: string: lib.optionalString cond "${string} ";
74 args = [
75 "hydra-check"
76 ]
77 ++ (lib.optional short "--short")
78 ++ (lib.optional (extra != "") extra)
79 ++ (map lib.escapeShellArg packages);
80 command = lib.concatStringsSep " " args;
81 in
82 ''
83 # if user presses ctrl-c during run
84 # pass on ctrl-c to fully quit rather than exiting to nix-shell
85 function ctrl_c() {
86 exit 130
87 }
88 trap ctrl_c INT
89 echo "Please stand by"
90 echo "${command}"
91 ${command}
92 exit $?
93 '';
94}