1 /* This function composes the Nix Packages collection. It:
3 1. Elaborates `localSystem` and `crossSystem` with defaults as needed.
5 2. Applies the final stage to the given `config` if it is a function
7 3. Defaults to no non-standard config and no cross-compilation target
9 4. Uses the above to infer the default standard environment's (stdenv's)
10 stages if no stdenv's are provided
12 5. Folds the stages to yield the final fully booted package set for the
15 Use `impure.nix` to also infer the `system` based on the one on which
16 evaluation is taking place, and the configuration from environment variables
19 { # The system packages will be built on. See the manual for the
20 # subtle division of labor between these two `*System`s and the three
24 , # The system packages will ultimately be run on.
25 crossSystem ? localSystem
27 , # Allow a configuration attribute set to be passed in as an argument.
30 , # List of overlays layers used to extend Nixpkgs.
33 , # List of overlays to apply to target packages only.
36 , # A function booting the final package set for a specific standard
37 # environment. See below for the arguments given to that function, the type of
39 stdenvStages ? import ../stdenv
41 , # Ignore unexpected args.
45 let # Rename the function arguments
47 crossSystem0 = crossSystem;
50 lib = import ../../lib;
52 inherit (lib) throwIfNot;
55 throwIfNot (lib.isList overlays) "The overlays argument to nixpkgs must be a list."
56 lib.foldr (x: throwIfNot (lib.isFunction x) "All overlays passed to nixpkgs must be functions.") (r: r) overlays
57 throwIfNot (lib.isList crossOverlays) "The crossOverlays argument to nixpkgs must be a list."
58 lib.foldr (x: throwIfNot (lib.isFunction x) "All crossOverlays passed to nixpkgs must be functions.") (r: r) crossOverlays
61 localSystem = lib.systems.elaborate args.localSystem;
63 # Condition preserves sharing which in turn affects equality.
65 if crossSystem0 == null || crossSystem0 == args.localSystem
67 else lib.systems.elaborate crossSystem0;
70 # { /* the config */ } and
71 # { pkgs, ... } : { /* the config */ }
73 if lib.isFunction config0
74 then config0 { inherit pkgs; }
77 configEval = lib.evalModules {
81 _file = "nixpkgs.config";
87 # take all the rest as-is
88 config = lib.showWarnings configEval.config.warnings configEval.config;
90 # A few packages make a new package set to draw their dependencies from.
91 # (Currently to get a cross tool chain, or forced-i686 package.) Rather than
92 # give `all-packages.nix` all the arguments to this function, even ones that
93 # don't concern it, we give it this function to "re-call" nixpkgs, inheriting
94 # whatever arguments it doesn't explicitly provide. This way,
95 # `all-packages.nix` doesn't know more than it needs too.
97 # It's OK that `args` doesn't include default arguments from this file:
98 # they'll be deterministically inferred. In fact we must *not* include them,
99 # because it's important that if some parameter which affects the default is
100 # substituted with a different argument, the default is re-inferred.
102 # To put this in concrete terms, this function is basically just used today to
103 # use package for a different platform for the current platform (namely cross
104 # compiling toolchains and 32-bit packages on x86_64). In both those cases we
105 # want the provided non-native `localSystem` argument to affect the stdenv
108 # NB!!! This thing gets its `config` argument from `args`, i.e. it's actually
109 # `config0`. It is important to keep it to `config0` format (as opposed to the
110 # result of `evalModules`, i.e. the `config` variable above) throughout all
111 # nixpkgs evaluations since the above function `config0 -> config` implemented
112 # via `evalModules` is not idempotent. In other words, if you add `config` to
113 # `newArgs`, expect strange very hard to debug errors! (Yes, I'm speaking from
115 nixpkgsFun = newArgs: import ./. (args // newArgs);
117 # Partially apply some arguments for building bootstraping stage pkgs
118 # sets. Only apply arguments which no stdenv would want to override.
119 allPackages = newArgs: import ./stage.nix ({
120 inherit lib nixpkgsFun;
123 boot = import ../stdenv/booter.nix { inherit lib allPackages; };
125 stages = stdenvStages {
126 inherit lib localSystem crossSystem config overlays crossOverlays;