nixpkgs/pkgs/stdenv/default.nix
Nicolas B. Pierron f5dfe78a1e Add overlays mechanism to Nixpkgs.
This patch add a new argument to Nixpkgs default expression named "overlays".

By default, the value of the argument is either taken from the environment variable `NIXPKGS_OVERLAYS`,
or from the directory `~/.nixpkgs/overlays/`.  If the environment variable does not name a valid directory
then this mechanism would fallback on the home directory.  If the home directory does not exists it will
fallback on an empty list of overlays.

The overlays directory should contain the list of extra Nixpkgs stages which would be used to extend the
content of Nixpkgs, with additional set of packages.  The overlays, i-e directory, files, symbolic links
are used in alphabetical order.

The simplest overlay which extends Nixpkgs with nothing looks like:

```nix
self: super: {
}
```

More refined overlays can use `super` as the basis for building new packages, and `self` as a way to query
the final result of the fix-point.

An example of overlay which extends Nixpkgs with a small set of packages can be found at:
  https://github.com/nbp/nixpkgs-mozilla/blob/nixpkgs-overlay/moz-overlay.nix

To use this file, checkout the repository and add a symbolic link to
the `moz-overlay.nix` file in `~/.nixpkgs/overlays` directory.
2017-01-16 01:17:33 +01:00

55 lines
1.9 KiB
Nix

# This file chooses a sane default stdenv given the system, platform, etc.
#
# Rather than returning a stdenv, this returns a list of functions---one per
# each bootstrapping stage. See `./booter.nix` for exactly what this list should
# contain.
{ # Args just for stdenvs' usage
lib
# Args to pass on to the pkgset builder, too
, system, platform, crossSystem, config, overlays
} @ args:
let
# The native (i.e., impure) build environment. This one uses the
# tools installed on the system outside of the Nix environment,
# i.e., the stuff in /bin, /usr/bin, etc. This environment should
# be used with care, since many Nix packages will not build properly
# with it (e.g., because they require GNU Make).
stagesNative = import ./native args;
# The Nix build environment.
stagesNix = import ./nix (args // { bootStages = stagesNative; });
stagesFreeBSD = import ./freebsd args;
# On Linux systems, the standard build environment consists of Nix-built
# instances glibc and the `standard' Unix tools, i.e., the Posix utilities,
# the GNU C compiler, and so on.
stagesLinux = import ./linux args;
inherit (import ./darwin args) stagesDarwin;
stagesCross = import ./cross args;
stagesCustom = import ./custom args;
# Select the appropriate stages for the platform `system'.
in
if crossSystem != null then stagesCross
else if config ? replaceStdenv then stagesCustom
else { # switch
"i686-linux" = stagesLinux;
"x86_64-linux" = stagesLinux;
"armv5tel-linux" = stagesLinux;
"armv6l-linux" = stagesLinux;
"armv7l-linux" = stagesLinux;
"mips64el-linux" = stagesLinux;
"powerpc-linux" = /* stagesLinux */ stagesNative;
"x86_64-darwin" = stagesDarwin;
"x86_64-solaris" = stagesNix;
"i686-cygwin" = stagesNative;
"x86_64-cygwin" = stagesNative;
"x86_64-freebsd" = stagesFreeBSD;
}.${system} or stagesNative