1 # This expression will, as efficiently as possible, dump a
2 # *superset* of all attrpaths of derivations which might be
3 # part of a release on *any* platform.
5 # Both this expression and what ofborg uses (release-outpaths.nix)
6 # are essentially single-threaded (under the current cppnix
9 # This expression runs much, much, much faster and uses much, much
10 # less memory than the ofborg script by skipping the
11 # platform-relevance checks. The ofborg outpaths.nix script takes
12 # half an hour on a 3ghz core and peaks at 60gbytes of memory; this
13 # expression runs on the same machine in 44 seconds with peak memory
16 # Once you have the list of attrnames you can split it up into
17 # $NUM_CORES batches and run the platform checks separately for each
20 # To dump the attrnames:
22 # nix-instantiate --eval --strict --json pkgs/top-level/release-attrpaths-superset.nix -A names
24 { lib ? import (path + "/lib")
26 , enableWarnings ? true
32 # No release package attrpath may have any of these attrnames as
33 # its initial component.
35 # If you can find a way to remove any of these entries without
36 # causing CI to fail, please do so.
38 excluded-toplevel-attrs = {
40 __splicedPackages = true;
41 pkgsBuildBuild = true;
43 pkgsBuildTarget = true;
45 pkgsHostTarget = true;
46 pkgsTargetTarget = true;
48 targetPackages = true;
55 pkgsx86_64Darwin = true;
58 pkgsExtraHardening = true;
61 # No release package attrname may have any of these at a component
62 # anywhere in its attrpath. These are the names of gigantic
63 # top-level attrsets that have leaked into so many sub-packagesets
64 # that it's easier to simply exclude them entirely.
66 # If you can find a way to remove any of these entries without
67 # causing CI to fail, please do so.
69 excluded-attrnames-at-any-depth = {
73 __functionArgs = true;
74 __splicedPackages = true;
80 overrideDerivation = true;
82 overrideScope' = true;
84 # Special case: lib/types.nix leaks into a lot of nixos-related
85 # derivations, and does not eval deeply.
89 # __attrsFailEvaluation is a temporary workaround to get top-level
90 # eval to succeed (under builtins.tryEval) for the entire
91 # packageset, without deep invasve changes into individual
94 # Now that CI has been added, ensuring that top-level eval will
95 # not be broken by any new commits, you should not add any new
96 # occurrences of __attrsFailEvaluation, and should remove them
97 # wherever you are able to (doing so will likely require deep
98 # adjustments within packages). Once all of the uses of
99 # __attrsFailEvaluation are removed, it will be deleted from the
100 # routine below. In the meantime,
102 # The intended semantics are that an attrpath rooted at pkgs is
103 # part of the (unfiltered) release jobset iff all of the following
106 # 1. The first component of the attrpath is not in
107 # `excluded-toplevel-attrs`
109 # 2. No attrname in the attrpath belongs to the list of forbidden
110 # attrnames `excluded-attrnames-at-any-depth`
112 # 3. The attrpath leads to a value for which lib.isDerivation is true
114 # 4. No proper prefix of the attrpath has __attrsFailEvaluation=true
116 # 5. Any proper prefix of the attrpath at which lib.isDerivation
117 # is true also has __recurseIntoDerivationForReleaseJobs=true.
119 # The last condition is unfortunately necessary because there are
120 # Hydra release jobnames which have proper prefixes which are
121 # attrnames of derivations (!). We should probably restructure
122 # the job tree so that this is not the case.
124 justAttrNames = path: value:
127 if lib.isDerivation value &&
128 # in some places we have *derivations* with jobsets as subattributes, ugh
129 !(value.__recurseIntoDerivationForReleaseJobs or false) then
132 # Even wackier case: we have meta.broken==true jobs with
133 # !meta.broken jobs as subattributes with license=unfree, and
134 # check-meta.nix won't throw an "unfree" failure because the
135 # enclosing derivation is marked broken. Yeah. Bonkers.
136 # We should just forbid jobsets enclosed by derivations.
137 else if lib.isDerivation value &&
138 !value.meta.available then []
140 else if !(lib.isAttrs value) then []
141 else if (value.__attrsFailEvaluation or false) then []
142 else lib.pipe value [
145 if excluded-attrnames-at-any-depth.${name} or false then [] else
146 (justAttrNames (path ++ [name]) value)))
151 seq = builtins.deepSeq attempt attempt;
152 tried = builtins.tryEval seq;
157 else if enableWarnings && path != [ "AAAAAASomeThingsFailToEvaluate" ]
158 then lib.warn "tryEval failed at: ${lib.concatStringsSep "." path}" []
163 else lib.trace "** ${lib.concatStringsSep "." path}" result;
165 unfiltered = import ./release-outpaths.nix {
167 attrNamesOnly = true;
171 filtered = lib.pipe unfiltered [
172 (pkgs: builtins.removeAttrs pkgs (builtins.attrNames excluded-toplevel-attrs))
177 # I am not entirely sure why these three packages end up in
178 # the Hydra jobset. But they do, and they don't meet the
179 # criteria above, so at the moment they are special-cased.
180 [ "pkgsLLVM" "stdenv" ]
181 [ "pkgsStatic" "stdenv" ]
182 [ "pkgsMusl" "stdenv" ]
183 ] ++ justAttrNames [] filtered;
186 map (path: (lib.concatStringsSep "." path)) paths;