fork
Configure Feed
Select the types of activity you want to include in your feed.
nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
fork
Configure Feed
Select the types of activity you want to include in your feed.
1/*
2 This file composes a single bootstrapping stage of the Nix Packages
3 collection. That is, it imports the functions that build the various
4 packages, and calls them with appropriate arguments. The result is a set of
5 all the packages in the Nix Packages collection for some particular platform
6 for some particular stage.
7
8 Default arguments are only provided for bootstrapping
9 arguments. Normal users should not import this directly but instead
10 import `pkgs/default.nix` or `default.nix`.
11*/
12
13let
14 # An overlay to auto-call packages in ../by-name.
15 # By defining it at the top of the file,
16 # this value gets reused even if this file is imported multiple times,
17 # thanks to Nix's import-value cache.
18 autoCalledPackages = import ./by-name-overlay.nix ../by-name;
19in
20
21{
22 ## Misc parameters kept the same for all stages
23 ##
24
25 # Utility functions, could just import but passing in for efficiency
26 lib,
27
28 # Use to reevaluate Nixpkgs
29 nixpkgsFun,
30
31 ## Other parameters
32 ##
33
34 # Either null or an object in the form:
35 #
36 # {
37 # pkgsBuildBuild = ...;
38 # pkgsBuildHost = ...;
39 # pkgsBuildTarget = ...;
40 # pkgsHostHost = ...;
41 # # pkgsHostTarget skipped on purpose.
42 # pkgsTargetTarget ...;
43 # }
44 #
45 # These are references to adjacent bootstrapping stages. The more familiar
46 # `buildPackages` and `targetPackages` are defined in terms of them. If null,
47 # they are instead defined internally as the current stage. This allows us to
48 # avoid expensive splicing. `pkgsHostTarget` is skipped because it is always
49 # defined as the current stage.
50 adjacentPackages,
51
52 # The standard environment to use for building packages.
53 stdenv,
54
55 # `stdenv` without a C compiler. Passing in this helps avoid infinite
56 # recursions, and may eventually replace passing in the full stdenv.
57 stdenvNoCC ? stdenv.override (
58 {
59 cc = null;
60 hasCC = false;
61 }
62 # Darwin doesn’t need an SDK in `stdenvNoCC`. Dropping it shrinks the closure
63 # size down from ~1 GiB to ~83 MiB, which is a considerable reduction.
64 // lib.optionalAttrs stdenv.hostPlatform.isDarwin { extraBuildInputs = [ ]; }
65 ),
66
67 # This is used because stdenv replacement and the stdenvCross do benefit from
68 # the overridden configuration provided by the user, as opposed to the normal
69 # bootstrapping stdenvs.
70 allowCustomOverrides,
71
72 # Non-GNU/Linux OSes are currently "impure" platforms, with their libc
73 # outside of the store. Thus, GCC, GFortran, & co. must always look for files
74 # in standard system directories (/usr/include, etc.)
75 noSysDirs ?
76 stdenv.buildPlatform.system != "x86_64-solaris"
77 && stdenv.buildPlatform.system != "x86_64-kfreebsd-gnu",
78
79 # The configuration attribute set
80 config,
81
82 # A list of overlays (Additional `self: super: { .. }` customization
83 # functions) to be fixed together in the produced package set
84 overlays,
85}@args:
86
87let
88 stdenvAdapters =
89 self: super:
90 let
91 res = import ../stdenv/adapters.nix {
92 inherit lib config;
93 pkgs = self;
94 };
95 in
96 res
97 // {
98 stdenvAdapters = res;
99 };
100
101 trivialBuilders =
102 self: super:
103 import ../build-support/trivial-builders {
104 inherit lib;
105 inherit (self) config;
106 inherit (self) runtimeShell stdenv stdenvNoCC;
107 inherit (self.pkgsBuildHost) jq shellcheck-minimal lndir;
108 };
109
110 stdenvBootstappingAndPlatforms =
111 self: super:
112 let
113 withFallback =
114 thisPkgs:
115 (if adjacentPackages == null then self else thisPkgs) // { recurseForDerivations = false; };
116 in
117 {
118 # Here are package sets of from related stages. They are all in the form
119 # `pkgs{theirHost}{theirTarget}`. For example, `pkgsBuildHost` means their
120 # host platform is our build platform, and their target platform is our host
121 # platform. We only care about their host/target platforms, not their build
122 # platform, because the the former two alone affect the interface of the
123 # final package; the build platform is just an implementation detail that
124 # should not leak.
125 pkgsBuildBuild = withFallback adjacentPackages.pkgsBuildBuild;
126 pkgsBuildHost = withFallback adjacentPackages.pkgsBuildHost;
127 pkgsBuildTarget = withFallback adjacentPackages.pkgsBuildTarget;
128 pkgsHostHost = withFallback adjacentPackages.pkgsHostHost;
129 pkgsHostTarget = self // {
130 recurseForDerivations = false;
131 }; # always `self`
132 pkgsTargetTarget = withFallback adjacentPackages.pkgsTargetTarget;
133
134 # Older names for package sets. Use these when only the host platform of the
135 # package set matter (i.e. use `buildPackages` where any of `pkgsBuild*`
136 # would do, and `targetPackages` when any of `pkgsTarget*` would do (if we
137 # had more than just `pkgsTargetTarget`).)
138 buildPackages = self.pkgsBuildHost;
139 pkgs = self.pkgsHostTarget;
140 targetPackages = self.pkgsTargetTarget;
141
142 inherit stdenv stdenvNoCC;
143 };
144
145 splice = self: super: import ./splice.nix lib self (adjacentPackages != null);
146
147 allPackages =
148 self: super:
149 let
150 res = import ./all-packages.nix {
151 inherit
152 lib
153 noSysDirs
154 config
155 overlays
156 ;
157 } res self super;
158 in
159 res;
160
161 aliases = self: super: lib.optionalAttrs config.allowAliases (import ./aliases.nix lib self super);
162
163 variants =
164 self: super:
165 lib.optionalAttrs config.allowVariants (
166 import ./variants.nix {
167 inherit
168 lib
169 nixpkgsFun
170 stdenv
171 overlays
172 ;
173 } self super
174 );
175
176 # stdenvOverrides is used to avoid having multiple of versions
177 # of certain dependencies that were used in bootstrapping the
178 # standard environment.
179 stdenvOverrides = self: super: (super.stdenv.overrides or (_: _: { })) self super;
180
181 # Allow packages to be overridden globally via the `packageOverrides'
182 # configuration option, which must be a function that takes `pkgs'
183 # as an argument and returns a set of new or overridden packages.
184 # The `packageOverrides' function is called with the *original*
185 # (un-overridden) set of packages, allowing packageOverrides
186 # attributes to refer to the original attributes (e.g. "foo =
187 # ... pkgs.foo ...").
188 configOverrides =
189 self: super:
190 lib.optionalAttrs allowCustomOverrides ((config.packageOverrides or (super: { })) super);
191
192 # Convenience attributes for instantitating package sets. Each of
193 # these will instantiate a new version of allPackages. Currently the
194 # following package sets are provided:
195 #
196 # - pkgsCross.<system> where system is a member of lib.systems.examples
197 # - pkgsMusl
198 # - pkgsi686Linux
199 # NOTE: add new non-critical package sets to "pkgs/top-level/variants.nix"
200 otherPackageSets = self: super: {
201 # This maps each entry in lib.systems.examples to its own package
202 # set. Each of these will contain all packages cross compiled for
203 # that target system. For instance, pkgsCross.raspberryPi.hello,
204 # will refer to the "hello" package built for the ARM6-based
205 # Raspberry Pi.
206 pkgsCross = lib.mapAttrs (n: crossSystem: nixpkgsFun { inherit crossSystem; }) lib.systems.examples;
207
208 # All packages built for i686 Linux.
209 # Used by wine, firefox with debugging version of Flash, ...
210 pkgsi686Linux =
211 let
212 isSupported = stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isx86;
213 in
214 if !config.allowAliases || isSupported then
215 nixpkgsFun {
216 overlays = [
217 (
218 self': super':
219 {
220 pkgsi686Linux = super';
221 }
222 // lib.optionalAttrs (!isSupported) {
223 # Overrides pkgsi686Linux.stdenv.mkDerivation to produce only broken derivations,
224 # when used on a non x86_64-linux platform in CI.
225 # TODO: Remove this, once pkgsi686Linux can become a variant.
226 stdenv = super'.stdenv // {
227 mkDerivation =
228 args:
229 (super'.stdenv.mkDerivation args).overrideAttrs (prevAttrs: {
230 meta = prevAttrs.meta or { } // {
231 broken = true;
232 };
233 });
234 };
235 }
236 )
237 ]
238 ++ overlays;
239 ${if stdenv.hostPlatform == stdenv.buildPlatform then "localSystem" else "crossSystem"} = {
240 config = lib.systems.parse.tripleFromSystem (
241 stdenv.hostPlatform.parsed
242 // {
243 cpu = lib.systems.parse.cpuTypes.i686;
244 }
245 );
246 };
247 }
248 else
249 throw "i686 Linux package set can only be used with the x86 family.";
250
251 # If already linux: the same package set unaltered
252 # Otherwise, return a natively built linux package set for the current cpu architecture string.
253 # (ABI and other details will be set to the default for the cpu/os pair)
254 pkgsLinux =
255 if stdenv.hostPlatform.isLinux then
256 self
257 else
258 nixpkgsFun {
259 localSystem = lib.systems.elaborate "${stdenv.hostPlatform.parsed.cpu.name}-linux";
260 };
261
262 # Extend the package set with zero or more overlays. This preserves
263 # preexisting overlays. Prefer to initialize with the right overlays
264 # in one go when calling Nixpkgs, for performance and simplicity.
265 appendOverlays =
266 extraOverlays:
267 if extraOverlays == [ ] then self else nixpkgsFun { overlays = args.overlays ++ extraOverlays; };
268
269 # NOTE: each call to extend causes a full nixpkgs rebuild, adding ~130MB
270 # of allocations. DO NOT USE THIS IN NIXPKGS.
271 #
272 # Extend the package set with a single overlay. This preserves
273 # preexisting overlays. Prefer to initialize with the right overlays
274 # in one go when calling Nixpkgs, for performance and simplicity.
275 # Prefer appendOverlays if used repeatedly.
276 extend = f: self.appendOverlays [ f ];
277
278 # Fully static packages.
279 # Currently uses Musl on Linux (couldn’t get static glibc to work).
280 pkgsStatic = nixpkgsFun {
281 overlays = [
282 (self': super': {
283 pkgsStatic = super';
284 })
285 ]
286 ++ overlays;
287 crossSystem = {
288 isStatic = true;
289 config = lib.systems.parse.tripleFromSystem (
290 if stdenv.hostPlatform.isLinux then
291 lib.systems.parse.mkMuslSystem stdenv.hostPlatform.parsed
292 else
293 stdenv.hostPlatform.parsed
294 );
295 gcc =
296 lib.optionalAttrs (stdenv.hostPlatform.system == "powerpc64-linux") { abi = "elfv2"; }
297 // stdenv.hostPlatform.gcc or { };
298 };
299 };
300 };
301
302 # The complete chain of package set builders, applied from top to bottom.
303 # stdenvOverlays must be last as it brings package forward from the
304 # previous bootstrapping phases which have already been overlaid.
305 toFix = lib.foldl' (lib.flip lib.extends) (self: { }) (
306 [
307 stdenvBootstappingAndPlatforms
308 stdenvAdapters
309 trivialBuilders
310 splice
311 autoCalledPackages
312 allPackages
313 otherPackageSets
314 aliases
315 variants
316 configOverrides
317 ]
318 ++ overlays
319 ++ [
320 stdenvOverrides
321 ]
322 );
323
324in
325# Return the complete set of packages.
326lib.fix toFix