summaryrefslogtreecommitdiff
path: root/ci/eval/chunk.nix
blob: e1759c2c6615ff4c02b28717d7c18cf9089e4596 (about) (plain)
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
# This turns ./outpaths.nix into chunks of a fixed size.
{
  lib ? import ../../lib,
  path ? ../..,
  # The file containing all available attribute paths, which are split into chunks here
  attrpathFile,
  chunkSize,
  myChunk,
  includeBroken,
  systems,
  extraNixpkgsConfigJson,
}:

let
  attrpaths = lib.importJSON attrpathFile;
  myAttrpaths = lib.sublist (chunkSize * myChunk) chunkSize attrpaths;

  unfiltered = import ./outpaths.nix {
    inherit path;
    inherit includeBroken systems;
    extraNixpkgsConfig = builtins.fromJSON extraNixpkgsConfigJson;
  };

  # Turns the unfiltered recursive attribute set into one that is limited to myAttrpaths
  filtered =
    let
      recurse =
        index: paths: attrs:
        lib.mapAttrs (
          name: values:
          if attrs ? ${name} then
            if lib.any (value: lib.length value <= index + 1) values then
              attrs.${name}
            else
              recurse (index + 1) values attrs.${name}
              # Make sure nix-env recurses as well
              // {
                recurseForDerivations = true;
              }
          else
            null
        ) (lib.groupBy (a: lib.elemAt a index) paths);
    in
    recurse 0 myAttrpaths unfiltered;

in
filtered