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;
81 overrideDerivation = true;
83 overrideScope' = true;
85 # Special case: lib/types.nix leaks into a lot of nixos-related
86 # derivations, and does not eval deeply.
90 # __attrsFailEvaluation is a temporary workaround to get top-level
91 # eval to succeed (under builtins.tryEval) for the entire
92 # packageset, without deep invasve changes into individual
95 # Now that CI has been added, ensuring that top-level eval will
96 # not be broken by any new commits, you should not add any new
97 # occurrences of __attrsFailEvaluation, and should remove them
98 # wherever you are able to (doing so will likely require deep
99 # adjustments within packages). Once all of the uses of
100 # __attrsFailEvaluation are removed, it will be deleted from the
101 # routine below. In the meantime,
103 # The intended semantics are that an attrpath rooted at pkgs is
104 # part of the (unfiltered) release jobset iff all of the following
107 # 1. The first component of the attrpath is not in
108 # `excluded-toplevel-attrs`
110 # 2. No attrname in the attrpath belongs to the list of forbidden
111 # attrnames `excluded-attrnames-at-any-depth`
113 # 3. The attrpath leads to a value for which lib.isDerivation is true
115 # 4. No proper prefix of the attrpath has __attrsFailEvaluation=true
117 # 5. Any proper prefix of the attrpath at which lib.isDerivation
118 # is true also has __recurseIntoDerivationForReleaseJobs=true.
120 # The last condition is unfortunately necessary because there are
121 # Hydra release jobnames which have proper prefixes which are
122 # attrnames of derivations (!). We should probably restructure
123 # the job tree so that this is not the case.
125 justAttrNames = path: value:
128 if lib.isDerivation value &&
129 # in some places we have *derivations* with jobsets as subattributes, ugh
130 !(value.__recurseIntoDerivationForReleaseJobs or false) then
133 # Even wackier case: we have meta.broken==true jobs with
134 # !meta.broken jobs as subattributes with license=unfree, and
135 # check-meta.nix won't throw an "unfree" failure because the
136 # enclosing derivation is marked broken. Yeah. Bonkers.
137 # We should just forbid jobsets enclosed by derivations.
138 else if lib.isDerivation value &&
139 !value.meta.available then []
141 else if !(lib.isAttrs value) then []
142 else if (value.__attrsFailEvaluation or false) then []
143 else lib.pipe value [
146 if excluded-attrnames-at-any-depth.${name} or false then [] else
147 (justAttrNames (path ++ [name]) value)))
152 seq = builtins.deepSeq attempt attempt;
153 tried = builtins.tryEval seq;
158 else if enableWarnings && path != [ "AAAAAASomeThingsFailToEvaluate" ]
159 then lib.warn "tryEval failed at: ${lib.concatStringsSep "." path}" []
164 else lib.trace "** ${lib.concatStringsSep "." path}" result;
166 unfiltered = import ./release-outpaths.nix {
168 attrNamesOnly = true;
172 filtered = lib.pipe unfiltered [
173 (pkgs: builtins.removeAttrs pkgs (builtins.attrNames excluded-toplevel-attrs))
178 # I am not entirely sure why these three packages end up in
179 # the Hydra jobset. But they do, and they don't meet the
180 # criteria above, so at the moment they are special-cased.
181 [ "pkgsLLVM" "stdenv" ]
182 [ "pkgsStatic" "stdenv" ]
183 [ "pkgsMusl" "stdenv" ]
184 ] ++ justAttrNames [] filtered;
187 map (path: (lib.concatStringsSep "." path)) paths;