summaryrefslogtreecommitdiff
path: root/ci/eval/attrpaths.nix
blob: ff1bdabbb35051aa7dcc6a5ab8b05b3ed697c10e (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
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
75
76
77
78
79
80
81
82
83
84
85
# This expression will, as efficiently as possible, dump a
# *superset* of all attrpaths of derivations which might be
# part of a release on *any* platform.
#
# This expression runs single-threaded under all current Nix
# implementations, but much faster and with much less memory
# used than ./outpaths.nix itself.
#
# Once you have the list of attrnames you can split it up into
# $NUM_CORES batches and evaluate the outpaths separately for each
# batch, in parallel.
#
# To dump the attrnames:
#
#   nix-instantiate --eval --strict --json ci/eval/attrpaths.nix -A names
#
{
  lib ? import (path + "/lib"),
  trace ? false,
  path ? ./../..,
  extraNixpkgsConfigJson ? "{}",
}:
let

  # TODO: Use mapAttrsToListRecursiveCond when this PR lands:
  # https://github.com/NixOS/nixpkgs/pull/395160
  justAttrNames =
    path: value:
    let
      result =
        if path == [ "AAAAAASomeThingsFailToEvaluate" ] || !(lib.isAttrs value) then
          [ ]
        else if lib.isDerivation value then
          [ path ]
        else
          lib.pipe value [
            (lib.mapAttrsToList (
              name: value:
              lib.addErrorContext "while evaluating package set attribute path '${
                lib.showAttrPath (path ++ [ name ])
              }'" (justAttrNames (path ++ [ name ]) value)
            ))
            lib.concatLists
          ];
    in
    lib.traceIf trace "** ${lib.showAttrPath path}" result;

  outpaths = import ./outpaths.nix {
    inherit path;
    extraNixpkgsConfig = builtins.fromJSON extraNixpkgsConfigJson;
    attrNamesOnly = true;
  };

  paths = [
    # Some of the following are based on variants, which are disabled with `attrNamesOnly = true`.
    # Until these have been removed from release.nix / hydra, we manually add them to the list.
    [
      "pkgsLLVM"
      "stdenv"
    ]
    [
      "pkgsArocc"
      "stdenv"
    ]
    [
      "pkgsZig"
      "stdenv"
    ]
    [
      "pkgsStatic"
      "stdenv"
    ]
    [
      "pkgsMusl"
      "stdenv"
    ]
  ]
  ++ justAttrNames [ ] outpaths;

  names = map lib.showAttrPath paths;

in
{
  inherit paths names;
}