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
72
73
74
{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

  outputs =
    { self, nixpkgs, ... }:
    let

      pkgs = nixpkgs.legacyPackages.x86_64-linux;

      mkDrvWithConstituents =
        name: constituents:
        pkgs.runCommand name {
          _hydraAggregate = true;
          inherit constituents;
        } "touch $out";
    in
    {
      hydraJobs = import ./ci.nix { inherit pkgs; };

      legacyPackages.x86_64-linux = {
        brokenPkgs = {
          brokenPackage = throw "this is an evaluation error";
        };
        infiniteRecursionPkgs = {
          packageWithInfiniteRecursion =
            let
              recursion = [ recursion ];
            in
            derivation {
              inherit (pkgs.stdenv.hostPlatform) system;
              name = "drvB";
              recursiveAttr = recursion;
              builder = ":";
            };
        };
        constituents = {
          success = {
            indirect_aggregate = mkDrvWithConstituents "indirect_aggregate" [
              "anotherone"
            ];
            direct_aggregate = mkDrvWithConstituents "direct_aggregate" [
              self.hydraJobs.builtJob
            ];
            mixed_aggregate = mkDrvWithConstituents "mixed_aggregate" [
              self.hydraJobs.builtJob
              "anotherone"
            ];
            anotherone = pkgs.writeText "constituent" "text";
          };
          failures = {
            aggregate = mkDrvWithConstituents "aggregate" [
              "doesntexist"
              "doesnteval"
            ];
            doesnteval = pkgs.writeText "constituent" (toString { });
          };
          cycle = {
            aggregate0 = mkDrvWithConstituents "aggregate0" [
              "aggregate1"
            ];
            aggregate1 = mkDrvWithConstituents "aggregate1" [
              "aggregate0"
            ];
          };
          transitive = {
            constituent = pkgs.hello;
            # also flip the order to make sure the toposort works as intended.
            aggregate1 = mkDrvWithConstituents "aggregate1" [ "constituent" ];
            aggregate0 = mkDrvWithConstituents "aggregate0" [ "aggregate1" ];
          };
        };
      };
    };
}