about summary refs log tree commit diff
path: root/nixpkgs/doc
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-04-09 18:28:16 +0000
committerAlyssa Ross <hi@alyssa.is>2021-04-12 18:46:15 +0000
commitfd2e737e0678ee7d8081baef05b305146a2c0034 (patch)
treeac3e9b27576a0382335532d126f9a66d486bc638 /nixpkgs/doc
parentcc207d720b6aa836e256c1ee9842bc739e630a8a (diff)
parent9e377a6ce42dccd9b624ae4ce8f978dc892ba0e2 (diff)
downloadnixlib-fd2e737e0678ee7d8081baef05b305146a2c0034.tar
nixlib-fd2e737e0678ee7d8081baef05b305146a2c0034.tar.gz
nixlib-fd2e737e0678ee7d8081baef05b305146a2c0034.tar.bz2
nixlib-fd2e737e0678ee7d8081baef05b305146a2c0034.tar.lz
nixlib-fd2e737e0678ee7d8081baef05b305146a2c0034.tar.xz
nixlib-fd2e737e0678ee7d8081baef05b305146a2c0034.tar.zst
nixlib-fd2e737e0678ee7d8081baef05b305146a2c0034.zip
Merge remote-tracking branch 'nixpkgs/nixos-unstable'
Diffstat (limited to 'nixpkgs/doc')
-rw-r--r--nixpkgs/doc/Makefile2
-rw-r--r--nixpkgs/doc/README.md12
-rw-r--r--nixpkgs/doc/builders/fetchers.chapter.md10
-rw-r--r--nixpkgs/doc/builders/images.xml4
-rw-r--r--nixpkgs/doc/builders/images/dockertools.section.md308
-rw-r--r--nixpkgs/doc/builders/images/dockertools.xml499
-rw-r--r--nixpkgs/doc/builders/images/ocitools.section.md37
-rw-r--r--nixpkgs/doc/builders/images/ocitools.xml61
-rw-r--r--nixpkgs/doc/builders/images/snaptools.xml2
-rw-r--r--nixpkgs/doc/builders/packages/citrix.section.md32
-rw-r--r--nixpkgs/doc/builders/packages/citrix.xml46
-rw-r--r--nixpkgs/doc/builders/packages/eclipse.section.md64
-rw-r--r--nixpkgs/doc/builders/packages/eclipse.xml72
-rw-r--r--nixpkgs/doc/builders/packages/emacs.section.md2
-rw-r--r--nixpkgs/doc/builders/packages/fuse.section.md19
-rw-r--r--nixpkgs/doc/builders/packages/ibus.section.md38
-rw-r--r--nixpkgs/doc/builders/packages/ibus.xml57
-rw-r--r--nixpkgs/doc/builders/packages/index.xml7
-rw-r--r--nixpkgs/doc/contributing/coding-conventions.xml12
-rw-r--r--nixpkgs/doc/contributing/submitting-changes.chapter.md24
-rw-r--r--nixpkgs/doc/contributing/vulnerability-roundup.chapter.md45
-rw-r--r--nixpkgs/doc/functions/library/attrsets.xml8
-rw-r--r--nixpkgs/doc/languages-frameworks/agda.section.md14
-rw-r--r--nixpkgs/doc/languages-frameworks/android.section.md2
-rw-r--r--nixpkgs/doc/languages-frameworks/coq.section.md6
-rw-r--r--nixpkgs/doc/languages-frameworks/dotnet.section.md8
-rw-r--r--nixpkgs/doc/languages-frameworks/idris.section.md18
-rw-r--r--nixpkgs/doc/languages-frameworks/lua.section.md4
-rw-r--r--nixpkgs/doc/languages-frameworks/python.section.md99
-rw-r--r--nixpkgs/doc/languages-frameworks/qt.section.md118
-rw-r--r--nixpkgs/doc/languages-frameworks/ruby.section.md2
-rw-r--r--nixpkgs/doc/languages-frameworks/rust.section.md291
-rw-r--r--nixpkgs/doc/languages-frameworks/vim.section.md8
-rw-r--r--nixpkgs/doc/manual.xml9
-rw-r--r--nixpkgs/doc/stdenv/cross-compilation.chapter.md21
-rw-r--r--nixpkgs/doc/stdenv/meta.chapter.md194
-rw-r--r--nixpkgs/doc/stdenv/meta.xml349
-rw-r--r--nixpkgs/doc/stdenv/multiple-output.chapter.md128
-rw-r--r--nixpkgs/doc/stdenv/multiple-output.xml262
-rw-r--r--nixpkgs/doc/stdenv/platform-notes.chapter.md62
-rw-r--r--nixpkgs/doc/stdenv/platform-notes.xml83
-rw-r--r--nixpkgs/doc/stdenv/stdenv.chapter.md1215
-rw-r--r--nixpkgs/doc/stdenv/stdenv.xml2423
-rw-r--r--nixpkgs/doc/using/configuration.xml12
-rw-r--r--nixpkgs/doc/using/overlays.xml256
45 files changed, 2744 insertions, 4201 deletions
diff --git a/nixpkgs/doc/Makefile b/nixpkgs/doc/Makefile
index 4f520779f5b2..7affbb0bb51c 100644
--- a/nixpkgs/doc/Makefile
+++ b/nixpkgs/doc/Makefile
@@ -1,4 +1,4 @@
-MD_TARGETS=$(addsuffix .xml, $(basename $(shell find . -type f -regex '.*\.md$$')))
+MD_TARGETS=$(addsuffix .xml, $(basename $(shell find . -type f -regex '.*\.md$$' -not -name README.md)))
 
 .PHONY: all
 all: validate format out/html/index.html out/epub/manual.epub
diff --git a/nixpkgs/doc/README.md b/nixpkgs/doc/README.md
new file mode 100644
index 000000000000..5395d7ca8f61
--- /dev/null
+++ b/nixpkgs/doc/README.md
@@ -0,0 +1,12 @@
+
+# Nixpkgs/doc
+
+This directory houses the sources files for the Nixpkgs manual.
+
+You can find the [rendered documentation for Nixpkgs `unstable` on nixos.org](https://nixos.org/manual/nixpkgs/unstable/).
+
+[Docs for Nixpkgs stable](https://nixos.org/manual/nixpkgs/stable/) are also available.
+
+If you want to contribute to the documentation, [here's how to do it](https://nixos.org/manual/nixpkgs/unstable/#chap-contributing).
+
+If you're only getting started with Nix, go to [nixos.org/learn](https://nixos.org/learn).
diff --git a/nixpkgs/doc/builders/fetchers.chapter.md b/nixpkgs/doc/builders/fetchers.chapter.md
index d4cab056c70b..c70e3020bbfa 100644
--- a/nixpkgs/doc/builders/fetchers.chapter.md
+++ b/nixpkgs/doc/builders/fetchers.chapter.md
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
 
 The main difference between `fetchurl` and `fetchzip` is in how they store the contents. `fetchurl` will store the unaltered contents of the URL within the Nix store. `fetchzip` on the other hand will decompress the archive for you, making files and directories directly accessible in the future. `fetchzip` can only be used with archives. Despite the name, `fetchzip` is not limited to .zip files and can also be used with any tarball.
 
-`fetchpatch` works very similarly to `fetchurl` with the same arguments expected. It expects patch files as a source and and performs normalization on them before computing the checksum. For example it will remove comments or other unstable parts that are sometimes added by version control systems and can change over time.
+`fetchpatch` works very similarly to `fetchurl` with the same arguments expected. It expects patch files as a source and performs normalization on them before computing the checksum. For example it will remove comments or other unstable parts that are sometimes added by version control systems and can change over time.
 
 
 Other fetcher functions allow you to add source code directly from a VCS such as subversion or git. These are mostly straightforward nambes based on the name of the command used with the VCS system. Because they give you a working repository, they act most like `fetchzip`.
@@ -31,6 +31,8 @@ Used with Subversion. Expects `url` to a Subversion directory, `rev`, and `sha25
 
 Used with Git. Expects `url` to a Git repo, `rev`, and `sha256`. `rev` in this case can be full the git commit id (SHA1 hash) or a tag name like `refs/tags/v1.0`.
 
+Additionally the following optional arguments can be given: `fetchSubmodules = true` makes `fetchgit` also fetch the submodules of a repository. If `deepClone` is set to true, the entire repository is cloned as opposing to just creating a shallow clone. `deepClone = true` also implies `leaveDotGit = true` which means that the `.git` directory of the clone won't be removed after checkout.
+
 ## `fetchfossil`
 
 Used with Fossil. Expects `url` to a Fossil archive, `rev`, and `sha256`.
@@ -49,6 +51,8 @@ A number of fetcher functions wrap part of `fetchurl` and `fetchzip`. They are m
 
 `fetchFromGitHub` expects four arguments. `owner` is a string corresponding to the GitHub user or organization that controls this repository. `repo` corresponds to the name of the software repository. These are located at the top of every GitHub HTML page as `owner`/`repo`. `rev` corresponds to the Git commit hash or tag (e.g `v1.0`) that will be downloaded from Git. Finally, `sha256` corresponds to the hash of the extracted directory. Again, other hash algorithms are also available but `sha256` is currently preferred.
 
+`fetchFromGitHub` uses `fetchzip` to download the source archive generated by GitHub for the specified revision. If `leaveDotGit`, `deepClone` or `fetchSubmodules` are set to `true`, `fetchFromGitHub` will use `fetchgit` instead. Refer to its section for documentation of these options.
+
 ## `fetchFromGitLab`
 
 This is used with GitLab repositories. The arguments expected are very similar to fetchFromGitHub above.
@@ -68,3 +72,7 @@ This is used with Savannah repositories. The arguments expected are very similar
 ## `fetchFromRepoOrCz`
 
 This is used with repo.or.cz repositories. The arguments expected are very similar to fetchFromGitHub above.
+
+## `fetchFromSourcehut`
+
+This is used with sourcehut repositories. The arguments expected are very similar to fetchFromGitHub above. Don't forget the tilde (~) in front of the user name!
diff --git a/nixpkgs/doc/builders/images.xml b/nixpkgs/doc/builders/images.xml
index 5e042a8ada80..d7d250291893 100644
--- a/nixpkgs/doc/builders/images.xml
+++ b/nixpkgs/doc/builders/images.xml
@@ -6,7 +6,7 @@
   This chapter describes tools for creating various types of images.
  </para>
  <xi:include href="images/appimagetools.xml" />
- <xi:include href="images/dockertools.xml" />
- <xi:include href="images/ocitools.xml" />
+ <xi:include href="images/dockertools.section.xml" />
+ <xi:include href="images/ocitools.section.xml" />
  <xi:include href="images/snaptools.xml" />
 </chapter>
diff --git a/nixpkgs/doc/builders/images/dockertools.section.md b/nixpkgs/doc/builders/images/dockertools.section.md
new file mode 100644
index 000000000000..2d21eb1c2e07
--- /dev/null
+++ b/nixpkgs/doc/builders/images/dockertools.section.md
@@ -0,0 +1,308 @@
+# pkgs.dockerTools {#sec-pkgs-dockerTools}
+
+`pkgs.dockerTools` is a set of functions for creating and manipulating Docker images according to the [ Docker Image Specification v1.2.0 ](https://github.com/moby/moby/blob/master/image/spec/v1.2.md#docker-image-specification-v120). Docker itself is not used to perform any of the operations done by these functions.
+
+## buildImage {#ssec-pkgs-dockerTools-buildImage}
+
+This function is analogous to the `docker build` command, in that it can be used to build a Docker-compatible repository tarball containing a single image with one or multiple layers. As such, the result is suitable for being loaded in Docker with `docker load`.
+
+The parameters of `buildImage` with relative example values are described below:
+
+[]{#ex-dockerTools-buildImage}
+[]{#ex-dockerTools-buildImage-runAsRoot}
+
+```nix
+buildImage {
+  name = "redis";
+  tag = "latest";
+
+  fromImage = someBaseImage;
+  fromImageName = null;
+  fromImageTag = "latest";
+
+  contents = pkgs.redis;
+  runAsRoot = ''
+    #!${pkgs.runtimeShell}
+    mkdir -p /data
+  '';
+
+  config = {
+    Cmd = [ "/bin/redis-server" ];
+    WorkingDir = "/data";
+    Volumes = { "/data" = { }; };
+  };
+}
+```
+
+The above example will build a Docker image `redis/latest` from the given base image. Loading and running this image in Docker results in `redis-server` being started automatically.
+
+- `name` specifies the name of the resulting image. This is the only required argument for `buildImage`.
+
+- `tag` specifies the tag of the resulting image. By default it's `null`, which indicates that the nix output hash will be used as tag.
+
+- `fromImage` is the repository tarball containing the base image. It must be a valid Docker image, such as exported by `docker save`. By default it's `null`, which can be seen as equivalent to `FROM scratch` of a `Dockerfile`.
+
+- `fromImageName` can be used to further specify the base image within the repository, in case it contains multiple images. By default it's `null`, in which case `buildImage` will peek the first image available in the repository.
+
+- `fromImageTag` can be used to further specify the tag of the base image within the repository, in case an image contains multiple tags. By default it's `null`, in which case `buildImage` will peek the first tag available for the base image.
+
+- `contents` is a derivation that will be copied in the new layer of the resulting image. This can be similarly seen as `ADD contents/ /` in a `Dockerfile`. By default it's `null`.
+
+- `runAsRoot` is a bash script that will run as root in an environment that overlays the existing layers of the base image with the new resulting layer, including the previously copied `contents` derivation. This can be similarly seen as `RUN ...` in a `Dockerfile`.
+
+> **_NOTE:_** Using this parameter requires the `kvm` device to be available.
+
+- `config` is used to specify the configuration of the containers that will be started off the built image in Docker. The available options are listed in the [ Docker Image Specification v1.2.0 ](https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions).
+
+After the new layer has been created, its closure (to which `contents`, `config` and `runAsRoot` contribute) will be copied in the layer itself. Only new dependencies that are not already in the existing layers will be copied.
+
+At the end of the process, only one new single layer will be produced and added to the resulting image.
+
+The resulting repository will only list the single image `image/tag`. In the case of [the `buildImage` example](#ex-dockerTools-buildImage) it would be `redis/latest`.
+
+It is possible to inspect the arguments with which an image was built using its `buildArgs` attribute.
+
+> **_NOTE:_** If you see errors similar to `getProtocolByName: does not exist (no such protocol name: tcp)` you may need to add `pkgs.iana-etc` to `contents`.
+
+> **_NOTE:_** If you see errors similar to `Error_Protocol ("certificate has unknown CA",True,UnknownCa)` you may need to add `pkgs.cacert` to `contents`.
+
+By default `buildImage` will use a static date of one second past the UNIX Epoch. This allows `buildImage` to produce binary reproducible images. When listing images with `docker images`, the newly created images will be listed like this:
+
+```ShellSession
+$ docker images
+REPOSITORY   TAG      IMAGE ID       CREATED        SIZE
+hello        latest   08c791c7846e   48 years ago   25.2MB
+```
+
+You can break binary reproducibility but have a sorted, meaningful `CREATED` column by setting `created` to `now`.
+
+```nix
+pkgs.dockerTools.buildImage {
+  name = "hello";
+  tag = "latest";
+  created = "now";
+  contents = pkgs.hello;
+
+  config.Cmd = [ "/bin/hello" ];
+}
+```
+
+and now the Docker CLI will display a reasonable date and sort the images as expected:
+
+```ShellSession
+$ docker images
+REPOSITORY   TAG      IMAGE ID       CREATED              SIZE
+hello        latest   de2bf4786de6   About a minute ago   25.2MB
+```
+
+however, the produced images will not be binary reproducible.
+
+## buildLayeredImage {#ssec-pkgs-dockerTools-buildLayeredImage}
+
+Create a Docker image with many of the store paths being on their own layer to improve sharing between images. The image is realized into the Nix store as a gzipped tarball. Depending on the intended usage, many users might prefer to use `streamLayeredImage` instead, which this function uses internally.
+
+`name`
+
+: The name of the resulting image.
+
+`tag` _optional_
+
+: Tag of the generated image.
+
+    *Default:* the output path's hash
+
+`fromImage` _optional_
+
+: The repository tarball containing the base image. It must be a valid Docker image, such as one exported by `docker save`.
+
+    *Default:* `null`, which can be seen as equivalent to `FROM scratch` of a `Dockerfile`.
+
+`contents` _optional_
+
+: Top level paths in the container. Either a single derivation, or a list of derivations.
+
+    *Default:* `[]`
+
+`config` _optional_
+
+: Run-time configuration of the container. A full list of the options are available at in the [ Docker Image Specification v1.2.0 ](https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions).
+
+    *Default:* `{}`
+
+`created` _optional_
+
+: Date and time the layers were created. Follows the same `now` exception supported by `buildImage`.
+
+    *Default:* `1970-01-01T00:00:01Z`
+
+`maxLayers` _optional_
+
+: Maximum number of layers to create.
+
+    *Default:* `100`
+
+    *Maximum:* `125`
+
+`extraCommands` _optional_
+
+: Shell commands to run while building the final layer, without access to most of the layer contents. Changes to this layer are "on top" of all the other layers, so can create additional directories and files.
+
+`fakeRootCommands` _optional_
+
+: Shell commands to run while creating the archive for the final layer in a fakeroot environment. Unlike `extraCommands`, you can run `chown` to change the owners of the files in the archive, changing fakeroot's state instead of the real filesystem. The latter would require privileges that the build user does not have. Static binaries do not interact with the fakeroot environment. By default all files in the archive will be owned by root.
+
+### Behavior of `contents` in the final image {#dockerTools-buildLayeredImage-arg-contents}
+
+Each path directly listed in `contents` will have a symlink in the root of the image.
+
+For example:
+
+```nix
+pkgs.dockerTools.buildLayeredImage {
+  name = "hello";
+  contents = [ pkgs.hello ];
+}
+```
+
+will create symlinks for all the paths in the `hello` package:
+
+```ShellSession
+/bin/hello -> /nix/store/h1zb1padqbbb7jicsvkmrym3r6snphxg-hello-2.10/bin/hello
+/share/info/hello.info -> /nix/store/h1zb1padqbbb7jicsvkmrym3r6snphxg-hello-2.10/share/info/hello.info
+/share/locale/bg/LC_MESSAGES/hello.mo -> /nix/store/h1zb1padqbbb7jicsvkmrym3r6snphxg-hello-2.10/share/locale/bg/LC_MESSAGES/hello.mo
+```
+
+### Automatic inclusion of `config` references {#dockerTools-buildLayeredImage-arg-config}
+
+The closure of `config` is automatically included in the closure of the final image.
+
+This allows you to make very simple Docker images with very little code. This container will start up and run `hello`:
+
+```nix
+pkgs.dockerTools.buildLayeredImage {
+  name = "hello";
+  config.Cmd = [ "${pkgs.hello}/bin/hello" ];
+}
+```
+
+### Adjusting `maxLayers` {#dockerTools-buildLayeredImage-arg-maxLayers}
+
+Increasing the `maxLayers` increases the number of layers which have a chance to be shared between different images.
+
+Modern Docker installations support up to 128 layers, however older versions support as few as 42.
+
+If the produced image will not be extended by other Docker builds, it is safe to set `maxLayers` to `128`. However it will be impossible to extend the image further.
+
+The first (`maxLayers-2`) most "popular" paths will have their own individual layers, then layer \#`maxLayers-1` will contain all the remaining "unpopular" paths, and finally layer \#`maxLayers` will contain the Image configuration.
+
+Docker's Layers are not inherently ordered, they are content-addressable and are not explicitly layered until they are composed in to an Image.
+
+## streamLayeredImage {#ssec-pkgs-dockerTools-streamLayeredImage}
+
+Builds a script which, when run, will stream an uncompressed tarball of a Docker image to stdout. The arguments to this function are as for `buildLayeredImage`. This method of constructing an image does not realize the image into the Nix store, so it saves on IO and disk/cache space, particularly with large images.
+
+The image produced by running the output script can be piped directly into `docker load`, to load it into the local docker daemon:
+
+```ShellSession
+$(nix-build) | docker load
+```
+
+Alternatively, the image be piped via `gzip` into `skopeo`, e.g. to copy it into a registry:
+
+```ShellSession
+$(nix-build) | gzip --fast | skopeo copy docker-archive:/dev/stdin docker://some_docker_registry/myimage:tag
+```
+
+## pullImage {#ssec-pkgs-dockerTools-fetchFromRegistry}
+
+This function is analogous to the `docker pull` command, in that it can be used to pull a Docker image from a Docker registry. By default [Docker Hub](https://hub.docker.com/) is used to pull images.
+
+Its parameters are described in the example below:
+
+```nix
+pullImage {
+  imageName = "nixos/nix";
+  imageDigest =
+    "sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b";
+  finalImageName = "nix";
+  finalImageTag = "1.11";
+  sha256 = "0mqjy3zq2v6rrhizgb9nvhczl87lcfphq9601wcprdika2jz7qh8";
+  os = "linux";
+  arch = "x86_64";
+}
+```
+
+- `imageName` specifies the name of the image to be downloaded, which can also include the registry namespace (e.g. `nixos`). This argument is required.
+
+- `imageDigest` specifies the digest of the image to be downloaded. This argument is required.
+
+- `finalImageName`, if specified, this is the name of the image to be created. Note it is never used to fetch the image since we prefer to rely on the immutable digest ID. By default it's equal to `imageName`.
+
+- `finalImageTag`, if specified, this is the tag of the image to be created. Note it is never used to fetch the image since we prefer to rely on the immutable digest ID. By default it's `latest`.
+
+- `sha256` is the checksum of the whole fetched image. This argument is required.
+
+- `os`, if specified, is the operating system of the fetched image. By default it's `linux`.
+
+- `arch`, if specified, is the cpu architecture of the fetched image. By default it's `x86_64`.
+
+`nix-prefetch-docker` command can be used to get required image parameters:
+
+```ShellSession
+$ nix run nixpkgs.nix-prefetch-docker -c nix-prefetch-docker --image-name mysql --image-tag 5
+```
+
+Since a given `imageName` may transparently refer to a manifest list of images which support multiple architectures and/or operating systems, you can supply the `--os` and `--arch` arguments to specify exactly which image you want. By default it will match the OS and architecture of the host the command is run on.
+
+```ShellSession
+$ nix-prefetch-docker --image-name mysql --image-tag 5 --arch x86_64 --os linux
+```
+
+Desired image name and tag can be set using `--final-image-name` and `--final-image-tag` arguments:
+
+```ShellSession
+$ nix-prefetch-docker --image-name mysql --image-tag 5 --final-image-name eu.gcr.io/my-project/mysql --final-image-tag prod
+```
+
+## exportImage {#ssec-pkgs-dockerTools-exportImage}
+
+This function is analogous to the `docker export` command, in that it can be used to flatten a Docker image that contains multiple layers. It is in fact the result of the merge of all the layers of the image. As such, the result is suitable for being imported in Docker with `docker import`.
+
+> **_NOTE:_** Using this function requires the `kvm` device to be available.
+
+The parameters of `exportImage` are the following:
+
+```nix
+exportImage {
+  fromImage = someLayeredImage;
+  fromImageName = null;
+  fromImageTag = null;
+
+  name = someLayeredImage.name;
+}
+```
+
+The parameters relative to the base image have the same synopsis as described in [buildImage](#ssec-pkgs-dockerTools-buildImage), except that `fromImage` is the only required argument in this case.
+
+The `name` argument is the name of the derivation output, which defaults to `fromImage.name`.
+
+## shadowSetup {#ssec-pkgs-dockerTools-shadowSetup}
+
+This constant string is a helper for setting up the base files for managing users and groups, only if such files don't exist already. It is suitable for being used in a [`buildImage` `runAsRoot`](#ex-dockerTools-buildImage-runAsRoot) script for cases like in the example below:
+
+```nix
+buildImage {
+  name = "shadow-basic";
+
+  runAsRoot = ''
+    #!${pkgs.runtimeShell}
+    ${shadowSetup}
+    groupadd -r redis
+    useradd -r -g redis redis
+    mkdir /data
+    chown redis:redis /data
+  '';
+}
+```
+
+Creating base files like `/etc/passwd` or `/etc/login.defs` is necessary for shadow-utils to manipulate users and groups.
diff --git a/nixpkgs/doc/builders/images/dockertools.xml b/nixpkgs/doc/builders/images/dockertools.xml
deleted file mode 100644
index d881e712a041..000000000000
--- a/nixpkgs/doc/builders/images/dockertools.xml
+++ /dev/null
@@ -1,499 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         xml:id="sec-pkgs-dockerTools">
- <title>pkgs.dockerTools</title>
-
- <para>
-  <varname>pkgs.dockerTools</varname> is a set of functions for creating and manipulating Docker images according to the <link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#docker-image-specification-v120"> Docker Image Specification v1.2.0 </link>. Docker itself is not used to perform any of the operations done by these functions.
- </para>
-
- <section xml:id="ssec-pkgs-dockerTools-buildImage">
-  <title>buildImage</title>
-
-  <para>
-   This function is analogous to the <command>docker build</command> command, in that it can be used to build a Docker-compatible repository tarball containing a single image with one or multiple layers. As such, the result is suitable for being loaded in Docker with <command>docker load</command>.
-  </para>
-
-  <para>
-   The parameters of <varname>buildImage</varname> with relative example values are described below:
-  </para>
-
-  <example xml:id='ex-dockerTools-buildImage'>
-   <title>Docker build</title>
-<programlisting>
-buildImage {
-  name = "redis"; <co xml:id='ex-dockerTools-buildImage-1' />
-  tag = "latest"; <co xml:id='ex-dockerTools-buildImage-2' />
-
-  fromImage = someBaseImage; <co xml:id='ex-dockerTools-buildImage-3' />
-  fromImageName = null; <co xml:id='ex-dockerTools-buildImage-4' />
-  fromImageTag = "latest"; <co xml:id='ex-dockerTools-buildImage-5' />
-
-  contents = pkgs.redis; <co xml:id='ex-dockerTools-buildImage-6' />
-  runAsRoot = '' <co xml:id='ex-dockerTools-buildImage-runAsRoot' />
-    #!${pkgs.runtimeShell}
-    mkdir -p /data
-  '';
-
-  config = { <co xml:id='ex-dockerTools-buildImage-8' />
-    Cmd = [ "/bin/redis-server" ];
-    WorkingDir = "/data";
-    Volumes = {
-      "/data" = {};
-    };
-  };
-}
-</programlisting>
-  </example>
-
-  <para>
-   The above example will build a Docker image <literal>redis/latest</literal> from the given base image. Loading and running this image in Docker results in <literal>redis-server</literal> being started automatically.
-  </para>
-
-  <calloutlist>
-   <callout arearefs='ex-dockerTools-buildImage-1'>
-    <para>
-     <varname>name</varname> specifies the name of the resulting image. This is the only required argument for <varname>buildImage</varname>.
-    </para>
-   </callout>
-   <callout arearefs='ex-dockerTools-buildImage-2'>
-    <para>
-     <varname>tag</varname> specifies the tag of the resulting image. By default it's <literal>null</literal>, which indicates that the nix output hash will be used as tag.
-    </para>
-   </callout>
-   <callout arearefs='ex-dockerTools-buildImage-3'>
-    <para>
-     <varname>fromImage</varname> is the repository tarball containing the base image. It must be a valid Docker image, such as exported by <command>docker save</command>. By default it's <literal>null</literal>, which can be seen as equivalent to <literal>FROM scratch</literal> of a <filename>Dockerfile</filename>.
-    </para>
-   </callout>
-   <callout arearefs='ex-dockerTools-buildImage-4'>
-    <para>
-     <varname>fromImageName</varname> can be used to further specify the base image within the repository, in case it contains multiple images. By default it's <literal>null</literal>, in which case <varname>buildImage</varname> will peek the first image available in the repository.
-    </para>
-   </callout>
-   <callout arearefs='ex-dockerTools-buildImage-5'>
-    <para>
-     <varname>fromImageTag</varname> can be used to further specify the tag of the base image within the repository, in case an image contains multiple tags. By default it's <literal>null</literal>, in which case <varname>buildImage</varname> will peek the first tag available for the base image.
-    </para>
-   </callout>
-   <callout arearefs='ex-dockerTools-buildImage-6'>
-    <para>
-     <varname>contents</varname> is a derivation that will be copied in the new layer of the resulting image. This can be similarly seen as <command>ADD contents/ /</command> in a <filename>Dockerfile</filename>. By default it's <literal>null</literal>.
-    </para>
-   </callout>
-   <callout arearefs='ex-dockerTools-buildImage-runAsRoot'>
-    <para>
-     <varname>runAsRoot</varname> is a bash script that will run as root in an environment that overlays the existing layers of the base image with the new resulting layer, including the previously copied <varname>contents</varname> derivation. This can be similarly seen as <command>RUN ...</command> in a <filename>Dockerfile</filename>.
-     <note>
-      <para>
-       Using this parameter requires the <literal>kvm</literal> device to be available.
-      </para>
-     </note>
-    </para>
-   </callout>
-   <callout arearefs='ex-dockerTools-buildImage-8'>
-    <para>
-     <varname>config</varname> is used to specify the configuration of the containers that will be started off the built image in Docker. The available options are listed in the <link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions"> Docker Image Specification v1.2.0 </link>.
-    </para>
-   </callout>
-  </calloutlist>
-
-  <para>
-   After the new layer has been created, its closure (to which <varname>contents</varname>, <varname>config</varname> and <varname>runAsRoot</varname> contribute) will be copied in the layer itself. Only new dependencies that are not already in the existing layers will be copied.
-  </para>
-
-  <para>
-   At the end of the process, only one new single layer will be produced and added to the resulting image.
-  </para>
-
-  <para>
-   The resulting repository will only list the single image <varname>image/tag</varname>. In the case of <xref linkend='ex-dockerTools-buildImage'/> it would be <varname>redis/latest</varname>.
-  </para>
-
-  <para>
-   It is possible to inspect the arguments with which an image was built using its <varname>buildArgs</varname> attribute.
-  </para>
-
-  <note>
-   <para>
-    If you see errors similar to <literal>getProtocolByName: does not exist (no such protocol name: tcp)</literal> you may need to add <literal>pkgs.iana-etc</literal> to <varname>contents</varname>.
-   </para>
-  </note>
-
-  <note>
-   <para>
-    If you see errors similar to <literal>Error_Protocol ("certificate has unknown CA",True,UnknownCa)</literal> you may need to add <literal>pkgs.cacert</literal> to <varname>contents</varname>.
-   </para>
-  </note>
-
-  <example xml:id="example-pkgs-dockerTools-buildImage-creation-date">
-   <title>Impurely Defining a Docker Layer's Creation Date</title>
-   <para>
-    By default <function>buildImage</function> will use a static date of one second past the UNIX Epoch. This allows <function>buildImage</function> to produce binary reproducible images. When listing images with <command>docker images</command>, the newly created images will be listed like this:
-   </para>
-<screen>
-<prompt>$ </prompt>docker images
-REPOSITORY   TAG      IMAGE ID       CREATED        SIZE
-hello        latest   08c791c7846e   48 years ago   25.2MB
-</screen>
-   <para>
-    You can break binary reproducibility but have a sorted, meaningful <literal>CREATED</literal> column by setting <literal>created</literal> to <literal>now</literal>.
-   </para>
-<programlisting><![CDATA[
-pkgs.dockerTools.buildImage {
-  name = "hello";
-  tag = "latest";
-  created = "now";
-  contents = pkgs.hello;
-
-  config.Cmd = [ "/bin/hello" ];
-}
-]]></programlisting>
-   <para>
-    and now the Docker CLI will display a reasonable date and sort the images as expected:
-<screen>
-<prompt>$ </prompt>docker images
-REPOSITORY   TAG      IMAGE ID       CREATED              SIZE
-hello        latest   de2bf4786de6   About a minute ago   25.2MB
-</screen>
-    however, the produced images will not be binary reproducible.
-   </para>
-  </example>
- </section>
-
- <section xml:id="ssec-pkgs-dockerTools-buildLayeredImage">
-  <title>buildLayeredImage</title>
-
-  <para>
-   Create a Docker image with many of the store paths being on their own layer to improve sharing between images. The image is realized into the Nix store as a gzipped tarball. Depending on the intended usage, many users might prefer to use <function>streamLayeredImage</function> instead, which this function uses internally.
-  </para>
-
-  <variablelist>
-   <varlistentry>
-    <term>
-     <varname>name</varname>
-    </term>
-    <listitem>
-     <para>
-      The name of the resulting image.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>tag</varname> <emphasis>optional</emphasis>
-    </term>
-    <listitem>
-     <para>
-      Tag of the generated image.
-     </para>
-     <para>
-      <emphasis>Default:</emphasis> the output path's hash
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>contents</varname> <emphasis>optional</emphasis>
-    </term>
-    <listitem>
-     <para>
-      Top level paths in the container. Either a single derivation, or a list of derivations.
-     </para>
-     <para>
-      <emphasis>Default:</emphasis> <literal>[]</literal>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>config</varname> <emphasis>optional</emphasis>
-    </term>
-    <listitem>
-     <para>
-      Run-time configuration of the container. A full list of the options are available at in the <link xlink:href="https://github.com/moby/moby/blob/master/image/spec/v1.2.md#image-json-field-descriptions"> Docker Image Specification v1.2.0 </link>.
-     </para>
-     <para>
-      <emphasis>Default:</emphasis> <literal>{}</literal>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>created</varname> <emphasis>optional</emphasis>
-    </term>
-    <listitem>
-     <para>
-      Date and time the layers were created. Follows the same <literal>now</literal> exception supported by <literal>buildImage</literal>.
-     </para>
-     <para>
-      <emphasis>Default:</emphasis> <literal>1970-01-01T00:00:01Z</literal>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>maxLayers</varname> <emphasis>optional</emphasis>
-    </term>
-    <listitem>
-     <para>
-      Maximum number of layers to create.
-     </para>
-     <para>
-      <emphasis>Default:</emphasis> <literal>100</literal>
-     </para>
-     <para>
-      <emphasis>Maximum:</emphasis> <literal>125</literal>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>extraCommands</varname> <emphasis>optional</emphasis>
-    </term>
-    <listitem>
-     <para>
-      Shell commands to run while building the final layer, without access to most of the layer contents. Changes to this layer are "on top" of all the other layers, so can create additional directories and files.
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
-
-  <section xml:id="dockerTools-buildLayeredImage-arg-contents">
-   <title>Behavior of <varname>contents</varname> in the final image</title>
-
-   <para>
-    Each path directly listed in <varname>contents</varname> will have a symlink in the root of the image.
-   </para>
-
-   <para>
-    For example:
-<programlisting><![CDATA[
-pkgs.dockerTools.buildLayeredImage {
-  name = "hello";
-  contents = [ pkgs.hello ];
-}
-]]></programlisting>
-    will create symlinks for all the paths in the <literal>hello</literal> package:
-<screen><![CDATA[
-/bin/hello -> /nix/store/h1zb1padqbbb7jicsvkmrym3r6snphxg-hello-2.10/bin/hello
-/share/info/hello.info -> /nix/store/h1zb1padqbbb7jicsvkmrym3r6snphxg-hello-2.10/share/info/hello.info
-/share/locale/bg/LC_MESSAGES/hello.mo -> /nix/store/h1zb1padqbbb7jicsvkmrym3r6snphxg-hello-2.10/share/locale/bg/LC_MESSAGES/hello.mo
-]]></screen>
-   </para>
-  </section>
-
-  <section xml:id="dockerTools-buildLayeredImage-arg-config">
-   <title>Automatic inclusion of <varname>config</varname> references</title>
-
-   <para>
-    The closure of <varname>config</varname> is automatically included in the closure of the final image.
-   </para>
-
-   <para>
-    This allows you to make very simple Docker images with very little code. This container will start up and run <command>hello</command>:
-<programlisting><![CDATA[
-pkgs.dockerTools.buildLayeredImage {
-  name = "hello";
-  config.Cmd = [ "${pkgs.hello}/bin/hello" ];
-}
-]]></programlisting>
-   </para>
-  </section>
-
-  <section xml:id="dockerTools-buildLayeredImage-arg-maxLayers">
-   <title>Adjusting <varname>maxLayers</varname></title>
-
-   <para>
-    Increasing the <varname>maxLayers</varname> increases the number of layers which have a chance to be shared between different images.
-   </para>
-
-   <para>
-    Modern Docker installations support up to 128 layers, however older versions support as few as 42.
-   </para>
-
-   <para>
-    If the produced image will not be extended by other Docker builds, it is safe to set <varname>maxLayers</varname> to <literal>128</literal>. However it will be impossible to extend the image further.
-   </para>
-
-   <para>
-    The first (<literal>maxLayers-2</literal>) most "popular" paths will have their own individual layers, then layer #<literal>maxLayers-1</literal> will contain all the remaining "unpopular" paths, and finally layer #<literal>maxLayers</literal> will contain the Image configuration.
-   </para>
-
-   <para>
-    Docker's Layers are not inherently ordered, they are content-addressable and are not explicitly layered until they are composed in to an Image.
-   </para>
-  </section>
- </section>
-
- <section xml:id="ssec-pkgs-dockerTools-streamLayeredImage">
-  <title>streamLayeredImage</title>
-
-  <para>
-   Builds a script which, when run, will stream an uncompressed tarball of a Docker image to stdout. The arguments to this function are as for <function>buildLayeredImage</function>. This method of constructing an image does not realize the image into the Nix store, so it saves on IO and disk/cache space, particularly with large images.
-  </para>
-
-  <para>
-    The image produced by running the output script can be piped directly into <command>docker load</command>, to load it into the local docker daemon:
-    <screen><![CDATA[
-$(nix-build) | docker load
-    ]]></screen>
-  </para>
-  <para>
-    Alternatively, the image be piped via <command>gzip</command> into <command>skopeo</command>, e.g. to copy it into a registry:
-    <screen><![CDATA[
-$(nix-build) | gzip --fast | skopeo copy docker-archive:/dev/stdin docker://some_docker_registry/myimage:tag
-    ]]></screen>
-  </para>
- </section>
-
- <section xml:id="ssec-pkgs-dockerTools-fetchFromRegistry">
-  <title>pullImage</title>
-
-  <para>
-   This function is analogous to the <command>docker pull</command> command, in that it can be used to pull a Docker image from a Docker registry. By default <link xlink:href="https://hub.docker.com/">Docker Hub</link> is used to pull images.
-  </para>
-
-  <para>
-   Its parameters are described in the example below:
-  </para>
-
-  <example xml:id='ex-dockerTools-pullImage'>
-   <title>Docker pull</title>
-<programlisting>
-pullImage {
-  imageName = "nixos/nix"; <co xml:id='ex-dockerTools-pullImage-1' />
-  imageDigest = "sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b"; <co xml:id='ex-dockerTools-pullImage-2' />
-  finalImageName = "nix"; <co xml:id='ex-dockerTools-pullImage-3' />
-  finalImageTag = "1.11";  <co xml:id='ex-dockerTools-pullImage-4' />
-  sha256 = "0mqjy3zq2v6rrhizgb9nvhczl87lcfphq9601wcprdika2jz7qh8"; <co xml:id='ex-dockerTools-pullImage-5' />
-  os = "linux"; <co xml:id='ex-dockerTools-pullImage-6' />
-  arch = "x86_64"; <co xml:id='ex-dockerTools-pullImage-7' />
-}
-</programlisting>
-  </example>
-
-  <calloutlist>
-   <callout arearefs='ex-dockerTools-pullImage-1'>
-    <para>
-     <varname>imageName</varname> specifies the name of the image to be downloaded, which can also include the registry namespace (e.g. <literal>nixos</literal>). This argument is required.
-    </para>
-   </callout>
-   <callout arearefs='ex-dockerTools-pullImage-2'>
-    <para>
-     <varname>imageDigest</varname> specifies the digest of the image to be downloaded. This argument is required.
-    </para>
-   </callout>
-   <callout arearefs='ex-dockerTools-pullImage-3'>
-    <para>
-     <varname>finalImageName</varname>, if specified, this is the name of the image to be created. Note it is never used to fetch the image since we prefer to rely on the immutable digest ID. By default it's equal to <varname>imageName</varname>.
-    </para>
-   </callout>
-   <callout arearefs='ex-dockerTools-pullImage-4'>
-    <para>
-     <varname>finalImageTag</varname>, if specified, this is the tag of the image to be created. Note it is never used to fetch the image since we prefer to rely on the immutable digest ID. By default it's <literal>latest</literal>.
-    </para>
-   </callout>
-   <callout arearefs='ex-dockerTools-pullImage-5'>
-    <para>
-     <varname>sha256</varname> is the checksum of the whole fetched image. This argument is required.
-    </para>
-   </callout>
-   <callout arearefs='ex-dockerTools-pullImage-6'>
-    <para>
-     <varname>os</varname>, if specified, is the operating system of the fetched image. By default it's <literal>linux</literal>.
-    </para>
-   </callout>
-   <callout arearefs='ex-dockerTools-pullImage-7'>
-    <para>
-     <varname>arch</varname>, if specified, is the cpu architecture of the fetched image. By default it's <literal>x86_64</literal>.
-    </para>
-   </callout>
-  </calloutlist>
-
-  <para>
-   <literal>nix-prefetch-docker</literal> command can be used to get required image parameters:
-<screen>
-<prompt>$ </prompt>nix run nixpkgs.nix-prefetch-docker -c nix-prefetch-docker --image-name mysql --image-tag 5
-</screen>
-   Since a given <varname>imageName</varname> may transparently refer to a manifest list of images which support multiple architectures and/or operating systems, you can supply the <option>--os</option> and <option>--arch</option> arguments to specify exactly which image you want. By default it will match the OS and architecture of the host the command is run on.
-<screen>
-<prompt>$ </prompt>nix-prefetch-docker --image-name mysql --image-tag 5 --arch x86_64 --os linux
-</screen>
-   Desired image name and tag can be set using <option>--final-image-name</option> and <option>--final-image-tag</option> arguments:
-<screen>
-<prompt>$ </prompt>nix-prefetch-docker --image-name mysql --image-tag 5 --final-image-name eu.gcr.io/my-project/mysql --final-image-tag prod
-</screen>
-  </para>
- </section>
-
- <section xml:id="ssec-pkgs-dockerTools-exportImage">
-  <title>exportImage</title>
-
-  <para>
-   This function is analogous to the <command>docker export</command> command, in that it can be used to flatten a Docker image that contains multiple layers. It is in fact the result of the merge of all the layers of the image. As such, the result is suitable for being imported in Docker with <command>docker import</command>.
-  </para>
-
-  <note>
-   <para>
-    Using this function requires the <literal>kvm</literal> device to be available.
-   </para>
-  </note>
-
-  <para>
-   The parameters of <varname>exportImage</varname> are the following:
-  </para>
-
-  <example xml:id='ex-dockerTools-exportImage'>
-   <title>Docker export</title>
-<programlisting>
-exportImage {
-  fromImage = someLayeredImage;
-  fromImageName = null;
-  fromImageTag = null;
-
-  name = someLayeredImage.name;
-}
-</programlisting>
-  </example>
-
-  <para>
-   The parameters relative to the base image have the same synopsis as described in <xref linkend='ssec-pkgs-dockerTools-buildImage'/>, except that <varname>fromImage</varname> is the only required argument in this case.
-  </para>
-
-  <para>
-   The <varname>name</varname> argument is the name of the derivation output, which defaults to <varname>fromImage.name</varname>.
-  </para>
- </section>
-
- <section xml:id="ssec-pkgs-dockerTools-shadowSetup">
-  <title>shadowSetup</title>
-
-  <para>
-   This constant string is a helper for setting up the base files for managing users and groups, only if such files don't exist already. It is suitable for being used in a <varname>runAsRoot</varname> <xref linkend='ex-dockerTools-buildImage-runAsRoot'/> script for cases like in the example below:
-  </para>
-
-  <example xml:id='ex-dockerTools-shadowSetup'>
-   <title>Shadow base files</title>
-<programlisting>
-buildImage {
-  name = "shadow-basic";
-
-  runAsRoot = ''
-    #!${pkgs.runtimeShell}
-    ${shadowSetup}
-    groupadd -r redis
-    useradd -r -g redis redis
-    mkdir /data
-    chown redis:redis /data
-  '';
-}
-</programlisting>
-  </example>
-
-  <para>
-   Creating base files like <literal>/etc/passwd</literal> or <literal>/etc/login.defs</literal> is necessary for shadow-utils to manipulate users and groups.
-  </para>
- </section>
-</section>
diff --git a/nixpkgs/doc/builders/images/ocitools.section.md b/nixpkgs/doc/builders/images/ocitools.section.md
new file mode 100644
index 000000000000..d3dee57ebac6
--- /dev/null
+++ b/nixpkgs/doc/builders/images/ocitools.section.md
@@ -0,0 +1,37 @@
+# pkgs.ociTools {#sec-pkgs-ociTools}
+
+`pkgs.ociTools` is a set of functions for creating containers according to the [OCI container specification v1.0.0](https://github.com/opencontainers/runtime-spec). Beyond that it makes no assumptions about the container runner you choose to use to run the created container.
+
+## buildContainer {#ssec-pkgs-ociTools-buildContainer}
+
+This function creates a simple OCI container that runs a single command inside of it. An OCI container consists of a `config.json` and a rootfs directory.The nix store of the container will contain all referenced dependencies of the given command.
+
+The parameters of `buildContainer` with an example value are described below:
+
+```nix
+buildContainer {
+  args = [
+    (with pkgs;
+      writeScript "run.sh" ''
+        #!${bash}/bin/bash
+        exec ${bash}/bin/bash
+      '').outPath
+  ];
+
+  mounts = {
+    "/data" = {
+      type = "none";
+      source = "/var/lib/mydata";
+      options = [ "bind" ];
+    };
+  };
+
+  readonly = false;
+}
+```
+
+- `args` specifies a set of arguments to run inside the container. This is the only required argument for `buildContainer`. All referenced packages inside the derivation will be made available inside the container
+
+- `mounts` specifies additional mount points chosen by the user. By default only a minimal set of necessary filesystems are mounted into the container (e.g procfs, cgroupfs)
+
+- `readonly` makes the container\'s rootfs read-only if it is set to true. The default value is false `false`.
diff --git a/nixpkgs/doc/builders/images/ocitools.xml b/nixpkgs/doc/builders/images/ocitools.xml
deleted file mode 100644
index f26ed8644276..000000000000
--- a/nixpkgs/doc/builders/images/ocitools.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xmlns:xi="http://www.w3.org/2001/XInclude"
-         xml:id="sec-pkgs-ociTools">
- <title>pkgs.ociTools</title>
-
- <para>
-  <varname>pkgs.ociTools</varname> is a set of functions for creating containers according to the <link xlink:href="https://github.com/opencontainers/runtime-spec">OCI container specification v1.0.0</link>. Beyond that it makes no assumptions about the container runner you choose to use to run the created container.
- </para>
-
- <section xml:id="ssec-pkgs-ociTools-buildContainer">
-  <title>buildContainer</title>
-
-  <para>
-   This function creates a simple OCI container that runs a single command inside of it. An OCI container consists of a <varname>config.json</varname> and a rootfs directory.The nix store of the container will contain all referenced dependencies of the given command.
-  </para>
-
-  <para>
-   The parameters of <varname>buildContainer</varname> with an example value are described below:
-  </para>
-
-  <example xml:id='ex-ociTools-buildContainer'>
-   <title>Build Container</title>
-<programlisting>
-buildContainer {
-  args = [ (with pkgs; writeScript "run.sh" ''
-    #!${bash}/bin/bash
-    exec ${bash}/bin/bash
-  '').outPath ]; <co xml:id='ex-ociTools-buildContainer-1' />
-
-  mounts = {
-    "/data" = {
-      type = "none";
-      source = "/var/lib/mydata";
-      options = [ "bind" ];
-    };
-  };<co xml:id='ex-ociTools-buildContainer-2' />
-
-  readonly = false; <co xml:id='ex-ociTools-buildContainer-3' />
-}
-</programlisting>
-   <calloutlist>
-    <callout arearefs='ex-ociTools-buildContainer-1'>
-     <para>
-      <varname>args</varname> specifies a set of arguments to run inside the container. This is the only required argument for <varname>buildContainer</varname>. All referenced packages inside the derivation will be made available inside the container
-     </para>
-    </callout>
-    <callout arearefs='ex-ociTools-buildContainer-2'>
-     <para>
-      <varname>mounts</varname> specifies additional mount points chosen by the user. By default only a minimal set of necessary filesystems are mounted into the container (e.g procfs, cgroupfs)
-     </para>
-    </callout>
-    <callout arearefs='ex-ociTools-buildContainer-3'>
-     <para>
-      <varname>readonly</varname> makes the container's rootfs read-only if it is set to true. The default value is false <literal>false</literal>.
-     </para>
-    </callout>
-   </calloutlist>
-  </example>
- </section>
-</section>
diff --git a/nixpkgs/doc/builders/images/snaptools.xml b/nixpkgs/doc/builders/images/snaptools.xml
index 422fcfa37d88..bbe2e3f5e14c 100644
--- a/nixpkgs/doc/builders/images/snaptools.xml
+++ b/nixpkgs/doc/builders/images/snaptools.xml
@@ -16,7 +16,7 @@
   </para>
 
   <para>
-   The <parameter>base</parameter> should not be be specified, as <function>makeSnap</function> will force set it.
+   The <parameter>base</parameter> should not be specified, as <function>makeSnap</function> will force set it.
   </para>
 
   <para>
diff --git a/nixpkgs/doc/builders/packages/citrix.section.md b/nixpkgs/doc/builders/packages/citrix.section.md
new file mode 100644
index 000000000000..b25ecb0bdefc
--- /dev/null
+++ b/nixpkgs/doc/builders/packages/citrix.section.md
@@ -0,0 +1,32 @@
+# Citrix Workspace {#sec-citrix}
+
+The [Citrix Workspace App](https://www.citrix.com/products/workspace-app/) is a remote desktop viewer which provides access to [XenDesktop](https://www.citrix.com/products/xenapp-xendesktop/) installations.
+
+## Basic usage {#sec-citrix-base}
+
+The tarball archive needs to be downloaded manually as the license agreements of the vendor for [Citrix Workspace](https://www.citrix.de/downloads/workspace-app/linux/workspace-app-for-linux-latest.html) needs to be accepted first. Then run `nix-prefetch-url file://$PWD/linuxx64-$version.tar.gz`. With the archive available in the store the package can be built and installed with Nix.
+
+## Citrix Selfservice {#sec-citrix-selfservice}
+
+The [selfservice](https://support.citrix.com/article/CTX200337) is an application managing Citrix desktops and applications. Please note that this feature only works with at least citrix_workspace_20_06_0 and later versions.
+
+In order to set this up, you first have to [download the `.cr` file from the Netscaler Gateway](https://its.uiowa.edu/support/article/102186). After that you can configure the `selfservice` like this:
+
+```ShellSession
+$ storebrowse -C ~/Downloads/receiverconfig.cr
+$ selfservice
+```
+
+## Custom certificates {#sec-citrix-custom-certs}
+
+The `Citrix Workspace App` in `nixpkgs` trusts several certificates [from the Mozilla database](https://curl.haxx.se/docs/caextract.html) by default. However several companies using Citrix might require their own corporate certificate. On distros with imperative packaging these certs can be stored easily in [`$ICAROOT`](https://developer-docs.citrix.com/projects/receiver-for-linux-command-reference/en/13.7/), however this directory is a store path in `nixpkgs`. In order to work around this issue the package provides a simple mechanism to add custom certificates without rebuilding the entire package using `symlinkJoin`:
+
+```nix
+with import <nixpkgs> { config.allowUnfree = true; };
+let
+  extraCerts = [
+    ./custom-cert-1.pem
+    ./custom-cert-2.pem # ...
+  ];
+in citrix_workspace.override { inherit extraCerts; }
+```
diff --git a/nixpkgs/doc/builders/packages/citrix.xml b/nixpkgs/doc/builders/packages/citrix.xml
deleted file mode 100644
index 803eb2e4fc40..000000000000
--- a/nixpkgs/doc/builders/packages/citrix.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xml:id="sec-citrix">
- <title>Citrix Workspace</title>
-
- <para>
-  The <link xlink:href="https://www.citrix.com/products/workspace-app/">Citrix Workspace App</link> is a remote desktop viewer which provides access to <link xlink:href="https://www.citrix.com/products/xenapp-xendesktop/">XenDesktop</link> installations.
- </para>
-
- <section xml:id="sec-citrix-base">
-  <title>Basic usage</title>
-
-  <para>
-   The tarball archive needs to be downloaded manually as the license agreements of the vendor for <link xlink:href="https://www.citrix.de/downloads/workspace-app/linux/workspace-app-for-linux-latest.html">Citrix Workspace</link> needs to be accepted first. Then run <command>nix-prefetch-url file://$PWD/linuxx64-$version.tar.gz</command>. With the archive available in the store the package can be built and installed with Nix.
-  </para>
- </section>
-
- <section xml:id="sec-citrix-selfservice">
-  <title>Citrix Selfservice</title>
-  <para>
-   The <link xlink:href="https://support.citrix.com/article/CTX200337">selfservice</link> is an application managing Citrix desktops and applications. Please note that this feature only works with at least <package>citrix_workspace_20_06_0</package> and later versions.
-  </para>
-  <para>
-   In order to set this up, you first have to <link xlink:href="https://its.uiowa.edu/support/article/102186">download the <literal>.cr</literal> file from the Netscaler Gateway</link>. After that you can configure the <command>selfservice</command> like this:
-<screen>
-<prompt>$ </prompt>storebrowse -C ~/Downloads/receiverconfig.cr
-<prompt>$ </prompt>selfservice
-</screen>
-  </para>
- </section>
-
- <section xml:id="sec-citrix-custom-certs">
-  <title>Custom certificates</title>
-
-  <para>
-   The <literal>Citrix Workspace App</literal> in <literal>nixpkgs</literal> trusts several certificates <link xlink:href="https://curl.haxx.se/docs/caextract.html">from the Mozilla database</link> by default. However several companies using Citrix might require their own corporate certificate. On distros with imperative packaging these certs can be stored easily in <link xlink:href="https://developer-docs.citrix.com/projects/receiver-for-linux-command-reference/en/13.7/"><literal>$ICAROOT</literal></link>, however this directory is a store path in <literal>nixpkgs</literal>. In order to work around this issue the package provides a simple mechanism to add custom certificates without rebuilding the entire package using <literal>symlinkJoin</literal>:
-<programlisting>
-<![CDATA[with import <nixpkgs> { config.allowUnfree = true; };
-let extraCerts = [ ./custom-cert-1.pem ./custom-cert-2.pem /* ... */ ]; in
-citrix_workspace.override {
-  inherit extraCerts;
-}]]>
-</programlisting>
-  </para>
- </section>
-</section>
diff --git a/nixpkgs/doc/builders/packages/eclipse.section.md b/nixpkgs/doc/builders/packages/eclipse.section.md
new file mode 100644
index 000000000000..faabb1884501
--- /dev/null
+++ b/nixpkgs/doc/builders/packages/eclipse.section.md
@@ -0,0 +1,64 @@
+# Eclipse {#sec-eclipse}
+
+The Nix expressions related to the Eclipse platform and IDE are in [`pkgs/applications/editors/eclipse`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/eclipse).
+
+Nixpkgs provides a number of packages that will install Eclipse in its various forms. These range from the bare-bones Eclipse Platform to the more fully featured Eclipse SDK or Scala-IDE packages and multiple version are often available. It is possible to list available Eclipse packages by issuing the command:
+
+```ShellSession
+$ nix-env -f '<nixpkgs>' -qaP -A eclipses --description
+```
+
+Once an Eclipse variant is installed it can be run using the `eclipse` command, as expected. From within Eclipse it is then possible to install plugins in the usual manner by either manually specifying an Eclipse update site or by installing the Marketplace Client plugin and using it to discover and install other plugins. This installation method provides an Eclipse installation that closely resemble a manually installed Eclipse.
+
+If you prefer to install plugins in a more declarative manner then Nixpkgs also offer a number of Eclipse plugins that can be installed in an _Eclipse environment_. This type of environment is created using the function `eclipseWithPlugins` found inside the `nixpkgs.eclipses` attribute set. This function takes as argument `{ eclipse, plugins ? [], jvmArgs ? [] }` where `eclipse` is a one of the Eclipse packages described above, `plugins` is a list of plugin derivations, and `jvmArgs` is a list of arguments given to the JVM running the Eclipse. For example, say you wish to install the latest Eclipse Platform with the popular Eclipse Color Theme plugin and also allow Eclipse to use more RAM. You could then add
+
+```nix
+packageOverrides = pkgs: {
+  myEclipse = with pkgs.eclipses; eclipseWithPlugins {
+    eclipse = eclipse-platform;
+    jvmArgs = [ "-Xmx2048m" ];
+    plugins = [ plugins.color-theme ];
+  };
+}
+```
+
+to your Nixpkgs configuration (`~/.config/nixpkgs/config.nix`) and install it by running `nix-env -f '<nixpkgs>' -iA myEclipse` and afterward run Eclipse as usual. It is possible to find out which plugins are available for installation using `eclipseWithPlugins` by running
+
+```ShellSession
+$ nix-env -f '<nixpkgs>' -qaP -A eclipses.plugins --description
+```
+
+If there is a need to install plugins that are not available in Nixpkgs then it may be possible to define these plugins outside Nixpkgs using the `buildEclipseUpdateSite` and `buildEclipsePlugin` functions found in the `nixpkgs.eclipses.plugins` attribute set. Use the `buildEclipseUpdateSite` function to install a plugin distributed as an Eclipse update site. This function takes `{ name, src }` as argument where `src` indicates the Eclipse update site archive. All Eclipse features and plugins within the downloaded update site will be installed. When an update site archive is not available then the `buildEclipsePlugin` function can be used to install a plugin that consists of a pair of feature and plugin JARs. This function takes an argument `{ name, srcFeature, srcPlugin }` where `srcFeature` and `srcPlugin` are the feature and plugin JARs, respectively.
+
+Expanding the previous example with two plugins using the above functions we have
+
+```nix
+packageOverrides = pkgs: {
+  myEclipse = with pkgs.eclipses; eclipseWithPlugins {
+    eclipse = eclipse-platform;
+    jvmArgs = [ "-Xmx2048m" ];
+    plugins = [
+      plugins.color-theme
+      (plugins.buildEclipsePlugin {
+        name = "myplugin1-1.0";
+        srcFeature = fetchurl {
+          url = "http://…/features/myplugin1.jar";
+          sha256 = "123…";
+        };
+        srcPlugin = fetchurl {
+          url = "http://…/plugins/myplugin1.jar";
+          sha256 = "123…";
+        };
+      });
+      (plugins.buildEclipseUpdateSite {
+        name = "myplugin2-1.0";
+        src = fetchurl {
+          stripRoot = false;
+          url = "http://…/myplugin2.zip";
+          sha256 = "123…";
+        };
+      });
+    ];
+  };
+}
+```
diff --git a/nixpkgs/doc/builders/packages/eclipse.xml b/nixpkgs/doc/builders/packages/eclipse.xml
deleted file mode 100644
index fc5094ed8f36..000000000000
--- a/nixpkgs/doc/builders/packages/eclipse.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xml:id="sec-eclipse">
- <title>Eclipse</title>
-
- <para>
-  The Nix expressions related to the Eclipse platform and IDE are in <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/eclipse"><filename>pkgs/applications/editors/eclipse</filename></link>.
- </para>
-
- <para>
-  Nixpkgs provides a number of packages that will install Eclipse in its various forms. These range from the bare-bones Eclipse Platform to the more fully featured Eclipse SDK or Scala-IDE packages and multiple version are often available. It is possible to list available Eclipse packages by issuing the command:
-<screen>
-<prompt>$ </prompt>nix-env -f '&lt;nixpkgs&gt;' -qaP -A eclipses --description
-</screen>
-  Once an Eclipse variant is installed it can be run using the <command>eclipse</command> command, as expected. From within Eclipse it is then possible to install plugins in the usual manner by either manually specifying an Eclipse update site or by installing the Marketplace Client plugin and using it to discover and install other plugins. This installation method provides an Eclipse installation that closely resemble a manually installed Eclipse.
- </para>
-
- <para>
-  If you prefer to install plugins in a more declarative manner then Nixpkgs also offer a number of Eclipse plugins that can be installed in an <emphasis>Eclipse environment</emphasis>. This type of environment is created using the function <varname>eclipseWithPlugins</varname> found inside the <varname>nixpkgs.eclipses</varname> attribute set. This function takes as argument <literal>{ eclipse, plugins ? [], jvmArgs ? [] }</literal> where <varname>eclipse</varname> is a one of the Eclipse packages described above, <varname>plugins</varname> is a list of plugin derivations, and <varname>jvmArgs</varname> is a list of arguments given to the JVM running the Eclipse. For example, say you wish to install the latest Eclipse Platform with the popular Eclipse Color Theme plugin and also allow Eclipse to use more RAM. You could then add
-<screen>
-packageOverrides = pkgs: {
-  myEclipse = with pkgs.eclipses; eclipseWithPlugins {
-    eclipse = eclipse-platform;
-    jvmArgs = [ "-Xmx2048m" ];
-    plugins = [ plugins.color-theme ];
-  };
-}
-</screen>
-  to your Nixpkgs configuration (<filename>~/.config/nixpkgs/config.nix</filename>) and install it by running <command>nix-env -f '&lt;nixpkgs&gt;' -iA myEclipse</command> and afterward run Eclipse as usual. It is possible to find out which plugins are available for installation using <varname>eclipseWithPlugins</varname> by running
-<screen>
-<prompt>$ </prompt>nix-env -f '&lt;nixpkgs&gt;' -qaP -A eclipses.plugins --description
-</screen>
- </para>
-
- <para>
-  If there is a need to install plugins that are not available in Nixpkgs then it may be possible to define these plugins outside Nixpkgs using the <varname>buildEclipseUpdateSite</varname> and <varname>buildEclipsePlugin</varname> functions found in the <varname>nixpkgs.eclipses.plugins</varname> attribute set. Use the <varname>buildEclipseUpdateSite</varname> function to install a plugin distributed as an Eclipse update site. This function takes <literal>{ name, src }</literal> as argument where <literal>src</literal> indicates the Eclipse update site archive. All Eclipse features and plugins within the downloaded update site will be installed. When an update site archive is not available then the <varname>buildEclipsePlugin</varname> function can be used to install a plugin that consists of a pair of feature and plugin JARs. This function takes an argument <literal>{ name, srcFeature, srcPlugin }</literal> where <literal>srcFeature</literal> and <literal>srcPlugin</literal> are the feature and plugin JARs, respectively.
- </para>
-
- <para>
-  Expanding the previous example with two plugins using the above functions we have
-<screen>
-packageOverrides = pkgs: {
-  myEclipse = with pkgs.eclipses; eclipseWithPlugins {
-    eclipse = eclipse-platform;
-    jvmArgs = [ "-Xmx2048m" ];
-    plugins = [
-      plugins.color-theme
-      (plugins.buildEclipsePlugin {
-        name = "myplugin1-1.0";
-        srcFeature = fetchurl {
-          url = "http://…/features/myplugin1.jar";
-          sha256 = "123…";
-        };
-        srcPlugin = fetchurl {
-          url = "http://…/plugins/myplugin1.jar";
-          sha256 = "123…";
-        };
-      });
-      (plugins.buildEclipseUpdateSite {
-        name = "myplugin2-1.0";
-        src = fetchurl {
-          stripRoot = false;
-          url = "http://…/myplugin2.zip";
-          sha256 = "123…";
-        };
-      });
-    ];
-  };
-}
-</screen>
- </para>
-</section>
diff --git a/nixpkgs/doc/builders/packages/emacs.section.md b/nixpkgs/doc/builders/packages/emacs.section.md
index b4723a22bb1c..93a819bc79bf 100644
--- a/nixpkgs/doc/builders/packages/emacs.section.md
+++ b/nixpkgs/doc/builders/packages/emacs.section.md
@@ -36,7 +36,7 @@ You can install it like any other packages via `nix-env -iA myEmacs`. However, t
       ;; load some packages
 
       (use-package company
-        :bind ("&lt;C-tab&gt;" . company-complete)
+        :bind ("<C-tab>" . company-complete)
         :diminish company-mode
         :commands (company-mode global-company-mode)
         :defer 1
diff --git a/nixpkgs/doc/builders/packages/fuse.section.md b/nixpkgs/doc/builders/packages/fuse.section.md
new file mode 100644
index 000000000000..5603481115e7
--- /dev/null
+++ b/nixpkgs/doc/builders/packages/fuse.section.md
@@ -0,0 +1,19 @@
+# FUSE {#sec-fuse}
+
+Some packages rely on
+[FUSE](https://www.kernel.org/doc/html/latest/filesystems/fuse.html) to provide
+support for additional filesystems not supported by the kernel.
+
+In general, FUSE software are primarily developed for Linux but many of them can
+also run on macOS. Nixpkgs supports FUSE packages on macOS, but it requires
+[macFUSE](https://osxfuse.github.io) to be installed outside of Nix. macFUSE
+currently isn't packaged in Nixpkgs mainly because it includes a kernel
+extension, which isn't supported by Nix outside of NixOS.
+
+If a package fails to run on macOS with an error message similar to the
+following, it's a likely sign that you need to have macFUSE installed.
+
+    dyld: Library not loaded: /usr/local/lib/libfuse.2.dylib
+    Referenced from: /nix/store/w8bi72bssv0bnxhwfw3xr1mvn7myf37x-sshfs-fuse-2.10/bin/sshfs
+    Reason: image not found
+    [1]    92299 abort      /nix/store/w8bi72bssv0bnxhwfw3xr1mvn7myf37x-sshfs-fuse-2.10/bin/sshfs
diff --git a/nixpkgs/doc/builders/packages/ibus.section.md b/nixpkgs/doc/builders/packages/ibus.section.md
new file mode 100644
index 000000000000..2ce85467bb86
--- /dev/null
+++ b/nixpkgs/doc/builders/packages/ibus.section.md
@@ -0,0 +1,38 @@
+# ibus-engines.typing-booster {#sec-ibus-typing-booster}
+
+This package is an ibus-based completion method to speed up typing.
+
+## Activating the engine {#sec-ibus-typing-booster-activate}
+
+IBus needs to be configured accordingly to activate `typing-booster`. The configuration depends on the desktop manager in use. For detailed instructions, please refer to the [upstream docs](https://mike-fabian.github.io/ibus-typing-booster/documentation.html).
+
+On NixOS you need to explicitly enable `ibus` with given engines before customizing your desktop to use `typing-booster`. This can be achieved using the `ibus` module:
+
+```nix
+{ pkgs, ... }: {
+  i18n.inputMethod = {
+    enabled = "ibus";
+    ibus.engines = with pkgs.ibus-engines; [ typing-booster ];
+  };
+}
+```
+
+## Using custom hunspell dictionaries {#sec-ibus-typing-booster-customize-hunspell}
+
+The IBus engine is based on `hunspell` to support completion in many languages. By default the dictionaries `de-de`, `en-us`, `fr-moderne` `es-es`, `it-it`, `sv-se` and `sv-fi` are in use. To add another dictionary, the package can be overridden like this:
+
+```nix
+ibus-engines.typing-booster.override { langs = [ "de-at" "en-gb" ]; }
+```
+
+_Note: each language passed to `langs` must be an attribute name in `pkgs.hunspellDicts`._
+
+## Built-in emoji picker {#sec-ibus-typing-booster-emoji-picker}
+
+The `ibus-engines.typing-booster` package contains a program named `emoji-picker`. To display all emojis correctly, a special font such as `noto-fonts-emoji` is needed:
+
+On NixOS it can be installed using the following expression:
+
+```nix
+{ pkgs, ... }: { fonts.fonts = with pkgs; [ noto-fonts-emoji ]; }
+```
diff --git a/nixpkgs/doc/builders/packages/ibus.xml b/nixpkgs/doc/builders/packages/ibus.xml
deleted file mode 100644
index 2ed37903a273..000000000000
--- a/nixpkgs/doc/builders/packages/ibus.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<section xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xml:id="sec-ibus-typing-booster">
- <title>ibus-engines.typing-booster</title>
-
- <para>
-  This package is an ibus-based completion method to speed up typing.
- </para>
-
- <section xml:id="sec-ibus-typing-booster-activate">
-  <title>Activating the engine</title>
-
-  <para>
-   IBus needs to be configured accordingly to activate <literal>typing-booster</literal>. The configuration depends on the desktop manager in use. For detailed instructions, please refer to the <link xlink:href="https://mike-fabian.github.io/ibus-typing-booster/documentation.html">upstream docs</link>.
-  </para>
-
-  <para>
-   On NixOS you need to explicitly enable <literal>ibus</literal> with given engines before customizing your desktop to use <literal>typing-booster</literal>. This can be achieved using the <literal>ibus</literal> module:
-<programlisting>{ pkgs, ... }: {
-  i18n.inputMethod = {
-    enabled = "ibus";
-    ibus.engines = with pkgs.ibus-engines; [ typing-booster ];
-  };
-}</programlisting>
-  </para>
- </section>
-
- <section xml:id="sec-ibus-typing-booster-customize-hunspell">
-  <title>Using custom hunspell dictionaries</title>
-
-  <para>
-   The IBus engine is based on <literal>hunspell</literal> to support completion in many languages. By default the dictionaries <literal>de-de</literal>, <literal>en-us</literal>, <literal>fr-moderne</literal> <literal>es-es</literal>, <literal>it-it</literal>, <literal>sv-se</literal> and <literal>sv-fi</literal> are in use. To add another dictionary, the package can be overridden like this:
-<programlisting>ibus-engines.typing-booster.override {
-  langs = [ "de-at" "en-gb" ];
-}</programlisting>
-  </para>
-
-  <para>
-   <emphasis>Note: each language passed to <literal>langs</literal> must be an attribute name in <literal>pkgs.hunspellDicts</literal>.</emphasis>
-  </para>
- </section>
-
- <section xml:id="sec-ibus-typing-booster-emoji-picker">
-  <title>Built-in emoji picker</title>
-
-  <para>
-   The <literal>ibus-engines.typing-booster</literal> package contains a program named <literal>emoji-picker</literal>. To display all emojis correctly, a special font such as <literal>noto-fonts-emoji</literal> is needed:
-  </para>
-
-  <para>
-   On NixOS it can be installed using the following expression:
-<programlisting>{ pkgs, ... }: {
-  fonts.fonts = with pkgs; [ noto-fonts-emoji ];
-}</programlisting>
-  </para>
- </section>
-</section>
diff --git a/nixpkgs/doc/builders/packages/index.xml b/nixpkgs/doc/builders/packages/index.xml
index e4f8a1d3120e..a2bcd4315311 100644
--- a/nixpkgs/doc/builders/packages/index.xml
+++ b/nixpkgs/doc/builders/packages/index.xml
@@ -5,14 +5,15 @@
  <para>
   This chapter contains information about how to use and maintain the Nix expressions for a number of specific packages, such as the Linux kernel or X.org.
  </para>
- <xi:include href="citrix.xml" />
+ <xi:include href="citrix.section.xml" />
  <xi:include href="dlib.xml" />
- <xi:include href="eclipse.xml" />
+ <xi:include href="eclipse.section.xml" />
  <xi:include href="elm.section.xml" />
  <xi:include href="emacs.section.xml" />
  <xi:include href="firefox.section.xml" />
  <xi:include href="fish.section.xml" />
- <xi:include href="ibus.xml" />
+ <xi:include href="fuse.section.xml" />
+ <xi:include href="ibus.section.xml" />
  <xi:include href="kakoune.section.xml" />
  <xi:include href="linux.section.xml" />
  <xi:include href="locales.section.xml" />
diff --git a/nixpkgs/doc/contributing/coding-conventions.xml b/nixpkgs/doc/contributing/coding-conventions.xml
index 9005a9ebafd6..9f00942918c0 100644
--- a/nixpkgs/doc/contributing/coding-conventions.xml
+++ b/nixpkgs/doc/contributing/coding-conventions.xml
@@ -180,17 +180,12 @@ args.stdenv.mkDerivation (args // {
    </listitem>
    <listitem>
     <para>
-     Arguments should be listed in the order they are used, with the
-     exception of <varname>lib</varname>, which always goes first.
+     Arguments should be listed in the order they are used, with the exception of <varname>lib</varname>, which always goes first.
     </para>
    </listitem>
    <listitem>
     <para>
-     Prefer using the top-level <varname>lib</varname> over its alias
-     <literal>stdenv.lib</literal>.  <varname>lib</varname> is unrelated to
-     <varname>stdenv</varname>, and so <literal>stdenv.lib</literal> should only
-     be used as a convenience alias when developing to avoid having to modify
-     the function inputs just to test something out.
+     Prefer using the top-level <varname>lib</varname> over its alias <literal>stdenv.lib</literal>. <varname>lib</varname> is unrelated to <varname>stdenv</varname>, and so <literal>stdenv.lib</literal> should only be used as a convenience alias when developing to avoid having to modify the function inputs just to test something out.
     </para>
    </listitem>
   </itemizedlist>
@@ -689,8 +684,7 @@ args.stdenv.mkDerivation (args // {
        </varlistentry>
        <varlistentry>
         <term>
-         If it’s a <emphasis>theme</emphasis> for a <emphasis>desktop environment</emphasis>,
-         a <emphasis>window manager</emphasis> or a <emphasis>display manager</emphasis>:
+         If it’s a <emphasis>theme</emphasis> for a <emphasis>desktop environment</emphasis>, a <emphasis>window manager</emphasis> or a <emphasis>display manager</emphasis>:
         </term>
         <listitem>
          <para>
diff --git a/nixpkgs/doc/contributing/submitting-changes.chapter.md b/nixpkgs/doc/contributing/submitting-changes.chapter.md
index 40fc5ea78921..13f15b929cfc 100644
--- a/nixpkgs/doc/contributing/submitting-changes.chapter.md
+++ b/nixpkgs/doc/contributing/submitting-changes.chapter.md
@@ -68,15 +68,16 @@
 
 Security fixes are submitted in the same way as other changes and thus the same guidelines apply.
 
-If the security fix comes in the form of a patch and a CVE is available, then the name of the patch should be the CVE identifier, so e.g. `CVE-2019-13636.patch` in the case of a patch that is included in the Nixpkgs tree. If a patch is fetched the name needs to be set as well, e.g.:
-
-```nix
-(fetchpatch {
-  name = "CVE-2019-11068.patch";
-  url = "https://gitlab.gnome.org/GNOME/libxslt/commit/e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch";
-  sha256 = "0pkpb4837km15zgg6h57bncp66d5lwrlvkr73h0lanywq7zrwhj8";
-})
-```
+- If a new version fixing the vulnerability has been released, update the package;
+- If the security fix comes in the form of a patch and a CVE is available, then add the patch to the Nixpkgs tree, and apply it to the package.
+  The name of the patch should be the CVE identifier, so e.g. `CVE-2019-13636.patch`; If a patch is fetched the name needs to be set as well, e.g.:
+  ```nix
+  (fetchpatch {
+    name = "CVE-2019-11068.patch";
+    url = "https://gitlab.gnome.org/GNOME/libxslt/commit/e03553605b45c88f0b4b2980adfbbb8f6fca2fd6.patch";
+    sha256 = "0pkpb4837km15zgg6h57bncp66d5lwrlvkr73h0lanywq7zrwhj8";
+  })
+  ```
 
 If a security fix applies to both master and a stable release then, similar to regular changes, they are preferably delivered via master first and cherry-picked to the release branch.
 
@@ -174,10 +175,13 @@ digraph {
     "staging-next" -> master [color="#E85EB0"] [label="stabilization ends"] [fontcolor="#E85EB0"]
     "staging" -> "staging-next" [color="#E85EB0"] [label="stabilization starts"] [fontcolor="#E85EB0"]
 
-    master -> "staging-next" -> staging [color="#5F5EE8"] [label="every six hours/any time"] [fontcolor="#5F5EE8"]
+    master -> "staging-next" -> staging [color="#5F5EE8"] [label="every six hours (GitHub Action)"] [fontcolor="#5F5EE8"]
 }
 ```
 
+[This GitHub Action](https://github.com/NixOS/nixpkgs/blob/master/.github/workflows/merge-staging.yml) brings changes from `master` to `staging-next` and from `staging-next` to `staging` every 6 hours.
+
+
 ### Master branch {#submitting-changes-master-branch}
 
 The `master` branch is the main development branch. It should only see non-breaking commits that do not cause mass rebuilds.
diff --git a/nixpkgs/doc/contributing/vulnerability-roundup.chapter.md b/nixpkgs/doc/contributing/vulnerability-roundup.chapter.md
new file mode 100644
index 000000000000..d451420f9815
--- /dev/null
+++ b/nixpkgs/doc/contributing/vulnerability-roundup.chapter.md
@@ -0,0 +1,45 @@
+# Vulnerability Roundup {#chap-vulnerability-roundup}
+
+## Issues {#vulnerability-roundup-issues}
+
+Vulnerable packages in Nixpkgs are managed using issues.
+Currently opened ones can be found using the following:
+
+[github.com/NixOS/nixpkgs/issues?q=is:issue+is:open+"Vulnerability+roundup"](https://github.com/NixOS/nixpkgs/issues?q=is%3Aissue+is%3Aopen+%22Vulnerability+roundup%22)
+
+Each issue correspond to a vulnerable version of a package; As a consequence:
+
+- One issue can contain several CVEs;
+- One CVE can be shared across several issues;
+- A single package can be concerned by several issues.
+
+
+A "Vulnerability roundup" issue usually respects the following format:
+
+```txt
+<link to relevant package search on search.nix.gsc.io>, <link to relevant files in Nixpkgs on GitHub>
+
+<list of related CVEs, their CVSS score, and the impacted NixOS version>
+
+<list of the scanned Nixpkgs versions>
+
+<list of relevant contributors>
+```
+
+Note that there can be an extra comment containing links to previously reported (and still open) issues for the same package.
+
+
+## Triaging and Fixing {#vulnerability-roundup-triaging-and-fixing}
+
+**Note**: An issue can be a "false positive" (i.e. automatically opened, but without the package it refers to being actually vulnerable).
+If you find such a "false positive", comment on the issue an explanation of why it falls into this category, linking as much information as the necessary to help maintainers double check.
+
+If you are investigating a "true positive":
+
+- Find the earliest patched version or a code patch in the CVE details;
+- Is the issue already patched (version up-to-date or patch applied manually) in Nixpkgs's `master` branch?
+  - **No**:
+    - [Submit a security fix](#submitting-changes-submitting-security-fixes);
+    - Once the fix is merged into `master`, [submit the change to the vulnerable release branch(es)](https://nixos.org/manual/nixpkgs/stable/#submitting-changes-stable-release-branches);
+  - **Yes**: [Backport the change to the vulnerable release branch(es)](https://nixos.org/manual/nixpkgs/stable/#submitting-changes-stable-release-branches).
+- When the patch has made it into all the relevant branches (`master`, and the vulnerable releases), close the relevant issue(s).
diff --git a/nixpkgs/doc/functions/library/attrsets.xml b/nixpkgs/doc/functions/library/attrsets.xml
index 7ef0d16624c8..de8414249abf 100644
--- a/nixpkgs/doc/functions/library/attrsets.xml
+++ b/nixpkgs/doc/functions/library/attrsets.xml
@@ -7,7 +7,7 @@
  <section xml:id="function-library-lib.attrsets.attrByPath">
   <title><function>lib.attrset.attrByPath</function></title>
 
-  <subtitle><literal>attrByPath :: [String] -> Any -> AttrSet</literal>
+  <subtitle><literal>attrByPath :: [String] -> Any -> AttrSet -> Any</literal>
   </subtitle>
 
   <xi:include href="./locations.xml" xpointer="lib.attrsets.attrByPath" />
@@ -1677,8 +1677,7 @@ recursiveUpdate
   <xi:include href="./locations.xml" xpointer="lib.attrsets.recurseIntoAttrs" />
 
   <para>
-   Make various Nix tools consider the contents of the resulting
-   attribute set when looking for what to build, find, etc.
+   Make various Nix tools consider the contents of the resulting attribute set when looking for what to build, find, etc.
   </para>
 
   <para>
@@ -1720,7 +1719,7 @@ recursiveUpdate
   <xi:include href="./locations.xml" xpointer="lib.attrsets.cartesianProductOfSets" />
 
   <para>
-    Return the cartesian product of attribute set value combinations.
+   Return the cartesian product of attribute set value combinations.
   </para>
 
   <variablelist>
@@ -1749,5 +1748,4 @@ cartesianProductOfSets { a = [ 1 2 ]; b = [ 10 20 ]; }
 ]]></programlisting>
   </example>
  </section>
-
 </section>
diff --git a/nixpkgs/doc/languages-frameworks/agda.section.md b/nixpkgs/doc/languages-frameworks/agda.section.md
index f57b194a7266..30a266502bf3 100644
--- a/nixpkgs/doc/languages-frameworks/agda.section.md
+++ b/nixpkgs/doc/languages-frameworks/agda.section.md
@@ -3,7 +3,7 @@
 ## How to use Agda
 
 Agda can be installed from `agda`:
-```
+```ShellSession
 $ nix-env -iA agda
 ```
 
@@ -15,13 +15,13 @@ To use Agda with libraries, the `agda.withPackages` function can be used. This f
 
 For example, suppose we wanted a version of Agda which has access to the standard library. This can be obtained with the expressions:
 
-```
+```nix
 agda.withPackages [ agdaPackages.standard-library ]
 ```
 
 or
 
-```
+```nix
 agda.withPackages (p: [ p.standard-library ])
 ```
 
@@ -32,7 +32,7 @@ If you want to use a library in your home directory (for instance if it is a dev
 Agda will not by default use these libraries. To tell Agda to use the library we have some options:
 
 * Call `agda` with the library flag:
-```
+```ShellSession
 $ agda -l standard-library -i . MyFile.agda
 ```
 * Write a `my-library.agda-lib` file for the project you are working on which may look like:
@@ -49,7 +49,7 @@ More information can be found in the [official Agda documentation on library man
 Agda modules can be compiled with the `--compile` flag. A version of `ghc` with `ieee754` is made available to the Agda program via the `--with-compiler` flag.
 This can be overridden by a different version of `ghc` as follows:
 
-```
+```nix
 agda.withPackages {
   pkgs = [ ... ];
   ghc = haskell.compiler.ghcHEAD;
@@ -80,12 +80,12 @@ By default, Agda sources are files ending on `.agda`, or literate Agda files end
 ## Adding Agda packages to Nixpkgs
 
 To add an Agda package to `nixpkgs`, the derivation should be written to `pkgs/development/libraries/agda/${library-name}/` and an entry should be added to `pkgs/top-level/agda-packages.nix`. Here it is called in a scope with access to all other Agda libraries, so the top line of the `default.nix` can look like:
-```
+```nix
 { mkDerivation, standard-library, fetchFromGitHub }:
 ```
 and `mkDerivation` should be called instead of `agdaPackages.mkDerivation`. Here is an example skeleton derivation for iowa-stdlib:
 
-```
+```nix
 mkDerivation {
   version = "1.5.0";
   pname = "iowa-stdlib";
diff --git a/nixpkgs/doc/languages-frameworks/android.section.md b/nixpkgs/doc/languages-frameworks/android.section.md
index 62e544cd48b6..416073df078e 100644
--- a/nixpkgs/doc/languages-frameworks/android.section.md
+++ b/nixpkgs/doc/languages-frameworks/android.section.md
@@ -80,7 +80,7 @@ Most of the function arguments have reasonable default settings.
 
 You can specify license names:
 
-* `extraLicenses` is a list of of license names.
+* `extraLicenses` is a list of license names.
   You can get these names from repo.json or `querypackages.sh licenses`. The SDK
   license (`android-sdk-license`) is accepted for you if you set accept_license
   to true. If you are doing something like working with preview SDKs, you will
diff --git a/nixpkgs/doc/languages-frameworks/coq.section.md b/nixpkgs/doc/languages-frameworks/coq.section.md
index 8f564c6e46b6..5964d46e2f80 100644
--- a/nixpkgs/doc/languages-frameworks/coq.section.md
+++ b/nixpkgs/doc/languages-frameworks/coq.section.md
@@ -21,8 +21,8 @@ The recommended way of defining a derivation for a Coq library, is to use the `c
   * if it is a string of the form `owner:branch` then it tries to download the `branch` of owner `owner` for a project of the same name using the same vcs, and the `version` attribute of the resulting derivation is set to `"dev"`, additionally if the owner is not provided (i.e. if the `owner:` prefix is missing), it defaults to the original owner of the package (see below),
   * if it is a string of the form `"#N"`, and the domain is github, then it tries to download the current head of the pull request `#N` from github,
 * `defaultVersion` (optional). Coq libraries may be compatible with some specific versions of Coq only. The `defaultVersion` attribute is used when no `version` is provided (or if `version = null`) to select the version of the library to use by default, depending on the context. This selection will mainly depend on a `coq` version number but also possibly on other packages versions (e.g. `mathcomp`). If its value ends up to be `null`, the package is marked for removal in end-user `coqPackages` attribute set.
-* `release` (optional, defaults to `{}`), lists all the known releases of the library and for each of them provides an attribute set with at least a `sha256` attribute (you may use the shell command `nix-prefetch-url --unpack <archive-url>` to find it, where `<archive-url>` is for example `https://github.com/owner/repo/archive/version.tar.gz`), each attribute set of the list of releases also takes optional overloading arguments for the fetcher as below (i.e.`domain`, `owner`, `repo`, `rev` assuming the default fetcher is used) and optional overrides for the result of the fetcher (i.e. `version` and `src`).
-* `fetcher` (optional, default to a generic fetching mechanism supporting github or gitlab based infrastructures), is a function that takes at least an `owner`, a `repo`, a `rev`, and a `sha256` and returns an attribute set with a `version` and `src`.
+* `release` (optional, defaults to `{}`), lists all the known releases of the library and for each of them provides an attribute set with at least a `sha256` attribute (you may put the empty string `""` in order to automatically insert a fake sha256, this will trigger an error which will allow you to find the correct sha256), each attribute set of the list of releases also takes optional overloading arguments for the fetcher as below (i.e.`domain`, `owner`, `repo`, `rev` assuming the default fetcher is used) and optional overrides for the result of the fetcher (i.e. `version` and `src`).
+* `fetcher` (optional, defaults to a generic fetching mechanism supporting github or gitlab based infrastructures), is a function that takes at least an `owner`, a `repo`, a `rev`, and a `sha256` and returns an attribute set with a `version` and `src`.
 * `repo` (optional, defaults to the value of `pname`),
 * `owner` (optional, defaults to `"coq-community"`).
 * `domain` (optional, defaults to `"github.com"`), domains including the strings `"github"` or `"gitlab"` in their names are automatically supported, otherwise, one must change the `fetcher` argument to support them (cf `pkgs/development/coq-modules/heq/default.nix` for an example),
@@ -31,6 +31,8 @@ The recommended way of defining a derivation for a Coq library, is to use the `c
 * `namePrefix` (optional), provides a way to alter the computation of `name` from `pname`, by explaining which dependencies must occur in `name`,
 * `extraBuildInputs` (optional), by default `buildInputs` just contains `coq`, this allows to add more build inputs,
 * `mlPlugin` (optional, defaults to `false`). Some extensions (plugins) might require OCaml and sometimes other OCaml packages. Standard dependencies can be added by setting the current option to `true`. For a finer grain control, the `coq.ocamlPackages` attribute can be used in `extraBuildInputs` to depend on the same package set Coq was built against.
+* `useDune2ifVersion` (optional, default to `(x: false)` uses Dune2 to build the package if the provided predicate evaluates to true on the version, e.g. `useDune2if = versions.isGe "1.1"`  will use dune if the version of the package is greater or equal to `"1.1"`,
+* `useDune2` (optional, defaults to `false`) uses Dune2 to build the package if set to true, the presence of this attribute overrides the behavior of the previous one.
 * `enableParallelBuilding` (optional, defaults to `true`), since it is activated by default, we provide a way to disable it.
 * `extraInstallFlags` (optional), allows to extend `installFlags` which initializes the variable `COQMF_COQLIB` so as to install in the proper subdirectory. Indeed Coq libraries should be installed in `$(out)/lib/coq/${coq.coq-version}/user-contrib/`. Such directories are automatically added to the `$COQPATH` environment variable by the hook defined in the Coq derivation.
 * `setCOQBIN` (optional, defaults to `true`), by default, the environment variable `$COQBIN` is set to the current Coq's binary, but one can disable this behavior by setting it to `false`,
diff --git a/nixpkgs/doc/languages-frameworks/dotnet.section.md b/nixpkgs/doc/languages-frameworks/dotnet.section.md
index 88fd74db8256..36369fd4e634 100644
--- a/nixpkgs/doc/languages-frameworks/dotnet.section.md
+++ b/nixpkgs/doc/languages-frameworks/dotnet.section.md
@@ -4,7 +4,7 @@
 
 For local development, it's recommended to use nix-shell to create a dotnet environment:
 
-```
+```nix
 # shell.nix
 with import <nixpkgs> {};
 
@@ -20,7 +20,7 @@ mkShell {
 
 It's very likely that more than one sdk will be needed on a given project. Dotnet provides several different frameworks (E.g dotnetcore, aspnetcore, etc.) as well as many versions for a given framework. Normally, dotnet is able to fetch a framework and install it relative to the executable. However, this would mean writing to the nix store in nixpkgs, which is read-only. To support the many-sdk use case, one can compose an environment using `dotnetCorePackages.combinePackages`:
 
-```
+```nix
 with import <nixpkgs> {};
 
 mkShell {
@@ -37,7 +37,7 @@ mkShell {
 
 This will produce a dotnet installation that has the dotnet 3.1, 3.0, and 2.1 sdk. The first sdk listed will have it's cli utility present in the resulting environment. Example info output:
 
-```
+```ShellSesssion
 $ dotnet --info
 .NET Core SDK (reflecting any global.json):
  Version:   3.1.101
@@ -64,7 +64,7 @@ $ dotnet --info
 
 The `dotnetCorePackages.sdk_X_Y` is preferred over the old dotnet-sdk as both major and minor version are very important for a dotnet environment. If a given minor version isn't present (or was changed), then this will likely break your ability to build a project.
 
-## dotnetCorePackages.sdk vs vs dotnetCorePackages.net vs dotnetCorePackages.netcore vs dotnetCorePackages.aspnetcore
+## dotnetCorePackages.sdk vs dotnetCorePackages.net vs dotnetCorePackages.netcore vs dotnetCorePackages.aspnetcore
 
 The `dotnetCorePackages.sdk` contains both a runtime and the full sdk of a given version. The `net`, `netcore` and `aspnetcore` packages are meant to serve as minimal runtimes to deploy alongside already built applications. For runtime versions >= .NET 5 `net` is used while `netcore` is used for older .NET Core runtime version.
 
diff --git a/nixpkgs/doc/languages-frameworks/idris.section.md b/nixpkgs/doc/languages-frameworks/idris.section.md
index 41e4f7ec3127..000e3627d70d 100644
--- a/nixpkgs/doc/languages-frameworks/idris.section.md
+++ b/nixpkgs/doc/languages-frameworks/idris.section.md
@@ -4,7 +4,7 @@
 
 The easiest way to get a working idris version is to install the `idris` attribute:
 
-```
+```ShellSesssion
 $ # On NixOS
 $ nix-env -i nixos.idris
 $ # On non-NixOS
@@ -21,7 +21,7 @@ self: super: {
 
 And then:
 
-```
+```ShellSesssion
 $ # On NixOS
 $ nix-env -iA nixos.myIdris
 $ # On non-NixOS
@@ -29,7 +29,7 @@ $ nix-env -iA nixpkgs.myIdris
 ```
 
 To see all available Idris packages:
-```
+```ShellSesssion
 $ # On NixOS
 $ nix-env -qaPA nixos.idrisPackages
 $ # On non-NixOS
@@ -37,7 +37,7 @@ $ nix-env -qaPA nixpkgs.idrisPackages
 ```
 
 Similarly, entering a `nix-shell`:
-```
+```ShellSesssion
 $ nix-shell -p 'idrisPackages.with-packages (with idrisPackages; [ contrib pruviloj ])'
 ```
 
@@ -45,14 +45,14 @@ $ nix-shell -p 'idrisPackages.with-packages (with idrisPackages; [ contrib pruvi
 
 To have access to these libraries in idris, call it with an argument `-p <library name>` for each library:
 
-```
+```ShellSesssion
 $ nix-shell -p 'idrisPackages.with-packages (with idrisPackages; [ contrib pruviloj ])'
 [nix-shell:~]$ idris -p contrib -p pruviloj
 ```
 
 A listing of all available packages the Idris binary has access to is available via `--listlibs`:
 
-```
+```ShellSesssion
 $ idris --listlibs
 00prelude-idx.ibc
 pruviloj
@@ -105,7 +105,7 @@ build-idris-package  {
 
 Assuming this file is saved as `yaml.nix`, it's buildable using
 
-```
+```ShellSesssion
 $ nix-build -E '(import <nixpkgs> {}).idrisPackages.callPackage ./yaml.nix {}'
 ```
 
@@ -121,7 +121,7 @@ with import <nixpkgs> {};
 
 in another file (say `default.nix`) to be able to build it with
 
-```
+```ShellSesssion
 $ nix-build -A yaml
 ```
 
@@ -133,7 +133,7 @@ Specifically, you can set `idrisBuildOptions`, `idrisTestOptions`, `idrisInstall
 
 For example you could set
 
-```
+```nix
 build-idris-package {
   idrisBuildOptions = [ "--log" "1" "--verbose" ]
 
diff --git a/nixpkgs/doc/languages-frameworks/lua.section.md b/nixpkgs/doc/languages-frameworks/lua.section.md
index d81949c75f69..5935cbd7bd52 100644
--- a/nixpkgs/doc/languages-frameworks/lua.section.md
+++ b/nixpkgs/doc/languages-frameworks/lua.section.md
@@ -50,7 +50,7 @@ and install it in your profile with
 ```shell
 nix-env -iA nixpkgs.myLuaEnv
 ```
-The environment is is installed by referring to the attribute, and considering
+The environment is installed by referring to the attribute, and considering
 the `nixpkgs` channel was used.
 
 #### Lua environment defined in `/etc/nixos/configuration.nix`
@@ -129,7 +129,7 @@ the whitelist maintainers/scripts/luarocks-packages.csv and updated by running m
 [luarocks2nix](https://github.com/nix-community/luarocks) is a tool capable of generating nix derivations from both rockspec and src.rock (and favors the src.rock).
 The automation only goes so far though and some packages need to be customized.
 These customizations go in `pkgs/development/lua-modules/overrides.nix`.
-For instance if the rockspec defines `external_dependencies`, these need to be manually added in in its rockspec file then it won't work.
+For instance if the rockspec defines `external_dependencies`, these need to be manually added in its rockspec file then it won't work.
 
 You can try converting luarocks packages to nix packages with the command `nix-shell -p luarocks-nix` and then `luarocks nix PKG_NAME`.
 Nix rely on luarocks to install lua packages, basically it runs:
diff --git a/nixpkgs/doc/languages-frameworks/python.section.md b/nixpkgs/doc/languages-frameworks/python.section.md
index 71193ed0cc0b..96ac61ab54c5 100644
--- a/nixpkgs/doc/languages-frameworks/python.section.md
+++ b/nixpkgs/doc/languages-frameworks/python.section.md
@@ -7,8 +7,9 @@
 #### Overview
 
 Several versions of the Python interpreter are available on Nix, as well as a
-high amount of packages. The attribute `python` refers to the default
-interpreter, which is currently CPython 2.7. It is also possible to refer to
+high amount of packages. The attribute `python3` refers to the default
+interpreter, which is currently CPython 3.8. The attribute `python` refers to
+CPython 2.7 for backwards-compatibility. It is also possible to refer to
 specific versions, e.g. `python38` refers to CPython 3.8, and `pypy` refers to
 the default PyPy interpreter.
 
@@ -78,7 +79,7 @@ $ nix-shell -p 'python38.withPackages(ps: with ps; [ numpy toolz ])'
 By default `nix-shell` will start a `bash` session with this interpreter in our
 `PATH`, so if we then run:
 
-```
+```Python console
 [nix-shell:~/src/nixpkgs]$ python3
 Python 3.8.1 (default, Dec 18 2019, 19:06:26)
 [GCC 9.2.0] on linux
@@ -89,7 +90,7 @@ Type "help", "copyright", "credits" or "license" for more information.
 Note that no other modules are in scope, even if they were imperatively
 installed into our user environment as a dependency of a Python application:
 
-```
+```Python console
 >>> import requests
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
@@ -145,8 +146,8 @@ print(f"The dot product of {a} and {b} is: {np.dot(a, b)}")
 Executing this script requires a `python3` that has `numpy`. Using what we learned
 in the previous section, we could startup a shell and just run it like so:
 
-```
-nix-shell -p 'python38.withPackages(ps: with ps; [ numpy ])' --run 'python3 foo.py'
+```ShellSesssion
+$ nix-shell -p 'python38.withPackages(ps: with ps; [ numpy ])' --run 'python3 foo.py'
 The dot product of [1 2] and [3 4] is: 11
 ```
 
@@ -334,7 +335,7 @@ Above, we were mostly just focused on use cases and what to do to get started
 creating working Python environments in nix.
 
 Now that you know the basics to be up and running, it is time to take a step
-back and take a deeper look at at how Python packages are packaged on Nix. Then,
+back and take a deeper look at how Python packages are packaged on Nix. Then,
 we will look at how you can use development mode with your code.
 
 #### Python library packages in Nixpkgs
@@ -611,7 +612,7 @@ Using the example above, the analagous pytestCheckHook usage would be:
     "update"
   ];
 
-  disabledTestFiles = [
+  disabledTestPaths = [
     "tests/test_failing.py"
   ];
 ```
@@ -638,7 +639,7 @@ are disabled.
 
 #### Using pythonImportsCheck
 
-Although unit tests are highly prefered to valid correctness of a package. Not
+Although unit tests are highly prefered to validate correctness of a package, not
 all packages have test suites that can be ran easily, and some have none at all.
 To help ensure the package still works, `pythonImportsCheck` can attempt to import
 the listed modules.
@@ -762,10 +763,10 @@ and in this case the `python38` interpreter is automatically used.
 Versions 2.7, 3.6, 3.7, 3.8 and 3.9 of the CPython interpreter are available as
 respectively `python27`, `python36`, `python37`, `python38` and `python39`. The
 aliases `python2` and `python3` correspond to respectively `python27` and
-`python38`. The default interpreter, `python`, maps to `python2`. The PyPy
-interpreters compatible with Python 2.7 and 3 are available as `pypy27` and
-`pypy3`, with aliases `pypy2` mapping to `pypy27` and `pypy` mapping to `pypy2`.
-The Nix expressions for the interpreters can be found in
+`python39`. The attribute `python` maps to `python2`. The PyPy interpreters
+compatible with Python 2.7 and 3 are available as `pypy27` and `pypy3`, with
+aliases `pypy2` mapping to `pypy27` and `pypy` mapping to `pypy2`. The Nix
+expressions for the interpreters can be found in
 `pkgs/development/interpreters/python`.
 
 All packages depending on any Python interpreter get appended
@@ -788,6 +789,23 @@ Each interpreter has the following attributes:
 - `executable`. Name of the interpreter executable, e.g. `python3.8`.
 - `pkgs`. Set of Python packages for that specific interpreter. The package set can be modified by overriding the interpreter and passing `packageOverrides`.
 
+### Optimizations
+
+The Python interpreters are by default not build with optimizations enabled, because
+the builds are in that case not reproducible. To enable optimizations, override the
+interpreter of interest, e.g using
+
+```
+let
+  pkgs = import ./. {};
+  mypython = pkgs.python3.override {
+    enableOptimizations = true;
+    reproducibleBuild = false;
+    self = mypython;
+  };
+in mypython
+```
+
 ### Building packages and applications
 
 Python libraries and applications that use `setuptools` or
@@ -918,7 +936,7 @@ because their behaviour is different:
 
 * `nativeBuildInputs ? []`: Build-time only dependencies. Typically executables
   as well as the items listed in `setup_requires`.
-* `buildInputs ? []`: Build and/or run-time dependencies that need to be be
+* `buildInputs ? []`: Build and/or run-time dependencies that need to be
   compiled for the host machine. Typically non-Python libraries which are being
   linked.
 * `checkInputs ? []`: Dependencies needed for running the `checkPhase`. These
@@ -1188,7 +1206,8 @@ community to help save time. No tool is preferred at the moment.
   expressions for your Python project. Note that [sharing derivations from
   pypi2nix with nixpkgs is possible but not
   encouraged](https://github.com/nix-community/pypi2nix/issues/222#issuecomment-443497376).
-- [python2nix](https://github.com/proger/python2nix) by Vladimir Kirillov.
+- [nixpkgs-pytools](https://github.com/nix-community/nixpkgs-pytools)
+- [poetry2nix](https://github.com/nix-community/poetry2nix)
 
 ### Deterministic builds
 
@@ -1486,11 +1505,12 @@ If you need to change a package's attribute(s) from `configuration.nix` you coul
   nixpkgs.config.packageOverrides = super: {
     python = super.python.override {
       packageOverrides = python-self: python-super: {
-        zerobin = python-super.zerobin.overrideAttrs (oldAttrs: {
-          src = super.fetchgit {
-            url = "https://github.com/sametmax/0bin";
-            rev = "a344dbb18fe7a855d0742b9a1cede7ce423b34ec";
-            sha256 = "16d769kmnrpbdr0ph0whyf4yff5df6zi4kmwx7sz1d3r6c8p6xji";
+        twisted = python-super.twisted.overrideAttrs (oldAttrs: {
+          src = super.fetchPipy {
+            pname = "twisted";
+            version = "19.10.0";
+            sha256 = "7394ba7f272ae722a74f3d969dcf599bc4ef093bc392038748a490f1724a515d";
+            extension = "tar.bz2";
           };
         });
       };
@@ -1498,9 +1518,11 @@ If you need to change a package's attribute(s) from `configuration.nix` you coul
   };
 ```
 
-`pythonPackages.zerobin` is now globally overridden. All packages and also the
-`zerobin` NixOS service use the new definition. Note that `python-super` refers
-to the old package set and `python-self` to the new, overridden version.
+`pythonPackages.twisted` is now globally overridden.
+All packages and also all NixOS services that reference `twisted`
+(such as `services.buildbot-worker`) now use the new definition.
+Note that `python-super` refers to the old package set and `python-self`
+to the new, overridden version.
 
 To modify only a Python package set instead of a whole Python derivation, use
 this snippet:
@@ -1508,7 +1530,7 @@ this snippet:
 ```nix
   myPythonPackages = pythonPackages.override {
     overrides = self: super: {
-      zerobin = ...;
+      twisted = ...;
     };
   }
 ```
@@ -1521,11 +1543,12 @@ Use the following overlay template:
 self: super: {
   python = super.python.override {
     packageOverrides = python-self: python-super: {
-      zerobin = python-super.zerobin.overrideAttrs (oldAttrs: {
-        src = super.fetchgit {
-          url = "https://github.com/sametmax/0bin";
-          rev = "a344dbb18fe7a855d0742b9a1cede7ce423b34ec";
-          sha256 = "16d769kmnrpbdr0ph0whyf4yff5df6zi4kmwx7sz1d3r6c8p6xji";
+      twisted = python-super.twisted.overrideAttrs (oldAttrs: {
+        src = super.fetchPypi {
+          pname = "twisted";
+          version = "19.10.0";
+          sha256 = "7394ba7f272ae722a74f3d969dcf599bc4ef093bc392038748a490f1724a515d";
+          extension = "tar.bz2";
         };
       });
     };
@@ -1550,13 +1573,11 @@ In a `setup.py` or `setup.cfg` it is common to declare dependencies:
 
 ### Contributing guidelines
 
-Following rules are desired to be respected:
+The following rules are desired to be respected:
 
 * Python libraries are called from `python-packages.nix` and packaged with
   `buildPythonPackage`. The expression of a library should be in
-  `pkgs/development/python-modules/<name>/default.nix`. Libraries in
-  `pkgs/top-level/python-packages.nix` are sorted quasi-alphabetically to avoid
-  merge conflicts.
+  `pkgs/development/python-modules/<name>/default.nix`.
 * Python applications live outside of `python-packages.nix` and are packaged
   with `buildPythonApplication`.
 * Make sure libraries build for all Python interpreters.
@@ -1566,7 +1587,11 @@ Following rules are desired to be respected:
   case, when you disable tests, leave a comment explaining why.
 * Commit names of Python libraries should reflect that they are Python
   libraries, so write for example `pythonPackages.numpy: 1.11 -> 1.12`.
-* Attribute names in `python-packages.nix` should be normalized according to
-  [PEP 0503](https://www.python.org/dev/peps/pep-0503/#normalized-names). This
-  means that characters should be converted to lowercase and `.` and `_` should
-  be replaced by a single `-` (foo-bar-baz instead of Foo__Bar.baz )
+* Attribute names in `python-packages.nix` as well as `pname`s should match the
+  library's name on PyPI, but be normalized according to [PEP
+  0503](https://www.python.org/dev/peps/pep-0503/#normalized-names). This means
+  that characters should be converted to lowercase and `.` and `_` should be
+  replaced by a single `-` (foo-bar-baz instead of Foo__Bar.baz).
+  If necessary, `pname` has to be given a different value within `fetchPypi`.
+* Attribute names in `python-packages.nix` should be sorted alphanumerically to
+  avoid merge conflicts and ease locating attributes.
diff --git a/nixpkgs/doc/languages-frameworks/qt.section.md b/nixpkgs/doc/languages-frameworks/qt.section.md
index 5dd415852c10..6f8c9626e6de 100644
--- a/nixpkgs/doc/languages-frameworks/qt.section.md
+++ b/nixpkgs/doc/languages-frameworks/qt.section.md
@@ -1,77 +1,88 @@
 # Qt {#sec-language-qt}
 
-This section describes the differences between Nix expressions for Qt libraries and applications and Nix expressions for other C++ software. Some knowledge of the latter is assumed.
+Writing Nix expressions for Qt libraries and applications is largely similar as for other C++ software.
+This section assumes some knowledge of the latter.
+There are two problems that the Nixpkgs Qt infrastructure addresses,
+which are not shared by other C++ software:
 
-There are primarily two problems which the Qt infrastructure is designed to address: ensuring consistent versioning of all dependencies and finding dependencies at runtime.
+1.  There are usually multiple supported versions of Qt in Nixpkgs.
+    All of a package's dependencies must be built with the same version of Qt.
+    This is similar to the version constraints imposed on interpreted languages like Python.
+2.  Qt makes extensive use of runtime dependency detection.
+    Runtime dependencies are made into build dependencies through wrappers.
 
 ## Nix expression for a Qt package (default.nix) {#qt-default-nix}
 
 ```{=docbook}
 <programlisting>
-{ mkDerivation, qtbase }: <co xml:id='qt-default-nix-co-1' />
+{ stdenv, lib, qtbase, wrapQtAppsHook }: <co xml:id='qt-default-nix-co-1' />
 
-mkDerivation { <co xml:id='qt-default-nix-co-2' />
+stdenv.mkDerivation {
   pname = "myapp";
   version = "1.0";
 
-  buildInputs = [ qtbase ]; <co xml:id='qt-default-nix-co-3' />
+  buildInputs = [ qtbase ];
+  nativeBuildInputs = [ wrapQtAppsHook ]; <co xml:id='qt-default-nix-co-2' />
 }
 </programlisting>
 
  <calloutlist>
   <callout arearefs='qt-default-nix-co-1'>
    <para>
-    Import <literal>mkDerivation</literal> and Qt (such as <literal>qtbase</literal> modules directly. <emphasis>Do not</emphasis> import Qt package sets; the Qt versions of dependencies may not be coherent, causing build and runtime failures.
+    Import Qt modules directly, that is: <literal>qtbase</literal>, <literal>qtdeclarative</literal>, etc.
+    <emphasis>Do not</emphasis> import Qt package sets such as <literal>qt5</literal>
+    because the Qt versions of dependencies may not be coherent, causing build and runtime failures.
    </para>
   </callout>
   <callout arearefs='qt-default-nix-co-2'>
-   <para>
-    Use <literal>mkDerivation</literal> instead of <literal>stdenv.mkDerivation</literal>. <literal>mkDerivation</literal> is a wrapper around <literal>stdenv.mkDerivation</literal> which applies some Qt-specific settings. This deriver accepts the same arguments as <literal>stdenv.mkDerivation</literal>; refer to <xref linkend='chap-stdenv' /> for details.
-   </para>
-   <para>
-    To use another deriver instead of <literal>stdenv.mkDerivation</literal>, use <literal>mkDerivationWith</literal>:
-<programlisting>
-mkDerivationWith myDeriver {
-  # ...
-}
-</programlisting>
-    If you cannot use <literal>mkDerivationWith</literal>, please refer to <xref linkend='qt-runtime-dependencies' />.
-   </para>
-  </callout>
-  <callout arearefs='qt-default-nix-co-3'>
-   <para>
-    <literal>mkDerivation</literal> accepts the same arguments as <literal>stdenv.mkDerivation</literal>, such as <literal>buildInputs</literal>.
-   </para>
+    <para>
+      All Qt packages must include <literal>wrapQtAppsHook</literal> in
+      <literal>nativeBuildInputs</literal>, or you must explicitly set
+      <literal>dontWrapQtApps</literal>.
+    </para>
   </callout>
  </calloutlist>
 ```
 
 ## Locating runtime dependencies {#qt-runtime-dependencies}
-Qt applications need to be wrapped to find runtime dependencies. If you cannot use `mkDerivation` or `mkDerivationWith` above, include `wrapQtAppsHook` in `nativeBuildInputs`:
+
+Qt applications must be wrapped to find runtime dependencies.
+Include `wrapQtAppsHook` in `nativeBuildInputs`:
 
 ```nix
+{ stdenv, wrapQtAppsHook }:
+
 stdenv.mkDerivation {
   # ...
-
   nativeBuildInputs = [ wrapQtAppsHook ];
 }
 ```
-Entries added to `qtWrapperArgs` are used to modify the wrappers created by `wrapQtAppsHook`. The entries are passed as arguments to [wrapProgram executable makeWrapperArgs](#fun-wrapProgram).
+
+Add entries to `qtWrapperArgs` are to modify the wrappers created by
+`wrapQtAppsHook`:
 
 ```nix
-mkDerivation {
-  # ...
+{ stdenv, wrapQtAppsHook }:
 
+stdenv.mkDerivation {
+  # ...
+  nativeBuildInputs = [ wrapQtAppsHook ];
   qtWrapperArgs = [ ''--prefix PATH : /path/to/bin'' ];
 }
 ```
 
-Set `dontWrapQtApps` to stop applications from being wrapped automatically. It is required to wrap applications manually with `wrapQtApp`, using the syntax of [wrapProgram executable makeWrapperArgs](#fun-wrapProgram):
+The entries are passed as arguments to [wrapProgram](#fun-wrapProgram).
+
+Set `dontWrapQtApps` to stop applications from being wrapped automatically.
+Wrap programs manually with `wrapQtApp`, using the syntax of
+[wrapProgram](#fun-wrapProgram):
 
 ```nix
-mkDerivation {
-  # ...
+{ stdenv, lib, wrapQtAppsHook }:
 
+stdenv.mkDerivation {
+  # ...
+  nativeBuildInputs = [ wrapQtAppsHook ];
   dontWrapQtApps = true;
   preFixup = ''
       wrapQtApp "$out/bin/myapp" --prefix PATH : /path/to/bin
@@ -79,25 +90,20 @@ mkDerivation {
 }
 ```
 
-> Note: `wrapQtAppsHook` ignores files that are non-ELF executables. This means that scripts won't be automatically wrapped so you'll need to manually wrap them as previously mentioned. An example of when you'd always need to do this is with Python applications that use PyQT.
-
-Libraries are built with every available version of Qt. Use the `meta.broken` attribute to disable the package for unsupported Qt versions:
-
-```nix
-mkDerivation {
-  # ...
+::: note
+`wrapQtAppsHook` ignores files that are non-ELF executables.
+This means that scripts won't be automatically wrapped so you'll need to manually wrap them as previously mentioned.
+An example of when you'd always need to do this is with Python applications that use PyQt.
+:::
 
-  # Disable this library with Qt &lt; 5.9.0
-  meta.broken = builtins.compareVersions qtbase.version "5.9.0" &lt; 0;
-}
-```
 ## Adding a library to Nixpkgs
-Qt libraries are added to `qt5-packages.nix` and are made available for every Qt
-version supported.
+Add Qt libraries to `qt5-packages.nix` to make them available for every
+supported Qt version.
+
 ### Example adding a Qt library {#qt-library-all-packages-nix}
 
 The following represents the contents of `qt5-packages.nix`.
-```
+```nix
 {
   # ...
 
@@ -106,14 +112,28 @@ The following represents the contents of `qt5-packages.nix`.
   # ...
 }
 ```
+
+Libraries are built with every available version of Qt.
+Use the `meta.broken` attribute to disable the package for unsupported Qt versions:
+
+```nix
+{ stdenv, lib, qtbase }:
+
+stdenv.mkDerivation {
+  # ...
+  # Disable this library with Qt < 5.9.0
+  meta.broken = lib.versionOlder qtbase.version "5.9.0";
+}
+```
+
 ## Adding an application to Nixpkgs
-Applications that use Qt are also added to `qt5-packages.nix`. An alias is added
-in the top-level `all-packages.nix` pointing to the package with the desired Qt5 version.
+Add Qt applications to `qt5-packages.nix`. Add an alias to `all-packages.nix`
+to select the Qt 5 version used for the application.
 
 ### Example adding a Qt application {#qt-application-all-packages-nix}
 
 The following represents the contents of `qt5-packages.nix`.
-```
+```nix
 {
   # ...
 
@@ -124,7 +144,7 @@ The following represents the contents of `qt5-packages.nix`.
 ```
 
 The following represents the contents of `all-packages.nix`.
-```
+```nix
 {
   # ...
 
diff --git a/nixpkgs/doc/languages-frameworks/ruby.section.md b/nixpkgs/doc/languages-frameworks/ruby.section.md
index aeec154586c7..c519d79d3daf 100644
--- a/nixpkgs/doc/languages-frameworks/ruby.section.md
+++ b/nixpkgs/doc/languages-frameworks/ruby.section.md
@@ -229,7 +229,7 @@ end
 
 If you want to package a specific version, you can use the standard Gemfile syntax for that, e.g. `gem 'mdl', '0.5.0'`, but if you want the latest stable version anyway, it's easier to update by simply running the `bundle lock` and `bundix` steps again.
 
-Now you can also also make a `default.nix` that looks like this:
+Now you can also make a `default.nix` that looks like this:
 
 ```nix
 { bundlerApp }:
diff --git a/nixpkgs/doc/languages-frameworks/rust.section.md b/nixpkgs/doc/languages-frameworks/rust.section.md
index 8f6db28ab4d6..d1a6a566774c 100644
--- a/nixpkgs/doc/languages-frameworks/rust.section.md
+++ b/nixpkgs/doc/languages-frameworks/rust.section.md
@@ -2,13 +2,14 @@
 
 To install the rust compiler and cargo put
 
-```
-rustc
-cargo
+```nix
+environment.systemPackages = [
+  rustc
+  cargo
+];
 ```
 
-into the `environment.systemPackages` or bring them into
-scope with `nix-shell -p rustc cargo`.
+into your `configuration.nix` or bring them into scope with `nix-shell -p rustc cargo`.
 
 For other versions such as daily builds (beta and nightly),
 use either `rustup` from nixpkgs (which will manage the rust installation in your home directory),
@@ -18,7 +19,7 @@ or use Mozilla's [Rust nightlies overlay](#using-the-rust-nightlies-overlay).
 
 Rust applications are packaged by using the `buildRustPackage` helper from `rustPlatform`:
 
-```
+```nix
 { lib, rustPlatform }:
 
 rustPlatform.buildRustPackage rec {
@@ -49,7 +50,7 @@ package. `cargoHash256` is used for traditional Nix SHA-256 hashes,
 such as the one in the example above. `cargoHash` should instead be
 used for [SRI](https://www.w3.org/TR/SRI/) hashes. For example:
 
-```
+```nix
   cargoHash = "sha256-l1vL2ZdtDRxSGvP0X/l3nMw8+6WF67KPutJEzUROjg8=";
 ```
 
@@ -59,27 +60,54 @@ expression and building the package once. The correct checksum can
 then be taken from the failed build. A fake hash can be used for
 `cargoSha256` as follows:
 
-```
+```nix
   cargoSha256 = lib.fakeSha256;
 ```
 
 For `cargoHash` you can use:
 
-```
+```nix
   cargoHash = lib.fakeHash;
 ```
 
 Per the instructions in the [Cargo Book](https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html)
 best practices guide, Rust applications should always commit the `Cargo.lock`
 file in git to ensure a reproducible build. However, a few packages do not, and
-Nix depends on this file, so if it missing you can use `cargoPatches` to apply
-it in the `patchPhase`. Consider sending a PR upstream with a note to the
+Nix depends on this file, so if it is missing you can use `cargoPatches` to
+apply it in the `patchPhase`. Consider sending a PR upstream with a note to the
 maintainer describing why it's important to include in the application.
 
 The fetcher will verify that the `Cargo.lock` file is in sync with the `src`
 attribute, and fail the build if not. It will also will compress the vendor
 directory into a tar.gz archive.
 
+The tarball with vendored dependencies contains a directory with the
+package's `name`, which is normally composed of `pname` and
+`version`. This means that the vendored dependencies hash
+(`cargoSha256`/`cargoHash`) is dependent on the package name and
+version. The `cargoDepsName` attribute can be used to use another name
+for the directory of vendored dependencies. For example, the hash can
+be made invariant to the version by setting `cargoDepsName` to
+`pname`:
+
+```nix
+rustPlatform.buildRustPackage rec {
+  pname = "broot";
+  version = "1.2.0";
+
+  src = fetchCrate {
+    inherit pname version;
+    sha256 = "1mqaynrqaas82f5957lx31x80v74zwmwmjxxlbywajb61vh00d38";
+  };
+
+  cargoHash = "sha256-JmBZcDVYJaK1cK05cxx5BrnGWp4t8ca6FLUbvIot67s=";
+  cargoDepsName = pname;
+
+  # ...
+}
+```
+
+
 ### Cross compilation
 
 By default, Rust packages are compiled for the host platform, just like any
@@ -119,6 +147,7 @@ where they are known to differ. But there are ways to customize the argument:
        rustc.platform = { foo = ""; bar = ""; };
      };
    }
+   ```
    will result in:
    ```shell
    --target /nix/store/asdfasdfsadf-thumb-crazy.json # contains {"foo":"","bar":""}
@@ -129,7 +158,7 @@ path) can be passed directly to `buildRustPackage`:
 
 ```nix
 pkgs.rustPlatform.buildRustPackage {
-  (...)
+  /* ... */
   target = "x86_64-fortanix-unknown-sgx";
 }
 ```
@@ -164,6 +193,13 @@ rustPlatform.buildRustPackage {
 Please note that the code will be compiled twice here: once in `release` mode
 for the `buildPhase`, and again in `debug` mode for the `checkPhase`.
 
+Test flags, e.g., `--features xxx/yyy`, can be passed to `cargo test` via the
+`cargoTestFlags` attribute.
+
+Another attribute, called `checkFlags`, is used to pass arguments to the test
+binary itself, as stated
+(here)[https://doc.rust-lang.org/cargo/commands/cargo-test.html].
+
 #### Tests relying on the structure of the `target/` directory
 
 Some tests may rely on the structure of the `target/` directory. Those tests
@@ -196,7 +232,7 @@ sometimes it may be necessary to disable this so the tests run consecutively.
 ```nix
 rustPlatform.buildRustPackage {
   /* ... */
-  cargoParallelTestThreads = false;
+  dontUseCargoParallelTests = true;
 }
 ```
 
@@ -227,7 +263,7 @@ Otherwise, some steps may fail because of the modified directory structure of `t
 source code in a reproducible way. If it is missing or out-of-date one can use
 the `cargoPatches` attribute to update or add it.
 
-```
+```nix
 rustPlatform.buildRustPackage rec {
   (...)
   cargoPatches = [
@@ -237,6 +273,199 @@ rustPlatform.buildRustPackage rec {
 }
 ```
 
+## Compiling non-Rust packages that include Rust code
+
+Several non-Rust packages incorporate Rust code for performance- or
+security-sensitive parts. `rustPlatform` exposes several functions and
+hooks that can be used to integrate Cargo in non-Rust packages.
+
+### Vendoring of dependencies
+
+Since network access is not allowed in sandboxed builds, Rust crate
+dependencies need to be retrieved using a fetcher. `rustPlatform`
+provides the `fetchCargoTarball` fetcher, which vendors all
+dependencies of a crate. For example, given a source path `src`
+containing `Cargo.toml` and `Cargo.lock`, `fetchCargoTarball`
+can be used as follows:
+
+```nix
+cargoDeps = rustPlatform.fetchCargoTarball {
+  inherit src;
+  hash = "sha256-BoHIN/519Top1NUBjpB/oEMqi86Omt3zTQcXFWqrek0=";
+};
+```
+
+The `src` attribute is required, as well as a hash specified through
+one of the `sha256` or `hash` attributes. The following optional
+attributes can also be used:
+
+* `name`: the name that is used for the dependencies tarball.  If
+  `name` is not specified, then the name `cargo-deps` will be used.
+* `sourceRoot`: when the `Cargo.lock`/`Cargo.toml` are in a
+  subdirectory, `sourceRoot` specifies the relative path to these
+  files.
+* `patches`: patches to apply before vendoring. This is useful when
+  the `Cargo.lock`/`Cargo.toml` files need to be patched before
+  vendoring.
+
+### Hooks
+
+`rustPlatform` provides the following hooks to automate Cargo builds:
+
+* `cargoSetupHook`: configure Cargo to use depenencies vendored
+  through `fetchCargoTarball`. This hook uses the `cargoDeps`
+  environment variable to find the vendored dependencies. If a project
+  already vendors its dependencies, the variable `cargoVendorDir` can
+  be used instead. When the `Cargo.toml`/`Cargo.lock` files are not in
+  `sourceRoot`, then the optional `cargoRoot` is used to specify the
+  Cargo root directory relative to `sourceRoot`.
+* `cargoBuildHook`: use Cargo to build a crate. If the crate to be
+  built is a crate in e.g. a Cargo workspace, the relative path to the
+  crate to build can be set through the optional `buildAndTestSubdir`
+  environment variable. Additional Cargo build flags can be passed
+  through `cargoBuildFlags`.
+* `maturinBuildHook`: use [Maturin](https://github.com/PyO3/maturin)
+  to build a Python wheel. Similar to `cargoBuildHook`, the optional
+  variable `buildAndTestSubdir` can be used to build a crate in a
+  Cargo workspace. Additional maturin flags can be passed through
+  `maturinBuildFlags`.
+* `cargoCheckHook`: run tests using Cargo. The build type for checks
+  can be set using `cargoCheckType`. Additional flags can be passed to
+  the tests using `checkFlags` and `checkFlagsArray`. By default,
+  tests are run in parallel. This can be disabled by setting
+  `dontUseCargoParallelTests`.
+* `cargoInstallHook`: install binaries and static/shared libraries
+  that were built using `cargoBuildHook`.
+
+### Examples
+
+#### Python package using `setuptools-rust`
+
+For Python packages using `setuptools-rust`, you can use
+`fetchCargoTarball` and `cargoSetupHook` to retrieve and set up Cargo
+dependencies. The build itself is then performed by
+`buildPythonPackage`.
+
+The following example outlines how the `tokenizers` Python package is
+built. Since the Python package is in the `source/bindings/python`
+directory of the *tokenizers* project's source archive, we use
+`sourceRoot` to point the tooling to this directory:
+
+```nix
+{ fetchFromGitHub
+, buildPythonPackage
+, rustPlatform
+, setuptools-rust
+}:
+
+buildPythonPackage rec {
+  pname = "tokenizers";
+  version = "0.10.0";
+
+  src = fetchFromGitHub {
+    owner = "huggingface";
+    repo = pname;
+    rev = "python-v${version}";
+    hash = "sha256-rQ2hRV52naEf6PvRsWVCTN7B1oXAQGmnpJw4iIdhamw=";
+  };
+
+  cargoDeps = rustPlatform.fetchCargoTarball {
+    inherit src sourceRoot;
+    name = "${pname}-${version}";
+    hash = "sha256-BoHIN/519Top1NUBjpB/oEMqi86Omt3zTQcXFWqrek0=";
+  };
+
+  sourceRoot = "source/bindings/python";
+
+  nativeBuildInputs = [ setuptools-rust ] ++ (with rustPlatform; [
+    cargoSetupHook
+    rust.cargo
+    rust.rustc
+  ]);
+
+  # ...
+}
+```
+
+In some projects, the Rust crate is not in the main Python source
+directory.  In such cases, the `cargoRoot` attribute can be used to
+specify the crate's directory relative to `sourceRoot`. In the
+following example, the crate is in `src/rust`, as specified in the
+`cargoRoot` attribute. Note that we also need to specify the correct
+path for `fetchCargoTarball`.
+
+```nix
+
+{ buildPythonPackage
+, fetchPypi
+, rustPlatform
+, setuptools-rust
+, openssl
+}:
+
+buildPythonPackage rec {
+  pname = "cryptography";
+  version = "3.4.2"; # Also update the hash in vectors.nix
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "1i1mx5y9hkyfi9jrrkcw804hmkcglxi6rmf7vin7jfnbr2bf4q64";
+  };
+
+  cargoDeps = rustPlatform.fetchCargoTarball {
+    inherit src;
+    sourceRoot = "${pname}-${version}/${cargoRoot}";
+    name = "${pname}-${version}";
+    hash = "sha256-PS562W4L1NimqDV2H0jl5vYhL08H9est/pbIxSdYVfo=";
+  };
+
+  cargoRoot = "src/rust";
+
+  # ...
+}
+```
+
+#### Python package using `maturin`
+
+Python packages that use [Maturin](https://github.com/PyO3/maturin)
+can be built with `fetchCargoTarball`, `cargoSetupHook`, and
+`maturinBuildHook`. For example, the following (partial) derivation
+builds the `retworkx` Python package. `fetchCargoTarball` and
+`cargoSetupHook` are used to fetch and set up the crate dependencies.
+`maturinBuildHook` is used to perform the build.
+
+```nix
+{ lib
+, buildPythonPackage
+, rustPlatform
+, fetchFromGitHub
+}:
+
+buildPythonPackage rec {
+  pname = "retworkx";
+  version = "0.6.0";
+
+  src = fetchFromGitHub {
+    owner = "Qiskit";
+    repo = "retworkx";
+    rev = version;
+    sha256 = "11n30ldg3y3y6qxg3hbj837pnbwjkqw3nxq6frds647mmmprrd20";
+  };
+
+  cargoDeps = rustPlatform.fetchCargoTarball {
+    inherit src;
+    name = "${pname}-${version}";
+    hash = "sha256-heOBK8qi2nuc/Ib+I/vLzZ1fUUD/G/KTw9d7M4Hz5O0=";
+  };
+
+  format = "pyproject";
+
+  nativeBuildInputs = with rustPlatform; [ cargoSetupHook maturinBuildHook ];
+
+  # ...
+}
+```
+
 ## Compiling Rust crates using Nix instead of Cargo
 
 ### Simple operation
@@ -261,7 +490,7 @@ an example for a minimal `hello` crate:
 
 Now, the file produced by the call to `carnix`, called `hello.nix`, looks like:
 
-```
+```nix
 # Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
 { stdenv, buildRustCrate, fetchgit }:
 let kernel = stdenv.buildPlatform.parsed.kernel.name;
@@ -290,7 +519,7 @@ dependencies, for instance by adding a single line `libc="*"` to our
 `Cargo.lock`. Then, `carnix` needs to be run again, and produces the
 following nix file:
 
-```
+```nix
 # Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
 { stdenv, buildRustCrate, fetchgit }:
 let kernel = stdenv.buildPlatform.parsed.kernel.name;
@@ -345,7 +574,7 @@ Some crates require external libraries. For crates from
 Starting from that file, one can add more overrides, to add features
 or build inputs by overriding the hello crate in a seperate file.
 
-```
+```nix
 with import <nixpkgs> {};
 ((import ./hello.nix).hello {}).override {
   crateOverrides = defaultCrateOverrides // {
@@ -365,7 +594,7 @@ derivation depend on the crate's version, the `attrs` argument of
 the override above can be read, as in the following example, which
 patches the derivation:
 
-```
+```nix
 with import <nixpkgs> {};
 ((import ./hello.nix).hello {}).override {
   crateOverrides = defaultCrateOverrides // {
@@ -386,7 +615,7 @@ dependencies. For instance, to override the build inputs for crate
 `libc` in the example above, where `libc` is a dependency of the main
 crate, we could do:
 
-```
+```nix
 with import <nixpkgs> {};
 ((import hello.nix).hello {}).override {
   crateOverrides = defaultCrateOverrides // {
@@ -402,27 +631,27 @@ general. A number of other parameters can be overridden:
 
 - The version of rustc used to compile the crate:
 
-  ```
+  ```nix
   (hello {}).override { rust = pkgs.rust; };
   ```
 
 - Whether to build in release mode or debug mode (release mode by
   default):
 
-  ```
+  ```nix
   (hello {}).override { release = false; };
   ```
 
 - Whether to print the commands sent to rustc when building
   (equivalent to `--verbose` in cargo:
 
-  ```
+  ```nix
   (hello {}).override { verbose = false; };
   ```
 
 - Extra arguments to be passed to `rustc`:
 
-  ```
+  ```nix
   (hello {}).override { extraRustcOpts = "-Z debuginfo=2"; };
   ```
 
@@ -434,7 +663,7 @@ general. A number of other parameters can be overridden:
   `postInstall`. As an example, here is how to create a new module
   before running the build script:
 
-  ```
+  ```nix
   (hello {}).override {
     preConfigure = ''
        echo "pub const PATH=\"${hi.out}\";" >> src/path.rs"
@@ -448,7 +677,7 @@ One can also supply features switches. For example, if we want to
 compile `diesel_cli` only with the `postgres` feature, and no default
 features, we would write:
 
-```
+```nix
 (callPackage ./diesel.nix {}).diesel {
   default = false;
   postgres = true;
@@ -471,7 +700,7 @@ Using the example `hello` project above, we want to do the following:
 
 A typical `shell.nix` might look like:
 
-```
+```nix
 with import <nixpkgs> {};
 
 stdenv.mkDerivation {
@@ -493,7 +722,7 @@ stdenv.mkDerivation {
 ```
 
 You should now be able to run the following:
-```
+```ShellSesssion
 $ nix-shell --pure
 $ cargo build
 $ cargo test
@@ -503,7 +732,7 @@ $ cargo test
 To control your rust version (i.e. use nightly) from within `shell.nix` (or
 other nix expressions) you can use the following `shell.nix`
 
-```
+```nix
 # Latest Nightly
 with import <nixpkgs> {};
 let src = fetchFromGitHub {
@@ -518,7 +747,7 @@ with import "${src.out}/rust-overlay.nix" pkgs pkgs;
 stdenv.mkDerivation {
   name = "rust-env";
   buildInputs = [
-    # Note: to use use stable, just replace `nightly` with `stable`
+    # Note: to use stable, just replace `nightly` with `stable`
     latest.rustChannels.nightly.rust
 
     # Add some extra dependencies from `pkgs`
@@ -531,7 +760,7 @@ stdenv.mkDerivation {
 ```
 
 Now run:
-```
+```ShellSession
 $ rustc --version
 rustc 1.26.0-nightly (188e693b3 2018-03-26)
 ```
@@ -566,7 +795,7 @@ in the `~/.config/nixpkgs/overlays` directory.
 
 Add the following to your `configuration.nix`, `home-configuration.nix`, `shell.nix`, or similar:
 
-```
+```nix
 { pkgs ? import <nixpkgs> {
     overlays = [
       (import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz))
diff --git a/nixpkgs/doc/languages-frameworks/vim.section.md b/nixpkgs/doc/languages-frameworks/vim.section.md
index 155dacc237b3..22b5e6f3013b 100644
--- a/nixpkgs/doc/languages-frameworks/vim.section.md
+++ b/nixpkgs/doc/languages-frameworks/vim.section.md
@@ -156,7 +156,7 @@ assuming that "using latest version" is ok most of the time.
 
 First create a vim-scripts file having one plugin name per line. Example:
 
-```
+```vim
 "tlib"
 {'name': 'vim-addon-sql'}
 {'filetype_regex': '\%(vim)$', 'names': ['reload', 'vim-dev-plugin']}
@@ -197,7 +197,7 @@ nix-shell -p vimUtils.vim_with_vim2nix --command "vim -c 'source generate.vim'"
 You should get a Vim buffer with the nix derivations (output1) and vam.pluginDictionaries (output2).
 You can add your Vim to your system's configuration file like this and start it by "vim-my":
 
-```
+```nix
 my-vim =
   let plugins = let inherit (vimUtils) buildVimPluginFrom2Nix; in {
     copy paste output1 here
@@ -217,7 +217,7 @@ my-vim =
 
 Sample output1:
 
-```
+```nix
 "reload" = buildVimPluginFrom2Nix { # created by nix#NixDerivation
   name = "reload";
   src = fetchgit {
@@ -248,7 +248,7 @@ Nix expressions for Vim plugins are stored in [pkgs/misc/vim-plugins](/pkgs/misc
 
 Some plugins require overrides in order to function properly. Overrides are placed in [overrides.nix](/pkgs/misc/vim-plugins/overrides.nix). Overrides are most often required when a plugin requires some dependencies, or extra steps are required during the build process. For example `deoplete-fish` requires both `deoplete-nvim` and `vim-fish`, and so the following override was added:
 
-```
+```nix
 deoplete-fish = super.deoplete-fish.overrideAttrs(old: {
   dependencies = with super; [ deoplete-nvim vim-fish ];
 });
diff --git a/nixpkgs/doc/manual.xml b/nixpkgs/doc/manual.xml
index 8cecb01fc227..1c5a7bbcaa9e 100644
--- a/nixpkgs/doc/manual.xml
+++ b/nixpkgs/doc/manual.xml
@@ -15,11 +15,11 @@
  </part>
  <part>
   <title>Standard environment</title>
-  <xi:include href="stdenv/stdenv.xml" />
-  <xi:include href="stdenv/meta.xml" />
-  <xi:include href="stdenv/multiple-output.xml" />
+  <xi:include href="stdenv/stdenv.chapter.xml" />
+  <xi:include href="stdenv/meta.chapter.xml" />
+  <xi:include href="stdenv/multiple-output.chapter.xml" />
   <xi:include href="stdenv/cross-compilation.chapter.xml" />
-  <xi:include href="stdenv/platform-notes.xml" />
+  <xi:include href="stdenv/platform-notes.chapter.xml" />
  </part>
  <part>
   <title>Builders</title>
@@ -35,6 +35,7 @@
   <xi:include href="contributing/quick-start.xml" />
   <xi:include href="contributing/coding-conventions.xml" />
   <xi:include href="contributing/submitting-changes.chapter.xml" />
+  <xi:include href="contributing/vulnerability-roundup.chapter.xml" />
   <xi:include href="contributing/reviewing-contributions.xml" />
   <xi:include href="contributing/contributing-to-documentation.xml" />
  </part>
diff --git a/nixpkgs/doc/stdenv/cross-compilation.chapter.md b/nixpkgs/doc/stdenv/cross-compilation.chapter.md
index d7a07a621be7..96641426628e 100644
--- a/nixpkgs/doc/stdenv/cross-compilation.chapter.md
+++ b/nixpkgs/doc/stdenv/cross-compilation.chapter.md
@@ -16,7 +16,7 @@ Nixpkgs follows the [conventions of GNU autoconf](https://gcc.gnu.org/onlinedocs
 In Nixpkgs, these three platforms are defined as attribute sets under the names `buildPlatform`, `hostPlatform`, and `targetPlatform`. They are always defined as attributes in the standard environment. That means one can access them like:
 
 ```nix
-{ stdenv, fooDep, barDep, .. }: ...stdenv.buildPlatform...
+{ stdenv, fooDep, barDep, ... }: ...stdenv.buildPlatform...
 ```
 
 `buildPlatform`
@@ -99,15 +99,26 @@ Some examples will make this table clearer. Suppose there's some package that is
 
 Some frequently encountered problems when packaging for cross-compilation should be answered here. Ideally, the information above is exhaustive, so this section cannot provide any new information, but it is ludicrous and cruel to expect everyone to spend effort working through the interaction of many features just to figure out the same answer to the same common problem. Feel free to add to this list!
 
+#### My package fails to find a binutils command (`cc`/`ar`/`ld` etc.) {#cross-qa-fails-to-find-binutils}
+Many packages assume that an unprefixed binutils (`cc`/`ar`/`ld` etc.) is available, but Nix doesn't provide one. It only provides a prefixed one, just as it only does for all the other binutils programs. It may be necessary to patch the package to fix the build system to use a prefix. For instance, instead of `cc`, use `${stdenv.cc.targetPrefix}cc`.
+
+```nix
+makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ];
+```
+
+#### How do I avoid compiling a GCC cross-compiler from source? {#cross-qa-avoid-compiling-gcc-cross-compiler}
+On less powerful machines, it can be inconvenient to cross-compile a package only to find out that GCC has to be compiled from source, which could take up to several hours. Nixpkgs maintains a limited [cross-related jobset on Hydra](https://hydra.nixos.org/jobset/nixpkgs/cross-trunk), which tests cross-compilation to various platforms from build platforms "x86\_64-darwin", "x86\_64-linux", and "aarch64-linux".  See `pkgs/top-level/release-cross.nix` for the full list of target platforms and packages.  For instance, the following invocation fetches the pre-built cross-compiled GCC for `armv6l-unknown-linux-gnueabihf` and builds GNU Hello from source.
+
+```ShellSession
+$ nix-build '<nixpkgs>' -A pkgsCross.raspberryPi.hello
+```
+
 #### What if my package's build system needs to build a C program to be run under the build environment? {#cross-qa-build-c-program-in-build-environment}
 Add the following to your `mkDerivation` invocation.
 ```nix
 depsBuildBuild = [ buildPackages.stdenv.cc ];
 ```
 
-#### My package fails to find `ar`. {#cross-qa-fails-to-find-ar}
-Many packages assume that an unprefixed `ar` is available, but Nix doesn't provide one. It only provides a prefixed one, just as it only does for all the other binutils programs. It may be necessary to patch the package to fix the build system to use a prefixed `ar`.
-
 ####  My package's testsuite needs to run host platform code. {#cross-testsuite-runs-host-code}
 
 Add the following to your `mkDerivation` invocation.
@@ -179,7 +190,7 @@ If one imagines the saturating self references at the end being replaced with in
 ```
 (native..., native, native, native, foreign, foreign, foreign...)
 ```
-On can then imagine any sequence of platforms such that there are bootstrap stages with their 3 platforms determined by "sliding a window" that is the 3 tuple through the sequence. This was the original model for bootstrapping. Without a target platform (assume a better world where all compilers are multi-target and all standard libraries are built in their own derivation), this is sufficient. Conversely if one wishes to cross compile "faster", with a "Canadian Cross" bootstrapping stage where `build != host != target`, more bootstrapping stages are needed since no sliding window provides the pesky `pkgsBuildTarget` package set since it skips the Canadian cross stage's "host".
+One can then imagine any sequence of platforms such that there are bootstrap stages with their 3 platforms determined by "sliding a window" that is the 3 tuple through the sequence. This was the original model for bootstrapping. Without a target platform (assume a better world where all compilers are multi-target and all standard libraries are built in their own derivation), this is sufficient. Conversely if one wishes to cross compile "faster", with a "Canadian Cross" bootstrapping stage where `build != host != target`, more bootstrapping stages are needed since no sliding window provides the pesky `pkgsBuildTarget` package set since it skips the Canadian cross stage's "host".
 
 
 ::: note
diff --git a/nixpkgs/doc/stdenv/meta.chapter.md b/nixpkgs/doc/stdenv/meta.chapter.md
new file mode 100644
index 000000000000..dd9f53258555
--- /dev/null
+++ b/nixpkgs/doc/stdenv/meta.chapter.md
@@ -0,0 +1,194 @@
+# Meta-attributes {#chap-meta}
+
+Nix packages can declare *meta-attributes* that contain information about a package such as a description, its homepage, its license, and so on. For instance, the GNU Hello package has a `meta` declaration like this:
+
+```nix
+meta = with lib; {
+  description = "A program that produces a familiar, friendly greeting";
+  longDescription = ''
+    GNU Hello is a program that prints "Hello, world!" when you run it.
+    It is fully customizable.
+  '';
+  homepage = "https://www.gnu.org/software/hello/manual/";
+  license = licenses.gpl3Plus;
+  maintainers = [ maintainers.eelco ];
+  platforms = platforms.all;
+};
+```
+
+Meta-attributes are not passed to the builder of the package. Thus, a change to a meta-attribute doesn’t trigger a recompilation of the package. The value of a meta-attribute must be a string.
+
+The meta-attributes of a package can be queried from the command-line using `nix-env`:
+
+```ShellSession
+$ nix-env -qa hello --json
+{
+    "hello": {
+        "meta": {
+            "description": "A program that produces a familiar, friendly greeting",
+            "homepage": "https://www.gnu.org/software/hello/manual/",
+            "license": {
+                "fullName": "GNU General Public License version 3 or later",
+                "shortName": "GPLv3+",
+                "url": "http://www.fsf.org/licensing/licenses/gpl.html"
+            },
+            "longDescription": "GNU Hello is a program that prints \"Hello, world!\" when you run it.\nIt is fully customizable.\n",
+            "maintainers": [
+                "Ludovic Court\u00e8s <ludo@gnu.org>"
+            ],
+            "platforms": [
+                "i686-linux",
+                "x86_64-linux",
+                "armv5tel-linux",
+                "armv7l-linux",
+                "mips32-linux",
+                "x86_64-darwin",
+                "i686-cygwin",
+                "i686-freebsd",
+                "x86_64-freebsd",
+                "i686-openbsd",
+                "x86_64-openbsd"
+            ],
+            "position": "/home/user/dev/nixpkgs/pkgs/applications/misc/hello/default.nix:14"
+        },
+        "name": "hello-2.9",
+        "system": "x86_64-linux"
+    }
+}
+```
+
+`nix-env` knows about the `description` field specifically:
+
+```ShellSession
+$ nix-env -qa hello --description
+hello-2.3  A program that produces a familiar, friendly greeting
+```
+
+## Standard meta-attributes {#sec-standard-meta-attributes}
+
+It is expected that each meta-attribute is one of the following:
+
+### `description` {#var-meta-description}
+
+A short (one-line) description of the package. This is shown by `nix-env -q --description` and also on the Nixpkgs release pages.
+
+Don’t include a period at the end. Don’t include newline characters. Capitalise the first character. For brevity, don’t repeat the name of package --- just describe what it does.
+
+Wrong: `"libpng is a library that allows you to decode PNG images."`
+
+Right: `"A library for decoding PNG images"`
+
+### `longDescription` {#var-meta-longDescription}
+
+An arbitrarily long description of the package.
+
+### `branch` {#var-meta-branch}
+
+Release branch. Used to specify that a package is not going to receive updates that are not in this branch; for example, Linux kernel 3.0 is supposed to be updated to 3.0.X, not 3.1.
+
+### `homepage` {#var-meta-homepage}
+
+The package’s homepage. Example: `https://www.gnu.org/software/hello/manual/`
+
+### `downloadPage` {#var-meta-downloadPage}
+
+The page where a link to the current version can be found. Example: `https://ftp.gnu.org/gnu/hello/`
+
+### `changelog` {#var-meta-changelog}
+
+A link or a list of links to the location of Changelog for a package. A link may use expansion to refer to the correct changelog version. Example: `"https://git.savannah.gnu.org/cgit/hello.git/plain/NEWS?h=v${version}"`
+
+### `license` {#var-meta-license}
+
+The license, or licenses, for the package. One from the attribute set defined in [`nixpkgs/lib/licenses.nix`](https://github.com/NixOS/nixpkgs/blob/master/lib/licenses.nix). At this moment using both a list of licenses and a single license is valid. If the license field is in the form of a list representation, then it means that parts of the package are licensed differently. Each license should preferably be referenced by their attribute. The non-list attribute value can also be a space delimited string representation of the contained attribute `shortNames` or `spdxIds`. The following are all valid examples:
+
+- Single license referenced by attribute (preferred) `lib.licenses.gpl3Only`.
+- Single license referenced by its attribute shortName (frowned upon) `"gpl3Only"`.
+- Single license referenced by its attribute spdxId (frowned upon) `"GPL-3.0-only"`.
+- Multiple licenses referenced by attribute (preferred) `with lib.licenses; [ asl20 free ofl ]`.
+- Multiple licenses referenced as a space delimited string of attribute shortNames (frowned upon) `"asl20 free ofl"`.
+
+For details, see [Licenses](#sec-meta-license).
+
+### `maintainers` {#var-meta-maintainers}
+
+A list of the maintainers of this Nix expression. Maintainers are defined in [`nixpkgs/maintainers/maintainer-list.nix`](https://github.com/NixOS/nixpkgs/blob/master/maintainers/maintainer-list.nix). There is no restriction to becoming a maintainer, just add yourself to that list in a separate commit titled “maintainers: add alice”, and reference maintainers with `maintainers = with lib.maintainers; [ alice bob ]`.
+
+### `priority` {#var-meta-priority}
+
+The *priority* of the package, used by `nix-env` to resolve file name conflicts between packages. See the Nix manual page for `nix-env` for details. Example: `"10"` (a low-priority package).
+
+### `platforms` {#var-meta-platforms}
+
+The list of Nix platform types on which the package is supported. Hydra builds packages according to the platform specified. If no platform is specified, the package does not have prebuilt binaries. An example is:
+
+```nix
+meta.platforms = lib.platforms.linux;
+```
+
+Attribute Set `lib.platforms` defines [various common lists](https://github.com/NixOS/nixpkgs/blob/master/lib/systems/doubles.nix) of platforms types.
+
+### `tests` {#var-meta-tests}
+
+::: warning
+This attribute is special in that it is not actually under the `meta` attribute set but rather under the `passthru` attribute set. This is due to how `meta` attributes work, and the fact that they are supposed to contain only metadata, not derivations.
+:::
+
+An attribute set with as values tests. A test is a derivation, which builds successfully when the test passes, and fails to build otherwise. A derivation that is a test needs to have `meta.timeout` defined.
+
+The NixOS tests are available as `nixosTests` in parameters of derivations. For instance, the OpenSMTPD derivation includes lines similar to:
+
+```nix
+{ /* ... */, nixosTests }:
+{
+  # ...
+  passthru.tests = {
+    basic-functionality-and-dovecot-integration = nixosTests.opensmtpd;
+  };
+}
+```
+
+### `timeout` {#var-meta-timeout}
+
+A timeout (in seconds) for building the derivation. If the derivation takes longer than this time to build, it can fail due to breaking the timeout. However, all computers do not have the same computing power, hence some builders may decide to apply a multiplicative factor to this value. When filling this value in, try to keep it approximately consistent with other values already present in `nixpkgs`.
+
+### `hydraPlatforms` {#var-meta-hydraPlatforms}
+
+The list of Nix platform types for which the Hydra instance at `hydra.nixos.org` will build the package. (Hydra is the Nix-based continuous build system.) It defaults to the value of `meta.platforms`. Thus, the only reason to set `meta.hydraPlatforms` is if you want `hydra.nixos.org` to build the package on a subset of `meta.platforms`, or not at all, e.g.
+
+```nix
+meta.platforms = lib.platforms.linux;
+meta.hydraPlatforms = [];
+```
+
+### `broken` {#var-meta-broken}
+
+If set to `true`, the package is marked as "broken", meaning that it won’t show up in `nix-env -qa`, and cannot be built or installed. Such packages should be removed from Nixpkgs eventually unless they are fixed.
+
+### `updateWalker` {#var-meta-updateWalker}
+
+If set to `true`, the package is tested to be updated correctly by the `update-walker.sh` script without additional settings. Such packages have `meta.version` set and their homepage (or the page specified by `meta.downloadPage`) contains a direct link to the package tarball.
+
+## Licenses {#sec-meta-license}
+
+The `meta.license` attribute should preferably contain a value from `lib.licenses` defined in [`nixpkgs/lib/licenses.nix`](https://github.com/NixOS/nixpkgs/blob/master/lib/licenses.nix), or in-place license description of the same format if the license is unlikely to be useful in another expression.
+
+Although it’s typically better to indicate the specific license, a few generic options are available:
+
+### `lib.licenses.free`, `"free"`
+
+Catch-all for free software licenses not listed above.
+
+### `lib.licenses.unfreeRedistributable`, `"unfree-redistributable"`
+
+Unfree package that can be redistributed in binary form. That is, it’s legal to redistribute the *output* of the derivation. This means that the package can be included in the Nixpkgs channel.
+
+Sometimes proprietary software can only be redistributed unmodified. Make sure the builder doesn’t actually modify the original binaries; otherwise we’re breaking the license. For instance, the NVIDIA X11 drivers can be redistributed unmodified, but our builder applies `patchelf` to make them work. Thus, its license is `"unfree"` and it cannot be included in the Nixpkgs channel.
+
+### `lib.licenses.unfree`, `"unfree"`
+
+Unfree package that cannot be redistributed. You can build it yourself, but you cannot redistribute the output of the derivation. Thus it cannot be included in the Nixpkgs channel.
+
+### `lib.licenses.unfreeRedistributableFirmware`, `"unfree-redistributable-firmware"`
+
+This package supplies unfree, redistributable firmware. This is a separate value from `unfree-redistributable` because not everybody cares whether firmware is free.
diff --git a/nixpkgs/doc/stdenv/meta.xml b/nixpkgs/doc/stdenv/meta.xml
deleted file mode 100644
index 91ace0b9cc95..000000000000
--- a/nixpkgs/doc/stdenv/meta.xml
+++ /dev/null
@@ -1,349 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xml:id="chap-meta">
- <title>Meta-attributes</title>
- <para>
-  Nix packages can declare <emphasis>meta-attributes</emphasis> that contain information about a package such as a description, its homepage, its license, and so on. For instance, the GNU Hello package has a <varname>meta</varname> declaration like this:
-<programlisting>
-meta = with lib; {
-  description = "A program that produces a familiar, friendly greeting";
-  longDescription = ''
-    GNU Hello is a program that prints "Hello, world!" when you run it.
-    It is fully customizable.
-  '';
-  homepage = "https://www.gnu.org/software/hello/manual/";
-  license = licenses.gpl3Plus;
-  maintainers = [ maintainers.eelco ];
-  platforms = platforms.all;
-};
-</programlisting>
- </para>
- <para>
-  Meta-attributes are not passed to the builder of the package. Thus, a change to a meta-attribute doesn’t trigger a recompilation of the package. The value of a meta-attribute must be a string.
- </para>
- <para>
-  The meta-attributes of a package can be queried from the command-line using <command>nix-env</command>:
-<screen>
-<prompt>$ </prompt>nix-env -qa hello --json
-{
-    "hello": {
-        "meta": {
-            "description": "A program that produces a familiar, friendly greeting",
-            "homepage": "https://www.gnu.org/software/hello/manual/",
-            "license": {
-                "fullName": "GNU General Public License version 3 or later",
-                "shortName": "GPLv3+",
-                "url": "http://www.fsf.org/licensing/licenses/gpl.html"
-            },
-            "longDescription": "GNU Hello is a program that prints \"Hello, world!\" when you run it.\nIt is fully customizable.\n",
-            "maintainers": [
-                "Ludovic Court\u00e8s &lt;ludo@gnu.org>"
-            ],
-            "platforms": [
-                "i686-linux",
-                "x86_64-linux",
-                "armv5tel-linux",
-                "armv7l-linux",
-                "mips32-linux",
-                "x86_64-darwin",
-                "i686-cygwin",
-                "i686-freebsd",
-                "x86_64-freebsd",
-                "i686-openbsd",
-                "x86_64-openbsd"
-            ],
-            "position": "/home/user/dev/nixpkgs/pkgs/applications/misc/hello/default.nix:14"
-        },
-        "name": "hello-2.9",
-        "system": "x86_64-linux"
-    }
-}
-
-
-</screen>
-  <command>nix-env</command> knows about the <varname>description</varname> field specifically:
-<screen>
-<prompt>$ </prompt>nix-env -qa hello --description
-hello-2.3  A program that produces a familiar, friendly greeting
-</screen>
- </para>
- <section xml:id="sec-standard-meta-attributes">
-  <title>Standard meta-attributes</title>
-
-  <para>
-   It is expected that each meta-attribute is one of the following:
-  </para>
-
-  <variablelist>
-   <varlistentry xml:id="var-meta-description">
-    <term>
-     <varname>description</varname>
-    </term>
-    <listitem>
-     <para>
-      A short (one-line) description of the package. This is shown by <command>nix-env -q --description</command> and also on the Nixpkgs release pages.
-     </para>
-     <para>
-      Don’t include a period at the end. Don’t include newline characters. Capitalise the first character. For brevity, don’t repeat the name of package — just describe what it does.
-     </para>
-     <para>
-      Wrong: <literal>"libpng is a library that allows you to decode PNG images."</literal>
-     </para>
-     <para>
-      Right: <literal>"A library for decoding PNG images"</literal>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-meta-longDescription">
-    <term>
-     <varname>longDescription</varname>
-    </term>
-    <listitem>
-     <para>
-      An arbitrarily long description of the package.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-meta-branch">
-    <term>
-     <varname>branch</varname>
-    </term>
-    <listitem>
-     <para>
-      Release branch. Used to specify that a package is not going to receive updates that are not in this branch; for example, Linux kernel 3.0 is supposed to be updated to 3.0.X, not 3.1.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-meta-homepage">
-    <term>
-     <varname>homepage</varname>
-    </term>
-    <listitem>
-     <para>
-      The package’s homepage. Example: <literal>https://www.gnu.org/software/hello/manual/</literal>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-meta-downloadPage">
-    <term>
-     <varname>downloadPage</varname>
-    </term>
-    <listitem>
-     <para>
-      The page where a link to the current version can be found. Example: <literal>https://ftp.gnu.org/gnu/hello/</literal>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-meta-changelog">
-    <term>
-     <varname>changelog</varname>
-    </term>
-    <listitem>
-     <para>
-      A link or a list of links to the location of Changelog for a package. A link may use expansion to refer to the correct changelog version. Example: <literal>"https://git.savannah.gnu.org/cgit/hello.git/plain/NEWS?h=v${version}"</literal>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-meta-license">
-    <term>
-     <varname>license</varname>
-    </term>
-    <listitem>
-     <para>
-      The license, or licenses, for the package. One from the attribute set defined in <link
-          xlink:href="https://github.com/NixOS/nixpkgs/blob/master/lib/licenses.nix"> <filename>nixpkgs/lib/licenses.nix</filename></link>. At this moment using both a list of licenses and a single license is valid. If the license field is in the form of a list representation, then it means that parts of the package are licensed differently. Each license should preferably be referenced by their attribute. The non-list attribute value can also be a space delimited string representation of the contained attribute shortNames or spdxIds. The following are all valid examples:
-      <itemizedlist>
-       <listitem>
-        <para>
-         Single license referenced by attribute (preferred) <literal>lib.licenses.gpl3Only</literal>.
-        </para>
-       </listitem>
-       <listitem>
-        <para>
-         Single license referenced by its attribute shortName (frowned upon) <literal>"gpl3Only"</literal>.
-        </para>
-       </listitem>
-       <listitem>
-        <para>
-         Single license referenced by its attribute spdxId (frowned upon) <literal>"GPL-3.0-only"</literal>.
-        </para>
-       </listitem>
-       <listitem>
-        <para>
-         Multiple licenses referenced by attribute (preferred) <literal>with lib.licenses; [ asl20 free ofl ]</literal>.
-        </para>
-       </listitem>
-       <listitem>
-        <para>
-         Multiple licenses referenced as a space delimited string of attribute shortNames (frowned upon) <literal>"asl20 free ofl"</literal>.
-        </para>
-       </listitem>
-      </itemizedlist>
-      For details, see <xref linkend='sec-meta-license'/>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-meta-maintainers">
-    <term>
-     <varname>maintainers</varname>
-    </term>
-    <listitem>
-     <para>
-      A list of the maintainers of this Nix expression. Maintainers are defined in <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/maintainers/maintainer-list.nix"><filename>nixpkgs/maintainers/maintainer-list.nix</filename></link>. There is no restriction to becoming a maintainer, just add yourself to that list in a separate commit titled 'maintainers: add alice', and reference maintainers with <literal>maintainers = with lib.maintainers; [ alice bob ]</literal>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-meta-priority">
-    <term>
-     <varname>priority</varname>
-    </term>
-    <listitem>
-     <para>
-      The <emphasis>priority</emphasis> of the package, used by <command>nix-env</command> to resolve file name conflicts between packages. See the Nix manual page for <command>nix-env</command> for details. Example: <literal>"10"</literal> (a low-priority package).
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-meta-platforms">
-    <term>
-     <varname>platforms</varname>
-    </term>
-    <listitem>
-     <para>
-      The list of Nix platform types on which the package is supported. Hydra builds packages according to the platform specified. If no platform is specified, the package does not have prebuilt binaries. An example is:
-<programlisting>
-meta.platforms = lib.platforms.linux;
-</programlisting>
-      Attribute Set <varname>lib.platforms</varname> defines <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/lib/systems/doubles.nix"> various common lists</link> of platforms types.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-meta-tests">
-    <term>
-     <varname>tests</varname>
-    </term>
-    <listitem>
-     <warning>
-      <para>
-       This attribute is special in that it is not actually under the <literal>meta</literal> attribute set but rather under the <literal>passthru</literal> attribute set. This is due to how <literal>meta</literal> attributes work, and the fact that they are supposed to contain only metadata, not derivations.
-      </para>
-     </warning>
-     <para>
-      An attribute set with as values tests. A test is a derivation, which builds successfully when the test passes, and fails to build otherwise. A derivation that is a test needs to have <literal>meta.timeout</literal> defined.
-     </para>
-     <para>
-      The NixOS tests are available as <literal>nixosTests</literal> in parameters of derivations. For instance, the OpenSMTPD derivation includes lines similar to:
-<programlisting>
-{ /* ... */, nixosTests }:
-{
-  # ...
-  passthru.tests = {
-    basic-functionality-and-dovecot-integration = nixosTests.opensmtpd;
-  };
-}
-</programlisting>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-meta-timeout">
-    <term>
-     <varname>timeout</varname>
-    </term>
-    <listitem>
-     <para>
-      A timeout (in seconds) for building the derivation. If the derivation takes longer than this time to build, it can fail due to breaking the timeout. However, all computers do not have the same computing power, hence some builders may decide to apply a multiplicative factor to this value. When filling this value in, try to keep it approximately consistent with other values already present in <literal>nixpkgs</literal>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-meta-hydraPlatforms">
-    <term>
-     <varname>hydraPlatforms</varname>
-    </term>
-    <listitem>
-     <para>
-      The list of Nix platform types for which the Hydra instance at <literal>hydra.nixos.org</literal> will build the package. (Hydra is the Nix-based continuous build system.) It defaults to the value of <varname>meta.platforms</varname>. Thus, the only reason to set <varname>meta.hydraPlatforms</varname> is if you want <literal>hydra.nixos.org</literal> to build the package on a subset of <varname>meta.platforms</varname>, or not at all, e.g.
-<programlisting>
-meta.platforms = lib.platforms.linux;
-meta.hydraPlatforms = [];
-</programlisting>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-meta-broken">
-    <term>
-     <varname>broken</varname>
-    </term>
-    <listitem>
-     <para>
-      If set to <literal>true</literal>, the package is marked as “broken”, meaning that it won’t show up in <literal>nix-env -qa</literal>, and cannot be built or installed. Such packages should be removed from Nixpkgs eventually unless they are fixed.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-meta-updateWalker">
-    <term>
-     <varname>updateWalker</varname>
-    </term>
-    <listitem>
-     <para>
-      If set to <literal>true</literal>, the package is tested to be updated correctly by the <literal>update-walker.sh</literal> script without additional settings. Such packages have <varname>meta.version</varname> set and their homepage (or the page specified by <varname>meta.downloadPage</varname>) contains a direct link to the package tarball.
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
- </section>
- <section xml:id="sec-meta-license">
-  <title>Licenses</title>
-
-  <para>
-   The <varname>meta.license</varname> attribute should preferrably contain a value from <varname>lib.licenses</varname> defined in <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/lib/licenses.nix"> <filename>nixpkgs/lib/licenses.nix</filename></link>, or in-place license description of the same format if the license is unlikely to be useful in another expression.
-  </para>
-
-  <para>
-   Although it's typically better to indicate the specific license, a few generic options are available:
-   <variablelist>
-    <varlistentry>
-     <term>
-      <varname>lib.licenses.free</varname>, <varname>"free"</varname>
-     </term>
-     <listitem>
-      <para>
-       Catch-all for free software licenses not listed above.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <varname>lib.licenses.unfreeRedistributable</varname>, <varname>"unfree-redistributable"</varname>
-     </term>
-     <listitem>
-      <para>
-       Unfree package that can be redistributed in binary form. That is, it’s legal to redistribute the <emphasis>output</emphasis> of the derivation. This means that the package can be included in the Nixpkgs channel.
-      </para>
-      <para>
-       Sometimes proprietary software can only be redistributed unmodified. Make sure the builder doesn’t actually modify the original binaries; otherwise we’re breaking the license. For instance, the NVIDIA X11 drivers can be redistributed unmodified, but our builder applies <command>patchelf</command> to make them work. Thus, its license is <varname>"unfree"</varname> and it cannot be included in the Nixpkgs channel.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <varname>lib.licenses.unfree</varname>, <varname>"unfree"</varname>
-     </term>
-     <listitem>
-      <para>
-       Unfree package that cannot be redistributed. You can build it yourself, but you cannot redistribute the output of the derivation. Thus it cannot be included in the Nixpkgs channel.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <varname>lib.licenses.unfreeRedistributableFirmware</varname>, <varname>"unfree-redistributable-firmware"</varname>
-     </term>
-     <listitem>
-      <para>
-       This package supplies unfree, redistributable firmware. This is a separate value from <varname>unfree-redistributable</varname> because not everybody cares whether firmware is free.
-      </para>
-     </listitem>
-    </varlistentry>
-   </variablelist>
-  </para>
- </section>
-</chapter>
diff --git a/nixpkgs/doc/stdenv/multiple-output.chapter.md b/nixpkgs/doc/stdenv/multiple-output.chapter.md
new file mode 100644
index 000000000000..90bc25bef739
--- /dev/null
+++ b/nixpkgs/doc/stdenv/multiple-output.chapter.md
@@ -0,0 +1,128 @@
+# Multiple-output packages {#chap-multiple-output}
+
+## Introduction {#sec-multiple-outputs-introduction}
+
+The Nix language allows a derivation to produce multiple outputs, which is similar to what is utilized by other Linux distribution packaging systems. The outputs reside in separate Nix store paths, so they can be mostly handled independently of each other, including passing to build inputs, garbage collection or binary substitution. The exception is that building from source always produces all the outputs.
+
+The main motivation is to save disk space by reducing runtime closure sizes; consequently also sizes of substituted binaries get reduced. Splitting can be used to have more granular runtime dependencies, for example the typical reduction is to split away development-only files, as those are typically not needed during runtime. As a result, closure sizes of many packages can get reduced to a half or even much less.
+
+::: note
+The reduction effects could be instead achieved by building the parts in completely separate derivations. That would often additionally reduce build-time closures, but it tends to be much harder to write such derivations, as build systems typically assume all parts are being built at once. This compromise approach of single source package producing multiple binary packages is also utilized often by rpm and deb.
+:::
+
+A number of attributes can be used to work with a derivation with multiple outputs. The attribute `outputs` is a list of strings, which are the names of the outputs. For each of these names, an identically named attribute is created, corresponding to that output. The attribute `meta.outputsToInstall` is used to determine the default set of outputs to install when using the derivation name unqualified.
+
+## Installing a split package {#sec-multiple-outputs-installing}
+
+When installing a package with multiple outputs, the package’s `meta.outputsToInstall` attribute determines which outputs are actually installed. `meta.outputsToInstall` is a list whose [default installs binaries and the associated man pages](https://github.com/NixOS/nixpkgs/blob/f1680774340d5443a1409c3421ced84ac1163ba9/pkgs/stdenv/generic/make-derivation.nix#L310-L320). The following sections describe ways to install different outputs.
+
+### Selecting outputs to install via NixOS {#sec-multiple-outputs-installing-nixos}
+
+NixOS provides two ways to select the outputs to install for packages listed in `environment.systemPackages`:
+
+- The configuration option `environment.extraOutputsToInstall` is appended to each package’s `meta.outputsToInstall` attribute to determine the outputs to install. It can for example be used to install `info` documentation or debug symbols for all packages.
+
+- The outputs can be listed as packages in `environment.systemPackages`. For example, the `"out"` and `"info"` outputs for the `coreutils` package can be installed by including `coreutils` and `coreutils.info` in `environment.systemPackages`.
+
+### Selecting outputs to install via `nix-env` {#sec-multiple-outputs-installing-nix-env}
+
+`nix-env` lacks an easy way to select the outputs to install. When installing a package, `nix-env` always installs the outputs listed in `meta.outputsToInstall`, even when the user explicitly selects an output.
+
+::: warning
+`nix-env` silenty disregards the outputs selected by the user, and instead installs the outputs from `meta.outputsToInstall`. For example,
+
+```ShellSession
+$ nix-env -iA nixpkgs.coreutils.info
+```
+
+installs the `"out"` output (`coreutils.meta.outputsToInstall` is `[ "out" ]`) instead of the requested `"info"`.
+:::
+
+The only recourse to select an output with `nix-env` is to override the package’s `meta.outputsToInstall`, using the functions described in <xref linkend="chap-overrides" />. For example, the following overlay adds the `"info"` output for the `coreutils` package:
+
+```nix
+self: super:
+{
+  coreutils = super.coreutils.overrideAttrs (oldAttrs: {
+    meta = oldAttrs.meta // { outputsToInstall = oldAttrs.meta.outputsToInstall or [ "out" ] ++ [ "info" ]; };
+  });
+}
+```
+
+## Using a split package {#sec-multiple-outputs-using-split-packages}
+
+In the Nix language the individual outputs can be reached explicitly as attributes, e.g. `coreutils.info`, but the typical case is just using packages as build inputs.
+
+When a multiple-output derivation gets into a build input of another derivation, the `dev` output is added if it exists, otherwise the first output is added. In addition to that, `propagatedBuildOutputs` of that package which by default contain `$outputBin` and `$outputLib` are also added. (See <xref linkend="multiple-output-file-type-groups" />.)
+
+In some cases it may be desirable to combine different outputs under a single store path. A function `symlinkJoin` can be used to do this. (Note that it may negate some closure size benefits of using a multiple-output package.)
+
+## Writing a split derivation {#sec-multiple-outputs-}
+
+Here you find how to write a derivation that produces multiple outputs.
+
+In nixpkgs there is a framework supporting multiple-output derivations. It tries to cover most cases by default behavior. You can find the source separated in `<nixpkgs/pkgs/build-support/setup-hooks/multiple-outputs.sh>`; it’s relatively well-readable. The whole machinery is triggered by defining the `outputs` attribute to contain the list of desired output names (strings).
+
+```nix
+outputs = [ "bin" "dev" "out" "doc" ];
+```
+
+Often such a single line is enough. For each output an equally named environment variable is passed to the builder and contains the path in nix store for that output. Typically you also want to have the main `out` output, as it catches any files that didn’t get elsewhere.
+
+::: note
+There is a special handling of the `debug` output, described at <xref linkend="stdenv-separateDebugInfo" />.
+:::
+
+### “Binaries first” {#multiple-output-file-binaries-first-convention}
+
+A commonly adopted convention in `nixpkgs` is that executables provided by the package are contained within its first output. This convention allows the dependent packages to reference the executables provided by packages in a uniform manner. For instance, provided with the knowledge that the `perl` package contains a `perl` executable it can be referenced as `${pkgs.perl}/bin/perl` within a Nix derivation that needs to execute a Perl script.
+
+The `glibc` package is a deliberate single exception to the “binaries first” convention. The `glibc` has `libs` as its first output allowing the libraries provided by `glibc` to be referenced directly (e.g. `${stdenv.glibc}/lib/ld-linux-x86-64.so.2`). The executables provided by `glibc` can be accessed via its `bin` attribute (e.g. `${stdenv.glibc.bin}/bin/ldd`).
+
+The reason for why `glibc` deviates from the convention is because referencing a library provided by `glibc` is a very common operation among Nix packages. For instance, third-party executables packaged by Nix are typically patched and relinked with the relevant version of `glibc` libraries from Nix packages (please see the documentation on [patchelf](https://github.com/NixOS/patchelf/blob/master/README) for more details).
+
+### File type groups {#multiple-output-file-type-groups}
+
+The support code currently recognizes some particular kinds of outputs and either instructs the build system of the package to put files into their desired outputs or it moves the files during the fixup phase. Each group of file types has an `outputFoo` variable specifying the output name where they should go. If that variable isn’t defined by the derivation writer, it is guessed – a default output name is defined, falling back to other possibilities if the output isn’t defined.
+
+#### ` $outputDev`
+
+is for development-only files. These include C(++) headers (`include/`), pkg-config (`lib/pkgconfig/`), cmake (`lib/cmake/`) and aclocal files (`share/aclocal/`). They go to `dev` or `out` by default.
+
+#### ` $outputBin`
+
+is meant for user-facing binaries, typically residing in `bin/`. They go to `bin` or `out` by default.
+
+#### ` $outputLib`
+
+is meant for libraries, typically residing in `lib/` and `libexec/`. They go to `lib` or `out` by default.
+
+#### ` $outputDoc`
+
+is for user documentation, typically residing in `share/doc/`. It goes to `doc` or `out` by default.
+
+#### ` $outputDevdoc`
+
+is for _developer_ documentation. Currently we count gtk-doc and devhelp books, typically residing in `share/gtk-doc/` and `share/devhelp/`, in there. It goes to `devdoc` or is removed (!) by default. This is because e.g. gtk-doc tends to be rather large and completely unused by nixpkgs users.
+
+#### ` $outputMan`
+
+is for man pages (except for section 3), typically residing in `share/man/man[0-9]/`. They go to `man` or `$outputBin` by default.
+
+#### ` $outputDevman`
+
+is for section 3 man pages, typically residing in `share/man/man[0-9]/`. They go to `devman` or `$outputMan` by default.
+
+#### ` $outputInfo`
+
+is for info pages, typically residing in `share/info/`. They go to `info` or `$outputBin` by default.
+
+### Common caveats {#sec-multiple-outputs-caveats}
+
+- Some configure scripts don’t like some of the parameters passed by default by the framework, e.g. `--docdir=/foo/bar`. You can disable this by setting `setOutputFlags = false;`.
+
+- The outputs of a single derivation can retain references to each other, but note that circular references are not allowed. (And each strongly-connected component would act as a single output anyway.)
+
+- Most of split packages contain their core functionality in libraries. These libraries tend to refer to various kind of data that typically gets into `out`, e.g. locale strings, so there is often no advantage in separating the libraries into `lib`, as keeping them in `out` is easier.
+
+- Some packages have hidden assumptions on install paths, which complicates splitting.
diff --git a/nixpkgs/doc/stdenv/multiple-output.xml b/nixpkgs/doc/stdenv/multiple-output.xml
deleted file mode 100644
index 20658918db72..000000000000
--- a/nixpkgs/doc/stdenv/multiple-output.xml
+++ /dev/null
@@ -1,262 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE chapter [
-  <!ENTITY ndash "&#x2013;"> <!-- @vcunat likes to use this one ;-) -->
-]>
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xml:id="chap-multiple-output">
- <title>Multiple-output packages</title>
- <section xml:id="sec-multiple-outputs-introduction">
-  <title>Introduction</title>
-
-  <para>
-   The Nix language allows a derivation to produce multiple outputs, which is similar to what is utilized by other Linux distribution packaging systems. The outputs reside in separate Nix store paths, so they can be mostly handled independently of each other, including passing to build inputs, garbage collection or binary substitution. The exception is that building from source always produces all the outputs.
-  </para>
-
-  <para>
-   The main motivation is to save disk space by reducing runtime closure sizes; consequently also sizes of substituted binaries get reduced. Splitting can be used to have more granular runtime dependencies, for example the typical reduction is to split away development-only files, as those are typically not needed during runtime. As a result, closure sizes of many packages can get reduced to a half or even much less.
-  </para>
-
-  <note>
-   <para>
-    The reduction effects could be instead achieved by building the parts in completely separate derivations. That would often additionally reduce build-time closures, but it tends to be much harder to write such derivations, as build systems typically assume all parts are being built at once. This compromise approach of single source package producing multiple binary packages is also utilized often by rpm and deb.
-   </para>
-  </note>
-
-  <para>
-   A number of attributes can be used to work with a derivation with multiple outputs. The attribute <varname>outputs</varname> is a list of strings, which are the names of the outputs. For each of these names, an identically named attribute is created, corresponding to that output. The attribute <varname>meta.outputsToInstall</varname> is used to determine the default set of outputs to install when using the derivation name unqualified.
-  </para>
-
- </section>
- <section xml:id="sec-multiple-outputs-installing">
-  <title>Installing a split package</title>
-
-  <para>
-   When installing a package with multiple outputs, the package's <varname>meta.outputsToInstall</varname> attribute determines which outputs are actually installed. <varname>meta.outputsToInstall</varname> is a list whose <link xlink:href="https://github.com/NixOS/nixpkgs/blob/f1680774340d5443a1409c3421ced84ac1163ba9/pkgs/stdenv/generic/make-derivation.nix#L310-L320">default installs binaries and the associated man pages</link>. The following sections describe ways to install different outputs.
-  </para>
-
-  <section xml:id="sec-multiple-outputs-installing-nixos">
-   <title>Selecting outputs to install via NixOS</title>
-
-   <para>
-    NixOS provides two ways to select the outputs to install for packages listed in <varname>environment.systemPackages</varname>:
-   </para>
-
-   <itemizedlist>
-    <listitem>
-     <para>
-      The configuration option <varname>environment.extraOutputsToInstall</varname> is appended to each package's <varname>meta.outputsToInstall</varname> attribute to determine the outputs to install. It can for example be used to install <literal>info</literal> documentation or debug symbols for all packages.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      The outputs can be listed as packages in <varname>environment.systemPackages</varname>. For example, the <literal>"out"</literal> and <literal>"info"</literal> outputs for the <varname>coreutils</varname> package can be installed by including <varname>coreutils</varname> and <varname>coreutils.info</varname> in <varname>environment.systemPackages</varname>.
-     </para>
-    </listitem>
-   </itemizedlist>
-  </section>
-
-  <section xml:id="sec-multiple-outputs-installing-nix-env">
-   <title>Selecting outputs to install via <command>nix-env</command></title>
-
-   <para>
-    <command>nix-env</command> lacks an easy way to select the outputs to install. When installing a package, <command>nix-env</command> always installs the outputs listed in <varname>meta.outputsToInstall</varname>, even when the user explicitly selects an output.
-   </para>
-
-   <warning>
-    <para>
-     <command>nix-env</command> silenty disregards the outputs selected by the user, and instead installs the outputs from <varname>meta.outputsToInstall</varname>. For example,
-    </para>
-<screen><prompt>$ </prompt>nix-env -iA nixpkgs.coreutils.info</screen>
-    <para>
-     installs the <literal>"out"</literal> output (<varname>coreutils.meta.outputsToInstall</varname> is <literal>[ "out" ]</literal>) instead of the requested <literal>"info"</literal>.
-    </para>
-   </warning>
-
-   <para>
-    The only recourse to select an output with <command>nix-env</command> is to override the package's <varname>meta.outputsToInstall</varname>, using the functions described in <xref linkend="chap-overrides" />. For example, the following overlay adds the <literal>"info"</literal> output for the <varname>coreutils</varname> package:
-   </para>
-
-<programlisting>self: super:
-{
-  coreutils = super.coreutils.overrideAttrs (oldAttrs: {
-    meta = oldAttrs.meta // { outputsToInstall = oldAttrs.meta.outputsToInstall or [ "out" ] ++ [ "info" ]; };
-  });
-}
-</programlisting>
-  </section>
- </section>
- <section xml:id="sec-multiple-outputs-using-split-packages">
-  <title>Using a split package</title>
-
-  <para>
-   In the Nix language the individual outputs can be reached explicitly as attributes, e.g. <varname>coreutils.info</varname>, but the typical case is just using packages as build inputs.
-  </para>
-
-  <para>
-   When a multiple-output derivation gets into a build input of another derivation, the <varname>dev</varname> output is added if it exists, otherwise the first output is added. In addition to that, <varname>propagatedBuildOutputs</varname> of that package which by default contain <varname>$outputBin</varname> and <varname>$outputLib</varname> are also added. (See <xref linkend="multiple-output-file-type-groups" />.)
-  </para>
-
-  <para>
-   In some cases it may be desirable to combine different outputs under a single store path. A function <literal>symlinkJoin</literal> can be used to do this. (Note that it may negate some closure size benefits of using a multiple-output package.)
-  </para>
- </section>
- <section xml:id="sec-multiple-outputs-">
-  <title>Writing a split derivation</title>
-
-  <para>
-   Here you find how to write a derivation that produces multiple outputs.
-  </para>
-
-  <para>
-   In nixpkgs there is a framework supporting multiple-output derivations. It tries to cover most cases by default behavior. You can find the source separated in &lt;<filename>nixpkgs/pkgs/build-support/setup-hooks/multiple-outputs.sh</filename>&gt;; it's relatively well-readable. The whole machinery is triggered by defining the <varname>outputs</varname> attribute to contain the list of desired output names (strings).
-  </para>
-
-<programlisting>outputs = [ "bin" "dev" "out" "doc" ];</programlisting>
-
-  <para>
-   Often such a single line is enough. For each output an equally named environment variable is passed to the builder and contains the path in nix store for that output. Typically you also want to have the main <varname>out</varname> output, as it catches any files that didn't get elsewhere.
-  </para>
-
-  <note>
-   <para>
-    There is a special handling of the <varname>debug</varname> output, described at <xref linkend="stdenv-separateDebugInfo" />.
-   </para>
-  </note>
-
-  <section xml:id="multiple-output-file-binaries-first-convention">
-   <title><quote>Binaries first</quote></title>
-
-   <para>
-    A commonly adopted convention in <literal>nixpkgs</literal> is that executables provided by the package are contained within its first output. This convention allows the dependent packages to reference the executables provided by packages in a uniform manner. For instance, provided with the knowledge that the <literal>perl</literal> package contains a <literal>perl</literal> executable it can be referenced as <literal>${pkgs.perl}/bin/perl</literal> within a Nix derivation that needs to execute a Perl script.
-   </para>
-
-   <para>
-    The <literal>glibc</literal> package is a deliberate single exception to the <quote>binaries first</quote> convention. The <literal>glibc</literal> has <literal>libs</literal> as its first output allowing the libraries provided by <literal>glibc</literal> to be referenced directly (e.g. <literal>${stdenv.glibc}/lib/ld-linux-x86-64.so.2</literal>). The executables provided by <literal>glibc</literal> can be accessed via its <literal>bin</literal> attribute (e.g. <literal>${stdenv.glibc.bin}/bin/ldd</literal>).
-   </para>
-
-   <para>
-    The reason for why <literal>glibc</literal> deviates from the convention is because referencing a library provided by <literal>glibc</literal> is a very common operation among Nix packages. For instance, third-party executables packaged by Nix are typically patched and relinked with the relevant version of <literal>glibc</literal> libraries from Nix packages (please see the documentation on <link xlink:href="https://github.com/NixOS/patchelf/blob/master/README">patchelf</link> for more details).
-   </para>
-  </section>
-
-  <section xml:id="multiple-output-file-type-groups">
-   <title>File type groups</title>
-
-   <para>
-    The support code currently recognizes some particular kinds of outputs and either instructs the build system of the package to put files into their desired outputs or it moves the files during the fixup phase. Each group of file types has an <varname>outputFoo</varname> variable specifying the output name where they should go. If that variable isn't defined by the derivation writer, it is guessed &ndash; a default output name is defined, falling back to other possibilities if the output isn't defined.
-   </para>
-
-   <variablelist>
-    <varlistentry>
-     <term>
-      <varname> $outputDev</varname>
-     </term>
-     <listitem>
-      <para>
-       is for development-only files. These include C(++) headers, pkg-config, cmake and aclocal files. They go to <varname>dev</varname> or <varname>out</varname> by default.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <varname> $outputBin</varname>
-     </term>
-     <listitem>
-      <para>
-       is meant for user-facing binaries, typically residing in bin/. They go to <varname>bin</varname> or <varname>out</varname> by default.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <varname> $outputLib</varname>
-     </term>
-     <listitem>
-      <para>
-       is meant for libraries, typically residing in <filename>lib/</filename> and <filename>libexec/</filename>. They go to <varname>lib</varname> or <varname>out</varname> by default.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <varname> $outputDoc</varname>
-     </term>
-     <listitem>
-      <para>
-       is for user documentation, typically residing in <filename>share/doc/</filename>. It goes to <varname>doc</varname> or <varname>out</varname> by default.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <varname> $outputDevdoc</varname>
-     </term>
-     <listitem>
-      <para>
-       is for <emphasis>developer</emphasis> documentation. Currently we count gtk-doc and devhelp books in there. It goes to <varname>devdoc</varname> or is removed (!) by default. This is because e.g. gtk-doc tends to be rather large and completely unused by nixpkgs users.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <varname> $outputMan</varname>
-     </term>
-     <listitem>
-      <para>
-       is for man pages (except for section 3). They go to <varname>man</varname> or <varname>$outputBin</varname> by default.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <varname> $outputDevman</varname>
-     </term>
-     <listitem>
-      <para>
-       is for section 3 man pages. They go to <varname>devman</varname> or <varname>$outputMan</varname> by default.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <varname> $outputInfo</varname>
-     </term>
-     <listitem>
-      <para>
-       is for info pages. They go to <varname>info</varname> or <varname>$outputBin</varname> by default.
-      </para>
-     </listitem>
-    </varlistentry>
-   </variablelist>
-  </section>
-
-  <section xml:id="sec-multiple-outputs-caveats">
-   <title>Common caveats</title>
-
-   <itemizedlist>
-    <listitem>
-     <para>
-      Some configure scripts don't like some of the parameters passed by default by the framework, e.g. <literal>--docdir=/foo/bar</literal>. You can disable this by setting <literal>setOutputFlags = false;</literal>.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      The outputs of a single derivation can retain references to each other, but note that circular references are not allowed. (And each strongly-connected component would act as a single output anyway.)
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      Most of split packages contain their core functionality in libraries. These libraries tend to refer to various kind of data that typically gets into <varname>out</varname>, e.g. locale strings, so there is often no advantage in separating the libraries into <varname>lib</varname>, as keeping them in <varname>out</varname> is easier.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      Some packages have hidden assumptions on install paths, which complicates splitting.
-     </para>
-    </listitem>
-   </itemizedlist>
-  </section>
- </section>
-<!--Writing a split derivation-->
-</chapter>
diff --git a/nixpkgs/doc/stdenv/platform-notes.chapter.md b/nixpkgs/doc/stdenv/platform-notes.chapter.md
new file mode 100644
index 000000000000..03e61e333f8b
--- /dev/null
+++ b/nixpkgs/doc/stdenv/platform-notes.chapter.md
@@ -0,0 +1,62 @@
+# Platform Notes {#chap-platform-notes}
+
+## Darwin (macOS) {#sec-darwin}
+
+Some common issues when packaging software for Darwin:
+
+- The Darwin `stdenv` uses clang instead of gcc. When referring to the compiler `$CC` or `cc` will work in both cases. Some builds hardcode gcc/g++ in their build scripts, that can usually be fixed with using something like `makeFlags = [ "CC=cc" ];` or by patching the build scripts.
+
+  ```nix
+  stdenv.mkDerivation {
+    name = "libfoo-1.2.3";
+    # ...
+    buildPhase = ''
+      $CC -o hello hello.c
+    '';
+  }
+  ```
+
+- On Darwin, libraries are linked using absolute paths, libraries are resolved by their `install_name` at link time. Sometimes packages won’t set this correctly causing the library lookups to fail at runtime. This can be fixed by adding extra linker flags or by running `install_name_tool -id` during the `fixupPhase`.
+
+  ```nix
+  stdenv.mkDerivation {
+    name = "libfoo-1.2.3";
+    # ...
+    makeFlags = lib.optional stdenv.isDarwin "LDFLAGS=-Wl,-install_name,$(out)/lib/libfoo.dylib";
+  }
+  ```
+
+- Even if the libraries are linked using absolute paths and resolved via their `install_name` correctly, tests can sometimes fail to run binaries. This happens because the `checkPhase` runs before the libraries are installed.
+
+  This can usually be solved by running the tests after the `installPhase` or alternatively by using `DYLD_LIBRARY_PATH`. More information about this variable can be found in the *dyld(1)* manpage.
+
+  ```
+  dyld: Library not loaded: /nix/store/7hnmbscpayxzxrixrgxvvlifzlxdsdir-jq-1.5-lib/lib/libjq.1.dylib
+  Referenced from: /private/tmp/nix-build-jq-1.5.drv-0/jq-1.5/tests/../jq
+  Reason: image not found
+  ./tests/jqtest: line 5: 75779 Abort trap: 6
+  ```
+
+  ```nix
+  stdenv.mkDerivation {
+    name = "libfoo-1.2.3";
+    # ...
+    doInstallCheck = true;
+    installCheckTarget = "check";
+  }
+  ```
+
+- Some packages assume xcode is available and use `xcrun` to resolve build tools like `clang`, etc. This causes errors like `xcode-select: error: no developer tools were found at '/Applications/Xcode.app'` while the build doesn’t actually depend on xcode.
+
+  ```nix
+  stdenv.mkDerivation {
+    name = "libfoo-1.2.3";
+    # ...
+    prePatch = ''
+      substituteInPlace Makefile \
+          --replace '/usr/bin/xcrun clang' clang
+    '';
+  }
+  ```
+
+  The package `xcbuild` can be used to build projects that really depend on Xcode. However, this replacement is not 100% compatible with Xcode and can occasionally cause issues.
diff --git a/nixpkgs/doc/stdenv/platform-notes.xml b/nixpkgs/doc/stdenv/platform-notes.xml
deleted file mode 100644
index cc8efaece129..000000000000
--- a/nixpkgs/doc/stdenv/platform-notes.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xml:id="chap-platform-notes">
- <title>Platform Notes</title>
- <section xml:id="sec-darwin">
-  <title>Darwin (macOS)</title>
-
-  <para>
-   Some common issues when packaging software for Darwin:
-  </para>
-
-  <itemizedlist>
-   <listitem>
-    <para>
-     The Darwin <literal>stdenv</literal> uses clang instead of gcc. When referring to the compiler <varname>$CC</varname> or <command>cc</command> will work in both cases. Some builds hardcode gcc/g++ in their build scripts, that can usually be fixed with using something like <literal>makeFlags = [ "CC=cc" ];</literal> or by patching the build scripts.
-    </para>
-<programlisting>
-stdenv.mkDerivation {
-  name = "libfoo-1.2.3";
-  # ...
-  buildPhase = ''
-    $CC -o hello hello.c
-  '';
-}
-</programlisting>
-   </listitem>
-   <listitem>
-    <para>
-     On Darwin, libraries are linked using absolute paths, libraries are resolved by their <literal>install_name</literal> at link time. Sometimes packages won't set this correctly causing the library lookups to fail at runtime. This can be fixed by adding extra linker flags or by running <command>install_name_tool -id</command> during the <function>fixupPhase</function>.
-    </para>
-<programlisting>
-stdenv.mkDerivation {
-  name = "libfoo-1.2.3";
-  # ...
-  makeFlags = lib.optional stdenv.isDarwin "LDFLAGS=-Wl,-install_name,$(out)/lib/libfoo.dylib";
-}
-</programlisting>
-   </listitem>
-   <listitem>
-    <para>
-     Even if the libraries are linked using absolute paths and resolved via their <literal>install_name</literal> correctly, tests can sometimes fail to run binaries. This happens because the <varname>checkPhase</varname> runs before the libraries are installed.
-    </para>
-    <para>
-     This can usually be solved by running the tests after the <varname>installPhase</varname> or alternatively by using <varname>DYLD_LIBRARY_PATH</varname>. More information about this variable can be found in the <citerefentry>
-     <refentrytitle>dyld</refentrytitle>
-     <manvolnum>1</manvolnum></citerefentry> manpage.
-    </para>
-<programlisting>
-dyld: Library not loaded: /nix/store/7hnmbscpayxzxrixrgxvvlifzlxdsdir-jq-1.5-lib/lib/libjq.1.dylib
-Referenced from: /private/tmp/nix-build-jq-1.5.drv-0/jq-1.5/tests/../jq
-Reason: image not found
-./tests/jqtest: line 5: 75779 Abort trap: 6
-</programlisting>
-<programlisting>
-stdenv.mkDerivation {
-  name = "libfoo-1.2.3";
-  # ...
-  doInstallCheck = true;
-  installCheckTarget = "check";
-}
-</programlisting>
-   </listitem>
-   <listitem>
-    <para>
-     Some packages assume xcode is available and use <command>xcrun</command> to resolve build tools like <command>clang</command>, etc. This causes errors like <code>xcode-select: error: no developer tools were found at '/Applications/Xcode.app'</code> while the build doesn't actually depend on xcode.
-    </para>
-<programlisting>
-stdenv.mkDerivation {
-  name = "libfoo-1.2.3";
-  # ...
-  prePatch = ''
-    substituteInPlace Makefile \
-        --replace '/usr/bin/xcrun clang' clang
-  '';
-}
-</programlisting>
-    <para>
-     The package <literal>xcbuild</literal> can be used to build projects that really depend on Xcode. However, this replacement is not 100% compatible with Xcode and can occasionally cause issues.
-    </para>
-   </listitem>
-  </itemizedlist>
- </section>
-</chapter>
diff --git a/nixpkgs/doc/stdenv/stdenv.chapter.md b/nixpkgs/doc/stdenv/stdenv.chapter.md
new file mode 100644
index 000000000000..b23c50e83644
--- /dev/null
+++ b/nixpkgs/doc/stdenv/stdenv.chapter.md
@@ -0,0 +1,1215 @@
+# The Standard Environment {#chap-stdenv}
+
+The standard build environment in the Nix Packages collection provides an environment for building Unix packages that does a lot of common build tasks automatically. In fact, for Unix packages that use the standard `./configure; make; make install` build interface, you don’t need to write a build script at all; the standard environment does everything automatically. If `stdenv` doesn’t do what you need automatically, you can easily customise or override the various build phases.
+
+## Using `stdenv` {#sec-using-stdenv}
+
+To build a package with the standard environment, you use the function `stdenv.mkDerivation`, instead of the primitive built-in function `derivation`, e.g.
+
+```nix
+stdenv.mkDerivation {
+  name = "libfoo-1.2.3";
+  src = fetchurl {
+    url = "http://example.org/libfoo-1.2.3.tar.bz2";
+    sha256 = "0x2g1jqygyr5wiwg4ma1nd7w4ydpy82z9gkcv8vh2v8dn3y58v5m";
+  };
+}
+```
+
+(`stdenv` needs to be in scope, so if you write this in a separate Nix expression from `pkgs/all-packages.nix`, you need to pass it as a function argument.) Specifying a `name` and a `src` is the absolute minimum Nix requires. For convenience, you can also use `pname` and `version` attributes and `mkDerivation` will automatically set `name` to `"${pname}-${version}"` by default. Since [RFC 0035](https://github.com/NixOS/rfcs/pull/35), this is preferred for packages in Nixpkgs, as it allows us to reuse the version easily:
+
+```nix
+stdenv.mkDerivation rec {
+  pname = "libfoo";
+  version = "1.2.3";
+  src = fetchurl {
+    url = "http://example.org/libfoo-source-${version}.tar.bz2";
+    sha256 = "0x2g1jqygyr5wiwg4ma1nd7w4ydpy82z9gkcv8vh2v8dn3y58v5m";
+  };
+}
+```
+
+Many packages have dependencies that are not provided in the standard environment. It’s usually sufficient to specify those dependencies in the `buildInputs` attribute:
+
+```nix
+stdenv.mkDerivation {
+  name = "libfoo-1.2.3";
+  ...
+  buildInputs = [libbar perl ncurses];
+}
+```
+
+This attribute ensures that the `bin` subdirectories of these packages appear in the `PATH` environment variable during the build, that their `include` subdirectories are searched by the C compiler, and so on. (See <xref linkend="ssec-setup-hooks" /> for details.)
+
+Often it is necessary to override or modify some aspect of the build. To make this easier, the standard environment breaks the package build into a number of *phases*, all of which can be overridden or modified individually: unpacking the sources, applying patches, configuring, building, and installing. (There are some others; see <xref linkend="sec-stdenv-phases" />.) For instance, a package that doesn’t supply a makefile but instead has to be compiled "manually" could be handled like this:
+
+```nix
+stdenv.mkDerivation {
+  name = "fnord-4.5";
+  ...
+  buildPhase = ''
+    gcc foo.c -o foo
+  '';
+  installPhase = ''
+    mkdir -p $out/bin
+    cp foo $out/bin
+  '';
+}
+```
+
+(Note the use of `''`-style string literals, which are very convenient for large multi-line script fragments because they don’t need escaping of `"` and `\`, and because indentation is intelligently removed.)
+
+There are many other attributes to customise the build. These are listed in <xref linkend="ssec-stdenv-attributes" />.
+
+While the standard environment provides a generic builder, you can still supply your own build script:
+
+```nix
+stdenv.mkDerivation {
+  name = "libfoo-1.2.3";
+  ...
+  builder = ./builder.sh;
+}
+```
+
+where the builder can do anything it wants, but typically starts with
+
+```bash
+source $stdenv/setup
+```
+
+to let `stdenv` set up the environment (e.g., process the `buildInputs`). If you want, you can still use `stdenv`’s generic builder:
+
+```bash
+source $stdenv/setup
+
+buildPhase() {
+  echo "... this is my custom build phase ..."
+  gcc foo.c -o foo
+}
+
+installPhase() {
+  mkdir -p $out/bin
+  cp foo $out/bin
+}
+
+genericBuild
+```
+
+## Tools provided by `stdenv` {#sec-tools-of-stdenv}
+
+The standard environment provides the following packages:
+
+- The GNU C Compiler, configured with C and C++ support.
+- GNU coreutils (contains a few dozen standard Unix commands).
+- GNU findutils (contains `find`).
+- GNU diffutils (contains `diff`, `cmp`).
+- GNU `sed`.
+- GNU `grep`.
+- GNU `awk`.
+- GNU `tar`.
+- `gzip`, `bzip2` and `xz`.
+- GNU Make.
+- Bash. This is the shell used for all builders in the Nix Packages collection. Not using `/bin/sh` removes a large source of portability problems.
+- The `patch` command.
+
+On Linux, `stdenv` also includes the `patchelf` utility.
+
+## Specifying dependencies {#ssec-stdenv-dependencies}
+
+As described in the Nix manual, almost any `*.drv` store path in a derivation’s attribute set will induce a dependency on that derivation. `mkDerivation`, however, takes a few attributes intended to, between them, include all the dependencies of a package. This is done both for structure and consistency, but also so that certain other setup can take place. For example, certain dependencies need their bin directories added to the `PATH`. That is built-in, but other setup is done via a pluggable mechanism that works in conjunction with these dependency attributes. See <xref linkend="ssec-setup-hooks" /> for details.
+
+Dependencies can be broken down along three axes: their host and target platforms relative to the new derivation’s, and whether they are propagated. The platform distinctions are motivated by cross compilation; see <xref linkend="chap-cross" /> for exactly what each platform means. [^footnote-stdenv-ignored-build-platform] But even if one is not cross compiling, the platforms imply whether or not the dependency is needed at run-time or build-time, a concept that makes perfect sense outside of cross compilation. By default, the run-time/build-time distinction is just a hint for mental clarity, but with `strictDeps` set it is mostly enforced even in the native case.
+
+The extension of `PATH` with dependencies, alluded to above, proceeds according to the relative platforms alone. The process is carried out only for dependencies whose host platform matches the new derivation’s build platform i.e. dependencies which run on the platform where the new derivation will be built. [^footnote-stdenv-native-dependencies-in-path] For each dependency \<dep\> of those dependencies, `dep/bin`, if present, is added to the `PATH` environment variable.
+
+The dependency is propagated when it forces some of its other-transitive (non-immediate) downstream dependencies to also take it on as an immediate dependency. Nix itself already takes a package’s transitive dependencies into account, but this propagation ensures nixpkgs-specific infrastructure like setup hooks (mentioned above) also are run as if the propagated dependency.
+
+It is important to note that dependencies are not necessarily propagated as the same sort of dependency that they were before, but rather as the corresponding sort so that the platform rules still line up. The exact rules for dependency propagation can be given by assigning to each dependency two integers based one how its host and target platforms are offset from the depending derivation’s platforms. Those offsets are given below in the descriptions of each dependency list attribute. Algorithmically, we traverse propagated inputs, accumulating every propagated dependency’s propagated dependencies and adjusting them to account for the “shift in perspective” described by the current dependency’s platform offsets. This results in sort a transitive closure of the dependency relation, with the offsets being approximately summed when two dependency links are combined. We also prune transitive dependencies whose combined offsets go out-of-bounds, which can be viewed as a filter over that transitive closure removing dependencies that are blatantly absurd.
+
+We can define the process precisely with [Natural Deduction](https://en.wikipedia.org/wiki/Natural_deduction) using the inference rules. This probably seems a bit obtuse, but so is the bash code that actually implements it! [^footnote-stdenv-find-inputs-location] They’re confusing in very different ways so… hopefully if something doesn’t make sense in one presentation, it will in the other!
+
+```
+let mapOffset(h, t, i) = i + (if i <= 0 then h else t - 1)
+
+propagated-dep(h0, t0, A, B)
+propagated-dep(h1, t1, B, C)
+h0 + h1 in {-1, 0, 1}
+h0 + t1 in {-1, 0, 1}
+-------------------------------------- Transitive property
+propagated-dep(mapOffset(h0, t0, h1),
+               mapOffset(h0, t0, t1),
+               A, C)
+```
+
+```
+let mapOffset(h, t, i) = i + (if i <= 0 then h else t - 1)
+
+dep(h0, _, A, B)
+propagated-dep(h1, t1, B, C)
+h0 + h1 in {-1, 0, 1}
+h0 + t1 in {-1, 0, -1}
+----------------------------- Take immediate dependencies' propagated dependencies
+propagated-dep(mapOffset(h0, t0, h1),
+               mapOffset(h0, t0, t1),
+               A, C)
+```
+
+```
+propagated-dep(h, t, A, B)
+----------------------------- Propagated dependencies count as dependencies
+dep(h, t, A, B)
+```
+
+Some explanation of this monstrosity is in order. In the common case, the target offset of a dependency is the successor to the target offset: `t = h + 1`. That means that:
+
+```
+let f(h, t, i) = i + (if i <= 0 then h else t - 1)
+let f(h, h + 1, i) = i + (if i <= 0 then h else (h + 1) - 1)
+let f(h, h + 1, i) = i + (if i <= 0 then h else h)
+let f(h, h + 1, i) = i + h
+```
+
+This is where “sum-like” comes in from above: We can just sum all of the host offsets to get the host offset of the transitive dependency. The target offset is the transitive dependency is simply the host offset + 1, just as it was with the dependencies composed to make this transitive one; it can be ignored as it doesn’t add any new information.
+
+Because of the bounds checks, the uncommon cases are `h = t` and `h + 2 = t`. In the former case, the motivation for `mapOffset` is that since its host and target platforms are the same, no transitive dependency of it should be able to “discover” an offset greater than its reduced target offsets. `mapOffset` effectively “squashes” all its transitive dependencies’ offsets so that none will ever be greater than the target offset of the original `h = t` package. In the other case, `h + 1` is skipped over between the host and target offsets. Instead of squashing the offsets, we need to “rip” them apart so no transitive dependencies’ offset is that one.
+
+Overall, the unifying theme here is that propagation shouldn’t be introducing transitive dependencies involving platforms the depending package is unaware of. \[One can imagine the dependending package asking for dependencies with the platforms it knows about; other platforms it doesn’t know how to ask for. The platform description in that scenario is a kind of unforagable capability.\] The offset bounds checking and definition of `mapOffset` together ensure that this is the case. Discovering a new offset is discovering a new platform, and since those platforms weren’t in the derivation “spec” of the needing package, they cannot be relevant. From a capability perspective, we can imagine that the host and target platforms of a package are the capabilities a package requires, and the depending package must provide the capability to the dependency.
+
+### Variables specifying dependencies
+#### `depsBuildBuild` {#var-stdenv-depsBuildBuild}
+
+A list of dependencies whose host and target platforms are the new derivation’s build platform. This means a `-1` host and `-1` target offset from the new derivation’s platforms. These are programs and libraries used at build time that produce programs and libraries also used at build time. If the dependency doesn’t care about the target platform (i.e. isn’t a compiler or similar tool), put it in `nativeBuildInputs` instead. The most common use of this `buildPackages.stdenv.cc`, the default C compiler for this role. That example crops up more than one might think in old commonly used C libraries.
+
+Since these packages are able to be run at build-time, they are always added to the `PATH`, as described above. But since these packages are only guaranteed to be able to run then, they shouldn’t persist as run-time dependencies. This isn’t currently enforced, but could be in the future.
+
+#### `nativeBuildInputs` {#var-stdenv-nativeBuildInputs}
+
+A list of dependencies whose host platform is the new derivation’s build platform, and target platform is the new derivation’s host platform. This means a `-1` host offset and `0` target offset from the new derivation’s platforms. These are programs and libraries used at build-time that, if they are a compiler or similar tool, produce code to run at run-time—i.e. tools used to build the new derivation. If the dependency doesn’t care about the target platform (i.e. isn’t a compiler or similar tool), put it here, rather than in `depsBuildBuild` or `depsBuildTarget`. This could be called `depsBuildHost` but `nativeBuildInputs` is used for historical continuity.
+
+Since these packages are able to be run at build-time, they are added to the `PATH`, as described above. But since these packages are only guaranteed to be able to run then, they shouldn’t persist as run-time dependencies. This isn’t currently enforced, but could be in the future.
+
+#### `depsBuildTarget` {#var-stdenv-depsBuildTarget}
+
+A list of dependencies whose host platform is the new derivation’s build platform, and target platform is the new derivation’s target platform. This means a `-1` host offset and `1` target offset from the new derivation’s platforms. These are programs used at build time that produce code to run with code produced by the depending package. Most commonly, these are tools used to build the runtime or standard library that the currently-being-built compiler will inject into any code it compiles. In many cases, the currently-being-built-compiler is itself employed for that task, but when that compiler won’t run (i.e. its build and host platform differ) this is not possible. Other times, the compiler relies on some other tool, like binutils, that is always built separately so that the dependency is unconditional.
+
+This is a somewhat confusing concept to wrap one’s head around, and for good reason. As the only dependency type where the platform offsets are not adjacent integers, it requires thinking of a bootstrapping stage *two* away from the current one. It and its use-case go hand in hand and are both considered poor form: try to not need this sort of dependency, and try to avoid building standard libraries and runtimes in the same derivation as the compiler produces code using them. Instead strive to build those like a normal library, using the newly-built compiler just as a normal library would. In short, do not use this attribute unless you are packaging a compiler and are sure it is needed.
+
+Since these packages are able to run at build time, they are added to the `PATH`, as described above. But since these packages are only guaranteed to be able to run then, they shouldn’t persist as run-time dependencies. This isn’t currently enforced, but could be in the future.
+
+#### `depsHostHost` {#var-stdenv-depsHostHost}
+
+A list of dependencies whose host and target platforms match the new derivation’s host platform. This means a `0` host offset and `0` target offset from the new derivation’s host platform. These are packages used at run-time to generate code also used at run-time. In practice, this would usually be tools used by compilers for macros or a metaprogramming system, or libraries used by the macros or metaprogramming code itself. It’s always preferable to use a `depsBuildBuild` dependency in the derivation being built over a `depsHostHost` on the tool doing the building for this purpose.
+
+#### `buildInputs` {#var-stdenv-buildInputs}
+
+A list of dependencies whose host platform and target platform match the new derivation’s. This means a `0` host offset and a `1` target offset from the new derivation’s host platform. This would be called `depsHostTarget` but for historical continuity. If the dependency doesn’t care about the target platform (i.e. isn’t a compiler or similar tool), put it here, rather than in `depsBuildBuild`.
+
+These are often programs and libraries used by the new derivation at *run*-time, but that isn’t always the case. For example, the machine code in a statically-linked library is only used at run-time, but the derivation containing the library is only needed at build-time. Even in the dynamic case, the library may also be needed at build-time to appease the linker.
+
+#### `depsTargetTarget` {#var-stdenv-depsTargetTarget}
+
+A list of dependencies whose host platform matches the new derivation’s target platform. This means a `1` offset from the new derivation’s platforms. These are packages that run on the target platform, e.g. the standard library or run-time deps of standard library that a compiler insists on knowing about. It’s poor form in almost all cases for a package to depend on another from a future stage \[future stage corresponding to positive offset\]. Do not use this attribute unless you are packaging a compiler and are sure it is needed.
+
+#### `depsBuildBuildPropagated` {#var-stdenv-depsBuildBuildPropagated}
+
+The propagated equivalent of `depsBuildBuild`. This perhaps never ought to be used, but it is included for consistency \[see below for the others\].
+
+#### `propagatedNativeBuildInputs` {#var-stdenv-propagatedNativeBuildInputs}
+
+The propagated equivalent of `nativeBuildInputs`. This would be called `depsBuildHostPropagated` but for historical continuity. For example, if package `Y` has `propagatedNativeBuildInputs = [X]`, and package `Z` has `buildInputs = [Y]`, then package `Z` will be built as if it included package `X` in its `nativeBuildInputs`. If instead, package `Z` has `nativeBuildInputs = [Y]`, then `Z` will be built as if it included `X` in the `depsBuildBuild` of package `Z`, because of the sum of the two `-1` host offsets.
+
+#### `depsBuildTargetPropagated` {#var-stdenv-depsBuildTargetPropagated}
+
+The propagated equivalent of `depsBuildTarget`. This is prefixed for the same reason of alerting potential users.
+
+#### `depsHostHostPropagated` {#var-stdenv-depsHostHostPropagated}
+
+The propagated equivalent of `depsHostHost`.
+
+#### `propagatedBuildInputs` {#var-stdenv-propagatedBuildInputs}
+
+The propagated equivalent of `buildInputs`. This would be called `depsHostTargetPropagated` but for historical continuity.
+
+#### `depsTargetTargetPropagated` {#var-stdenv-depsTargetTargetPropagated}
+
+The propagated equivalent of `depsTargetTarget`. This is prefixed for the same reason of alerting potential users.
+
+## Attributes {#ssec-stdenv-attributes}
+
+### Variables affecting `stdenv` initialisation
+
+#### `NIX_DEBUG` {#var-stdenv-NIX_DEBUG}
+
+A natural number indicating how much information to log. If set to 1 or higher, `stdenv` will print moderate debugging information during the build. In particular, the `gcc` and `ld` wrapper scripts will print out the complete command line passed to the wrapped tools. If set to 6 or higher, the `stdenv` setup script will be run with `set -x` tracing. If set to 7 or higher, the `gcc` and `ld` wrapper scripts will also be run with `set -x` tracing.
+
+### Attributes affecting build properties
+
+#### `enableParallelBuilding` {#var-stdenv-enableParallelBuilding}
+
+If set to `true`, `stdenv` will pass specific flags to `make` and other build tools to enable parallel building with up to `build-cores` workers.
+
+Unless set to `false`, some build systems with good support for parallel building including `cmake`, `meson`, and `qmake` will set it to `true`.
+
+### Special variables
+
+#### `passthru` {#var-stdenv-passthru}
+
+This is an attribute set which can be filled with arbitrary values. For example:
+
+```nix
+passthru = {
+  foo = "bar";
+  baz = {
+    value1 = 4;
+    value2 = 5;
+  };
+}
+```
+
+Values inside it are not passed to the builder, so you can change them without triggering a rebuild. However, they can be accessed outside of a derivation directly, as if they were set inside a derivation itself, e.g. `hello.baz.value1`. We don’t specify any usage or schema of `passthru` - it is meant for values that would be useful outside the derivation in other parts of a Nix expression (e.g. in other derivations). An example would be to convey some specific dependency of your derivation which contains a program with plugins support. Later, others who make derivations with plugins can use passed-through dependency to ensure that their plugin would be binary-compatible with built program.
+
+#### `passthru.updateScript` {#var-passthru-updateScript}
+
+A script to be run by `maintainers/scripts/update.nix` when the package is matched. It needs to be an executable file, either on the file system:
+
+```nix
+passthru.updateScript = ./update.sh;
+```
+
+or inside the expression itself:
+
+```nix
+passthru.updateScript = writeScript "update-zoom-us" ''
+  #!/usr/bin/env nix-shell
+  #!nix-shell -i bash -p curl pcre common-updater-scripts
+
+  set -eu -o pipefail
+
+  version="$(curl -sI https://zoom.us/client/latest/zoom_x86_64.tar.xz | grep -Fi 'Location:' | pcregrep -o1 '/(([0-9]\.?)+)/')"
+  update-source-version zoom-us "$version"
+'';
+```
+
+The attribute can also contain a list, a script followed by arguments to be passed to it:
+
+```nix
+passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ];
+```
+
+The script will be run with `UPDATE_NIX_ATTR_PATH` environment variable set to the attribute path it is supposed to update.
+
+::: note
+The script will be usually run from the root of the Nixpkgs repository but you should not rely on that. Also note that the update scripts will be run in parallel by default; you should avoid running `git commit` or any other commands that cannot handle that.
+:::
+
+For information about how to run the updates, execute `nix-shell maintainers/scripts/update.nix`.
+
+## Phases {#sec-stdenv-phases}
+
+The generic builder has a number of *phases*. Package builds are split into phases to make it easier to override specific parts of the build (e.g., unpacking the sources or installing the binaries). Furthermore, it allows a nicer presentation of build logs in the Nix build farm.
+
+Each phase can be overridden in its entirety either by setting the environment variable `namePhase` to a string containing some shell commands to be executed, or by redefining the shell function `namePhase`. The former is convenient to override a phase from the derivation, while the latter is convenient from a build script. However, typically one only wants to *add* some commands to a phase, e.g. by defining `postInstall` or `preFixup`, as skipping some of the default actions may have unexpected consequences. The default script for each phase is defined in the file `pkgs/stdenv/generic/setup.sh`.
+
+### Controlling phases {#ssec-controlling-phases}
+
+There are a number of variables that control what phases are executed and in what order:
+
+#### Variables affecting phase control
+
+##### `phases` {#var-stdenv-phases}
+
+Specifies the phases. You can change the order in which phases are executed, or add new phases, by setting this variable. If it’s not set, the default value is used, which is `$prePhases unpackPhase patchPhase $preConfigurePhases configurePhase $preBuildPhases buildPhase checkPhase $preInstallPhases installPhase fixupPhase installCheckPhase $preDistPhases distPhase $postPhases`.
+
+Usually, if you just want to add a few phases, it’s more convenient to set one of the variables below (such as `preInstallPhases`), as you then don’t specify all the normal phases.
+
+##### `prePhases` {#var-stdenv-prePhases}
+
+Additional phases executed before any of the default phases.
+
+##### `preConfigurePhases` {#var-stdenv-preConfigurePhases}
+
+Additional phases executed just before the configure phase.
+
+##### `preBuildPhases` {#var-stdenv-preBuildPhases}
+
+Additional phases executed just before the build phase.
+
+##### `preInstallPhases` {#var-stdenv-preInstallPhases}
+
+Additional phases executed just before the install phase.
+
+##### `preFixupPhases` {#var-stdenv-preFixupPhases}
+
+Additional phases executed just before the fixup phase.
+
+##### `preDistPhases` {#var-stdenv-preDistPhases}
+
+Additional phases executed just before the distribution phase.
+
+##### `postPhases` {#var-stdenv-postPhases}
+
+Additional phases executed after any of the default phases.
+
+### The unpack phase {#ssec-unpack-phase}
+
+The unpack phase is responsible for unpacking the source code of the package. The default implementation of `unpackPhase` unpacks the source files listed in the `src` environment variable to the current directory. It supports the following files by default:
+
+#### Tar files
+
+These can optionally be compressed using `gzip` (`.tar.gz`, `.tgz` or `.tar.Z`), `bzip2` (`.tar.bz2`, `.tbz2` or `.tbz`) or `xz` (`.tar.xz`, `.tar.lzma` or `.txz`).
+
+#### Zip files
+
+Zip files are unpacked using `unzip`. However, `unzip` is not in the standard environment, so you should add it to `nativeBuildInputs` yourself.
+
+#### Directories in the Nix store
+
+These are simply copied to the current directory. The hash part of the file name is stripped, e.g. `/nix/store/1wydxgby13cz...-my-sources` would be copied to `my-sources`.
+
+Additional file types can be supported by setting the `unpackCmd` variable (see below).
+
+#### Variables controlling the unpack phase
+##### `srcs` / `src` {#var-stdenv-src}
+
+The list of source files or directories to be unpacked or copied. One of these must be set.
+
+##### `sourceRoot` {#var-stdenv-sourceRoot}
+
+After running `unpackPhase`, the generic builder changes the current directory to the directory created by unpacking the sources. If there are multiple source directories, you should set `sourceRoot` to the name of the intended directory.
+
+##### `setSourceRoot` {#var-stdenv-setSourceRoot}
+
+Alternatively to setting `sourceRoot`, you can set `setSourceRoot` to a shell command to be evaluated by the unpack phase after the sources have been unpacked. This command must set `sourceRoot`.
+
+##### `preUnpack` {#var-stdenv-preUnpack}
+
+Hook executed at the start of the unpack phase.
+
+##### `postUnpack` {#var-stdenv-postUnpack}
+
+Hook executed at the end of the unpack phase.
+
+##### `dontUnpack` {#var-stdenv-dontUnpack}
+
+Set to true to skip the unpack phase.
+
+##### `dontMakeSourcesWritable` {#var-stdenv-dontMakeSourcesWritable}
+
+If set to `1`, the unpacked sources are *not* made writable. By default, they are made writable to prevent problems with read-only sources. For example, copied store directories would be read-only without this.
+
+##### `unpackCmd` {#var-stdenv-unpackCmd}
+
+The unpack phase evaluates the string `$unpackCmd` for any unrecognised file. The path to the current source file is contained in the `curSrc` variable.
+
+### The patch phase {#ssec-patch-phase}
+
+The patch phase applies the list of patches defined in the `patches` variable.
+
+#### Variables controlling the patch phase
+
+##### `dontPatch` {#var-stdenv-dontPatch}
+
+Set to true to skip the patch phase.
+
+##### `patches` {#var-stdenv-patches}
+
+The list of patches. They must be in the format accepted by the `patch` command, and may optionally be compressed using `gzip` (`.gz`), `bzip2` (`.bz2`) or `xz` (`.xz`).
+
+##### `patchFlags` {#var-stdenv-patchFlags}
+
+Flags to be passed to `patch`. If not set, the argument `-p1` is used, which causes the leading directory component to be stripped from the file names in each patch.
+
+##### `prePatch` {#var-stdenv-prePatch}
+
+Hook executed at the start of the patch phase.
+
+##### `postPatch` {#var-stdenv-postPatch}
+
+Hook executed at the end of the patch phase.
+
+### The configure phase {#ssec-configure-phase}
+
+The configure phase prepares the source tree for building. The default `configurePhase` runs `./configure` (typically an Autoconf-generated script) if it exists.
+
+#### Variables controlling the configure phase
+
+##### `configureScript` {#var-stdenv-configureScript}
+
+The name of the configure script. It defaults to `./configure` if it exists; otherwise, the configure phase is skipped. This can actually be a command (like `perl ./Configure.pl`).
+
+##### `configureFlags` {#var-stdenv-configureFlags}
+
+A list of strings passed as additional arguments to the configure script.
+
+##### `dontConfigure` {#var-stdenv-dontConfigure}
+
+Set to true to skip the configure phase.
+
+##### `configureFlagsArray` {#var-stdenv-configureFlagsArray}
+
+A shell array containing additional arguments passed to the configure script. You must use this instead of `configureFlags` if the arguments contain spaces.
+
+##### `dontAddPrefix` {#var-stdenv-dontAddPrefix}
+
+By default, the flag `--prefix=$prefix` is added to the configure flags. If this is undesirable, set this variable to true.
+
+##### `prefix` {#var-stdenv-prefix}
+
+The prefix under which the package must be installed, passed via the `--prefix` option to the configure script. It defaults to `$out`.
+
+##### `prefixKey` {#var-stdenv-prefixKey}
+
+The key to use when specifying the prefix. By default, this is set to `--prefix=` as that is used by the majority of packages.
+
+##### `dontAddDisableDepTrack` {#var-stdenv-dontAddDisableDepTrack}
+
+By default, the flag `--disable-dependency-tracking` is added to the configure flags to speed up Automake-based builds. If this is undesirable, set this variable to true.
+
+##### `dontFixLibtool` {#var-stdenv-dontFixLibtool}
+
+By default, the configure phase applies some special hackery to all files called `ltmain.sh` before running the configure script in order to improve the purity of Libtool-based packages [^footnote-stdenv-sys-lib-search-path] . If this is undesirable, set this variable to true.
+
+##### `dontDisableStatic` {#var-stdenv-dontDisableStatic}
+
+By default, when the configure script has `--enable-static`, the option `--disable-static` is added to the configure flags.
+
+If this is undesirable, set this variable to true.
+
+##### `configurePlatforms` {#var-stdenv-configurePlatforms}
+
+By default, when cross compiling, the configure script has `--build=...` and `--host=...` passed. Packages can instead pass `[ "build" "host" "target" ]` or a subset to control exactly which platform flags are passed. Compilers and other tools can use this to also pass the target platform. [^footnote-stdenv-build-time-guessing-impurity]
+
+##### `preConfigure` {#var-stdenv-preConfigure}
+
+Hook executed at the start of the configure phase.
+
+##### `postConfigure` {#var-stdenv-postConfigure}
+
+Hook executed at the end of the configure phase.
+
+### The build phase {#build-phase}
+
+The build phase is responsible for actually building the package (e.g. compiling it). The default `buildPhase` simply calls `make` if a file named `Makefile`, `makefile` or `GNUmakefile` exists in the current directory (or the `makefile` is explicitly set); otherwise it does nothing.
+
+#### Variables controlling the build phase
+
+##### `dontBuild` {#var-stdenv-dontBuild}
+
+Set to true to skip the build phase.
+
+##### `makefile` {#var-stdenv-makefile}
+
+The file name of the Makefile.
+
+##### `makeFlags` {#var-stdenv-makeFlags}
+
+A list of strings passed as additional flags to `make`. These flags are also used by the default install and check phase. For setting make flags specific to the build phase, use `buildFlags` (see below).
+
+```nix
+makeFlags = [ "PREFIX=$(out)" ];
+```
+
+::: note
+The flags are quoted in bash, but environment variables can be specified by using the make syntax.
+:::
+
+##### `makeFlagsArray` {#var-stdenv-makeFlagsArray}
+
+A shell array containing additional arguments passed to `make`. You must use this instead of `makeFlags` if the arguments contain spaces, e.g.
+
+```nix
+preBuild = ''
+  makeFlagsArray+=(CFLAGS="-O0 -g" LDFLAGS="-lfoo -lbar")
+'';
+```
+
+Note that shell arrays cannot be passed through environment variables, so you cannot set `makeFlagsArray` in a derivation attribute (because those are passed through environment variables): you have to define them in shell code.
+
+##### `buildFlags` / `buildFlagsArray` {#var-stdenv-buildFlags}
+
+A list of strings passed as additional flags to `make`. Like `makeFlags` and `makeFlagsArray`, but only used by the build phase.
+
+##### `preBuild` {#var-stdenv-preBuild}
+
+Hook executed at the start of the build phase.
+
+##### `postBuild` {#var-stdenv-postBuild}
+
+Hook executed at the end of the build phase.
+
+You can set flags for `make` through the `makeFlags` variable.
+
+Before and after running `make`, the hooks `preBuild` and `postBuild` are called, respectively.
+
+### The check phase {#ssec-check-phase}
+
+The check phase checks whether the package was built correctly by running its test suite. The default `checkPhase` calls `make check`, but only if the `doCheck` variable is enabled.
+
+#### Variables controlling the check phase
+
+##### `doCheck` {#var-stdenv-doCheck}
+
+Controls whether the check phase is executed. By default it is skipped, but if `doCheck` is set to true, the check phase is usually executed. Thus you should set
+
+```nix
+doCheck = true;
+```
+
+in the derivation to enable checks. The exception is cross compilation. Cross compiled builds never run tests, no matter how `doCheck` is set, as the newly-built program won’t run on the platform used to build it.
+
+##### `makeFlags` / `makeFlagsArray` / `makefile`
+
+See the [build phase](#var-stdenv-makeFlags) for details.
+
+##### `checkTarget` {#var-stdenv-checkTarget}
+
+The make target that runs the tests. Defaults to `check`.
+
+##### `checkFlags` / `checkFlagsArray` {#var-stdenv-checkFlags}
+
+A list of strings passed as additional flags to `make`. Like `makeFlags` and `makeFlagsArray`, but only used by the check phase.
+
+##### `checkInputs` {#var-stdenv-checkInputs}
+
+A list of dependencies used by the phase. This gets included in `nativeBuildInputs` when `doCheck` is set.
+
+##### `preCheck` {#var-stdenv-preCheck}
+
+Hook executed at the start of the check phase.
+
+##### `postCheck` {#var-stdenv-postCheck}
+
+Hook executed at the end of the check phase.
+
+### The install phase {#ssec-install-phase}
+
+The install phase is responsible for installing the package in the Nix store under `out`. The default `installPhase` creates the directory `$out` and calls `make install`.
+
+#### Variables controlling the install phase
+
+##### `dontInstall` {#var-stdenv-dontInstall}
+
+Set to true to skip the install phase.
+
+##### `makeFlags` / `makeFlagsArray` / `makefile`
+
+See the [build phase](#var-stdenv-makeFlags) for details.
+
+##### `installTargets` {#var-stdenv-installTargets}
+
+The make targets that perform the installation. Defaults to `install`. Example:
+
+```nix
+installTargets = "install-bin install-doc";
+```
+
+##### `installFlags` / `installFlagsArray` {#var-stdenv-installFlags}
+
+A list of strings passed as additional flags to `make`. Like `makeFlags` and `makeFlagsArray`, but only used by the install phase.
+
+##### `preInstall` {#var-stdenv-preInstall}
+
+Hook executed at the start of the install phase.
+
+##### `postInstall` {#var-stdenv-postInstall}
+
+Hook executed at the end of the install phase.
+
+### The fixup phase {#ssec-fixup-phase}
+
+The fixup phase performs some (Nix-specific) post-processing actions on the files installed under `$out` by the install phase. The default `fixupPhase` does the following:
+
+- It moves the `man/`, `doc/` and `info/` subdirectories of `$out` to `share/`.
+- It strips libraries and executables of debug information.
+- On Linux, it applies the `patchelf` command to ELF executables and libraries to remove unused directories from the `RPATH` in order to prevent unnecessary runtime dependencies.
+- It rewrites the interpreter paths of shell scripts to paths found in `PATH`. E.g., `/usr/bin/perl` will be rewritten to `/nix/store/some-perl/bin/perl` found in `PATH`.
+
+#### Variables controlling the fixup phase
+
+##### `dontFixup` {#var-stdenv-dontFixup}
+
+Set to true to skip the fixup phase.
+
+##### `dontStrip` {#var-stdenv-dontStrip}
+
+If set, libraries and executables are not stripped. By default, they are.
+
+##### `dontStripHost` {#var-stdenv-dontStripHost}
+
+Like `dontStrip`, but only affects the `strip` command targetting the package’s host platform. Useful when supporting cross compilation, but otherwise feel free to ignore.
+
+##### `dontStripTarget` {#var-stdenv-dontStripTarget}
+
+Like `dontStrip`, but only affects the `strip` command targetting the packages’ target platform. Useful when supporting cross compilation, but otherwise feel free to ignore.
+
+##### `dontMoveSbin` {#var-stdenv-dontMoveSbin}
+
+If set, files in `$out/sbin` are not moved to `$out/bin`. By default, they are.
+
+##### `stripAllList` {#var-stdenv-stripAllList}
+
+List of directories to search for libraries and executables from which *all* symbols should be stripped. By default, it’s empty. Stripping all symbols is risky, since it may remove not just debug symbols but also ELF information necessary for normal execution.
+
+##### `stripAllFlags` {#var-stdenv-stripAllFlags}
+
+Flags passed to the `strip` command applied to the files in the directories listed in `stripAllList`. Defaults to `-s` (i.e. `--strip-all`).
+
+##### `stripDebugList` {#var-stdenv-stripDebugList}
+
+List of directories to search for libraries and executables from which only debugging-related symbols should be stripped. It defaults to `lib lib32 lib64 libexec bin sbin`.
+
+##### `stripDebugFlags` {#var-stdenv-stripDebugFlags}
+
+Flags passed to the `strip` command applied to the files in the directories listed in `stripDebugList`. Defaults to `-S` (i.e. `--strip-debug`).
+
+##### `dontPatchELF` {#var-stdenv-dontPatchELF}
+
+If set, the `patchelf` command is not used to remove unnecessary `RPATH` entries. Only applies to Linux.
+
+##### `dontPatchShebangs` {#var-stdenv-dontPatchShebangs}
+
+If set, scripts starting with `#!` do not have their interpreter paths rewritten to paths in the Nix store.
+
+##### `dontPruneLibtoolFiles` {#var-stdenv-dontPruneLibtoolFiles}
+
+If set, libtool `.la` files associated with shared libraries won’t have their `dependency_libs` field cleared.
+
+##### `forceShare` {#var-stdenv-forceShare}
+
+The list of directories that must be moved from `$out` to `$out/share`. Defaults to `man doc info`.
+
+##### `setupHook` {#var-stdenv-setupHook}
+
+A package can export a [setup hook](#ssec-setup-hooks) by setting this variable. The setup hook, if defined, is copied to `$out/nix-support/setup-hook`. Environment variables are then substituted in it using `substituteAll`.
+
+##### `preFixup` {#var-stdenv-preFixup}
+
+Hook executed at the start of the fixup phase.
+
+##### `postFixup` {#var-stdenv-postFixup}
+
+Hook executed at the end of the fixup phase.
+
+##### `separateDebugInfo` {#stdenv-separateDebugInfo}
+
+If set to `true`, the standard environment will enable debug information in C/C++ builds. After installation, the debug information will be separated from the executables and stored in the output named `debug`. (This output is enabled automatically; you don’t need to set the `outputs` attribute explicitly.) To be precise, the debug information is stored in `debug/lib/debug/.build-id/XX/YYYY…`, where \<XXYYYY…\> is the \<build ID\> of the binary — a SHA-1 hash of the contents of the binary. Debuggers like GDB use the build ID to look up the separated debug information.
+
+For example, with GDB, you can add
+
+```
+set debug-file-directory ~/.nix-profile/lib/debug
+```
+
+to `~/.gdbinit`. GDB will then be able to find debug information installed via `nix-env -i`.
+
+### The installCheck phase {#ssec-installCheck-phase}
+
+The installCheck phase checks whether the package was installed correctly by running its test suite against the installed directories. The default `installCheck` calls `make installcheck`.
+
+#### Variables controlling the installCheck phase
+
+##### `doInstallCheck` {#var-stdenv-doInstallCheck}
+
+Controls whether the installCheck phase is executed. By default it is skipped, but if `doInstallCheck` is set to true, the installCheck phase is usually executed. Thus you should set
+
+```nix
+doInstallCheck = true;
+```
+
+in the derivation to enable install checks. The exception is cross compilation. Cross compiled builds never run tests, no matter how `doInstallCheck` is set, as the newly-built program won’t run on the platform used to build it.
+
+##### `installCheckTarget` {#var-stdenv-installCheckTarget}
+
+The make target that runs the install tests. Defaults to `installcheck`.
+
+##### `installCheckFlags` / `installCheckFlagsArray` {#var-stdenv-installCheckFlags}
+
+A list of strings passed as additional flags to `make`. Like `makeFlags` and `makeFlagsArray`, but only used by the installCheck phase.
+
+##### `installCheckInputs` {#var-stdenv-installCheckInputs}
+
+A list of dependencies used by the phase. This gets included in `nativeBuildInputs` when `doInstallCheck` is set.
+
+##### `preInstallCheck` {#var-stdenv-preInstallCheck}
+
+Hook executed at the start of the installCheck phase.
+
+##### `postInstallCheck` {#var-stdenv-postInstallCheck}
+
+Hook executed at the end of the installCheck phase.
+
+### The distribution phase {#ssec-distribution-phase}
+
+The distribution phase is intended to produce a source distribution of the package. The default `distPhase` first calls `make dist`, then it copies the resulting source tarballs to `$out/tarballs/`. This phase is only executed if the attribute `doDist` is set.
+
+#### Variables controlling the distribution phase
+
+##### `distTarget` {#var-stdenv-distTarget}
+
+The make target that produces the distribution. Defaults to `dist`.
+
+##### `distFlags` / `distFlagsArray` {#var-stdenv-distFlags}
+
+Additional flags passed to `make`.
+
+##### `tarballs` {#var-stdenv-tarballs}
+
+The names of the source distribution files to be copied to `$out/tarballs/`. It can contain shell wildcards. The default is `*.tar.gz`.
+
+##### `dontCopyDist` {#var-stdenv-dontCopyDist}
+
+If set, no files are copied to `$out/tarballs/`.
+
+##### `preDist` {#var-stdenv-preDist}
+
+Hook executed at the start of the distribution phase.
+
+##### `postDist` {#var-stdenv-postDist}
+
+Hook executed at the end of the distribution phase.
+
+## Shell functions {#ssec-stdenv-functions}
+
+The standard environment provides a number of useful functions.
+
+### `makeWrapper` \<executable\> \<wrapperfile\> \<args\> {#fun-makeWrapper}
+
+Constructs a wrapper for a program with various possible arguments. For example:
+
+```bash
+# adds `FOOBAR=baz` to `$out/bin/foo`’s environment
+makeWrapper $out/bin/foo $wrapperfile --set FOOBAR baz
+
+# prefixes the binary paths of `hello` and `git`
+# Be advised that paths often should be patched in directly
+# (via string replacements or in `configurePhase`).
+makeWrapper $out/bin/foo $wrapperfile --prefix PATH : ${lib.makeBinPath [ hello git ]}
+```
+
+There’s many more kinds of arguments, they are documented in `nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh`.
+
+`wrapProgram` is a convenience function you probably want to use most of the time.
+
+### `substitute` \<infile\> \<outfile\> \<subs\> {#fun-substitute}
+
+Performs string substitution on the contents of \<infile\>, writing the result to \<outfile\>. The substitutions in \<subs\> are of the following form:
+
+#### `--replace` \<s1\> \<s2\>
+
+Replace every occurrence of the string \<s1\> by \<s2\>.
+
+#### `--subst-var` \<varName\>
+
+Replace every occurrence of `@varName@` by the contents of the environment variable \<varName\>. This is useful for generating files from templates, using `@...@` in the template as placeholders.
+
+#### `--subst-var-by` \<varName\> \<s\>
+
+Replace every occurrence of `@varName@` by the string \<s\>.
+
+Example:
+
+```shell
+substitute ./foo.in ./foo.out \
+    --replace /usr/bin/bar $bar/bin/bar \
+    --replace "a string containing spaces" "some other text" \
+    --subst-var someVar
+```
+
+### `substituteInPlace` \<file\> \<subs\> {#fun-substituteInPlace}
+
+Like `substitute`, but performs the substitutions in place on the file \<file\>.
+
+### `substituteAll` \<infile\> \<outfile\> {#fun-substituteAll}
+
+Replaces every occurrence of `@varName@`, where \<varName\> is any environment variable, in \<infile\>, writing the result to \<outfile\>. For instance, if \<infile\> has the contents
+
+```bash
+#! @bash@/bin/sh
+PATH=@coreutils@/bin
+echo @foo@
+```
+
+and the environment contains `bash=/nix/store/bmwp0q28cf21...-bash-3.2-p39` and `coreutils=/nix/store/68afga4khv0w...-coreutils-6.12`, but does not contain the variable `foo`, then the output will be
+
+```bash
+#! /nix/store/bmwp0q28cf21...-bash-3.2-p39/bin/sh
+PATH=/nix/store/68afga4khv0w...-coreutils-6.12/bin
+echo @foo@
+```
+
+That is, no substitution is performed for undefined variables.
+
+Environment variables that start with an uppercase letter or an underscore are filtered out, to prevent global variables (like `HOME`) or private variables (like `__ETC_PROFILE_DONE`) from accidentally getting substituted. The variables also have to be valid bash "names", as defined in the bash manpage (alphanumeric or `_`, must not start with a number).
+
+### `substituteAllInPlace` \<file\> {#fun-substituteAllInPlace}
+
+Like `substituteAll`, but performs the substitutions in place on the file \<file\>.
+
+### `stripHash` \<path\> {#fun-stripHash}
+
+Strips the directory and hash part of a store path, outputting the name part to `stdout`. For example:
+
+```bash
+# prints coreutils-8.24
+stripHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
+```
+
+If you wish to store the result in another variable, then the following idiom may be useful:
+
+```bash
+name="/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
+someVar=$(stripHash $name)
+```
+
+### `wrapProgram` \<executable\> \<makeWrapperArgs\> {#fun-wrapProgram}
+
+Convenience function for `makeWrapper` that automatically creates a sane wrapper file. It takes all the same arguments as `makeWrapper`, except for `--argv0`.
+
+It cannot be applied multiple times, since it will overwrite the wrapper file.
+
+## Package setup hooks {#ssec-setup-hooks}
+
+Nix itself considers a build-time dependency as merely something that should previously be built and accessible at build time—packages themselves are on their own to perform any additional setup. In most cases, that is fine, and the downstream derivation can deal with its own dependencies. But for a few common tasks, that would result in almost every package doing the same sort of setup work—depending not on the package itself, but entirely on which dependencies were used.
+
+In order to alleviate this burden, the setup hook mechanism was written, where any package can include a shell script that \[by convention rather than enforcement by Nix\], any downstream reverse-dependency will source as part of its build process. That allows the downstream dependency to merely specify its dependencies, and lets those dependencies effectively initialize themselves. No boilerplate mirroring the list of dependencies is needed.
+
+The setup hook mechanism is a bit of a sledgehammer though: a powerful feature with a broad and indiscriminate area of effect. The combination of its power and implicit use may be expedient, but isn’t without costs. Nix itself is unchanged, but the spirit of added dependencies being effect-free is violated even if the letter isn’t. For example, if a derivation path is mentioned more than once, Nix itself doesn’t care and simply makes sure the dependency derivation is already built just the same—depending is just needing something to exist, and needing is idempotent. However, a dependency specified twice will have its setup hook run twice, and that could easily change the build environment (though a well-written setup hook will therefore strive to be idempotent so this is in fact not observable). More broadly, setup hooks are anti-modular in that multiple dependencies, whether the same or different, should not interfere and yet their setup hooks may well do so.
+
+The most typical use of the setup hook is actually to add other hooks which are then run (i.e. after all the setup hooks) on each dependency. For example, the C compiler wrapper’s setup hook feeds itself flags for each dependency that contains relevant libraries and headers. This is done by defining a bash function, and appending its name to one of `envBuildBuildHooks`, `envBuildHostHooks`, `envBuildTargetHooks`, `envHostHostHooks`, `envHostTargetHooks`, or `envTargetTargetHooks`. These 6 bash variables correspond to the 6 sorts of dependencies by platform (there’s 12 total but we ignore the propagated/non-propagated axis).
+
+Packages adding a hook should not hard code a specific hook, but rather choose a variable *relative* to how they are included. Returning to the C compiler wrapper example, if the wrapper itself is an `n` dependency, then it only wants to accumulate flags from `n + 1` dependencies, as only those ones match the compiler’s target platform. The `hostOffset` variable is defined with the current dependency’s host offset `targetOffset` with its target offset, before its setup hook is sourced. Additionally, since most environment hooks don’t care about the target platform, that means the setup hook can append to the right bash array by doing something like
+
+```{.bash}
+addEnvHooks "$hostOffset" myBashFunction
+```
+
+The *existence* of setups hooks has long been documented and packages inside Nixpkgs are free to use this mechanism. Other packages, however, should not rely on these mechanisms not changing between Nixpkgs versions. Because of the existing issues with this system, there’s little benefit from mandating it be stable for any period of time.
+
+First, let’s cover some setup hooks that are part of Nixpkgs default stdenv. This means that they are run for every package built using `stdenv.mkDerivation`. Some of these are platform specific, so they may run on Linux but not Darwin or vice-versa.
+
+### `move-docs.sh`
+
+This setup hook moves any installed documentation to the `/share` subdirectory directory. This includes the man, doc and info directories. This is needed for legacy programs that do not know how to use the `share` subdirectory.
+
+### `compress-man-pages.sh`
+
+This setup hook compresses any man pages that have been installed. The compression is done using the gzip program. This helps to reduce the installed size of packages.
+
+### `strip.sh`
+
+This runs the strip command on installed binaries and libraries. This removes unnecessary information like debug symbols when they are not needed. This also helps to reduce the installed size of packages.
+
+### `patch-shebangs.sh`
+
+This setup hook patches installed scripts to use the full path to the shebang interpreter. A shebang interpreter is the first commented line of a script telling the operating system which program will run the script (e.g `#!/bin/bash`). In Nix, we want an exact path to that interpreter to be used. This often replaces `/bin/sh` with a path in the Nix store.
+
+### `audit-tmpdir.sh`
+
+This verifies that no references are left from the install binaries to the directory used to build those binaries. This ensures that the binaries do not need things outside the Nix store. This is currently supported in Linux only.
+
+### `multiple-outputs.sh`
+
+This setup hook adds configure flags that tell packages to install files into any one of the proper outputs listed in `outputs`. This behavior can be turned off by setting `setOutputFlags` to false in the derivation environment. See <xref linkend="chap-multiple-output" /> for more information.
+
+### `move-sbin.sh`
+
+This setup hook moves any binaries installed in the `sbin/` subdirectory into `bin/`. In addition, a link is provided from `sbin/` to `bin/` for compatibility.
+
+### `move-lib64.sh`
+
+This setup hook moves any libraries installed in the `lib64/` subdirectory into `lib/`. In addition, a link is provided from `lib64/` to `lib/` for compatibility.
+
+### `move-systemd-user-units.sh`
+
+This setup hook moves any systemd user units installed in the `lib/` subdirectory into `share/`. In addition, a link is provided from `share/` to `lib/` for compatibility. This is needed for systemd to find user services when installed into the user profile.
+
+### `set-source-date-epoch-to-latest.sh`
+
+This sets `SOURCE_DATE_EPOCH` to the modification time of the most recent file.
+
+### Bintools Wrapper
+
+The Bintools Wrapper wraps the binary utilities for a bunch of miscellaneous purposes. These are GNU Binutils when targetting Linux, and a mix of cctools and GNU binutils for Darwin. \[The “Bintools” name is supposed to be a compromise between “Binutils” and “cctools” not denoting any specific implementation.\] Specifically, the underlying bintools package, and a C standard library (glibc or Darwin’s libSystem, just for the dynamic loader) are all fed in, and dependency finding, hardening (see below), and purity checks for each are handled by the Bintools Wrapper. Packages typically depend on CC Wrapper, which in turn (at run time) depends on the Bintools Wrapper.
+
+The Bintools Wrapper was only just recently split off from CC Wrapper, so the division of labor is still being worked out. For example, it shouldn’t care about the C standard library, but just take a derivation with the dynamic loader (which happens to be the glibc on linux). Dependency finding however is a task both wrappers will continue to need to share, and probably the most important to understand. It is currently accomplished by collecting directories of host-platform dependencies (i.e. `buildInputs` and `nativeBuildInputs`) in environment variables. The Bintools Wrapper’s setup hook causes any `lib` and `lib64` subdirectories to be added to `NIX_LDFLAGS`. Since the CC Wrapper and the Bintools Wrapper use the same strategy, most of the Bintools Wrapper code is sparsely commented and refers to the CC Wrapper. But the CC Wrapper’s code, by contrast, has quite lengthy comments. The Bintools Wrapper merely cites those, rather than repeating them, to avoid falling out of sync.
+
+A final task of the setup hook is defining a number of standard environment variables to tell build systems which executables fulfill which purpose. They are defined to just be the base name of the tools, under the assumption that the Bintools Wrapper’s binaries will be on the path. Firstly, this helps poorly-written packages, e.g. ones that look for just `gcc` when `CC` isn’t defined yet `clang` is to be used. Secondly, this helps packages not get confused when cross-compiling, in which case multiple Bintools Wrappers may simultaneously be in use. [^footnote-stdenv-per-platform-wrapper] `BUILD_`- and `TARGET_`-prefixed versions of the normal environment variable are defined for additional Bintools Wrappers, properly disambiguating them.
+
+A problem with this final task is that the Bintools Wrapper is honest and defines `LD` as `ld`. Most packages, however, firstly use the C compiler for linking, secondly use `LD` anyways, defining it as the C compiler, and thirdly, only so define `LD` when it is undefined as a fallback. This triple-threat means Bintools Wrapper will break those packages, as LD is already defined as the actual linker which the package won’t override yet doesn’t want to use. The workaround is to define, just for the problematic package, `LD` as the C compiler. A good way to do this would be `preConfigure = "LD=$CC"`.
+
+### CC Wrapper
+
+The CC Wrapper wraps a C toolchain for a bunch of miscellaneous purposes. Specifically, a C compiler (GCC or Clang), wrapped binary tools, and a C standard library (glibc or Darwin’s libSystem, just for the dynamic loader) are all fed in, and dependency finding, hardening (see below), and purity checks for each are handled by the CC Wrapper. Packages typically depend on the CC Wrapper, which in turn (at run-time) depends on the Bintools Wrapper.
+
+Dependency finding is undoubtedly the main task of the CC Wrapper. This works just like the Bintools Wrapper, except that any `include` subdirectory of any relevant dependency is added to `NIX_CFLAGS_COMPILE`. The setup hook itself contains some lengthy comments describing the exact convoluted mechanism by which this is accomplished.
+
+Similarly, the CC Wrapper follows the Bintools Wrapper in defining standard environment variables with the names of the tools it wraps, for the same reasons described above. Importantly, while it includes a `cc` symlink to the c compiler for portability, the `CC` will be defined using the compiler’s “real name” (i.e. `gcc` or `clang`). This helps lousy build systems that inspect on the name of the compiler rather than run it.
+
+Here are some more packages that provide a setup hook. Since the list of hooks is extensible, this is not an exhaustive list. The mechanism is only to be used as a last resort, so it might cover most uses.
+
+### Perl {#setup-hook-perl}
+
+Adds the `lib/site_perl` subdirectory of each build input to the `PERL5LIB` environment variable. For instance, if `buildInputs` contains Perl, then the `lib/site_perl` subdirectory of each input is added to the `PERL5LIB` environment variable.
+
+### Python {#setup-hook-python}
+
+Adds the `lib/${python.libPrefix}/site-packages` subdirectory of each build input to the `PYTHONPATH` environment variable.
+
+### pkg-config {#setup-hook-pkg-config}
+
+Adds the `lib/pkgconfig` and `share/pkgconfig` subdirectories of each build input to the `PKG_CONFIG_PATH` environment variable.
+
+### Automake {#setup-hook-automake}
+
+Adds the `share/aclocal` subdirectory of each build input to the `ACLOCAL_PATH` environment variable.
+
+### Autoconf {#setup-hook-autoconf}
+
+The `autoreconfHook` derivation adds `autoreconfPhase`, which runs autoreconf, libtoolize and automake, essentially preparing the configure script in autotools-based builds. Most autotools-based packages come with the configure script pre-generated, but this hook is necessary for a few packages and when you need to patch the package’s configure scripts.
+
+### libxml2 {#setup-hook-libxml2}
+
+Adds every file named `catalog.xml` found under the `xml/dtd` and `xml/xsl` subdirectories of each build input to the `XML_CATALOG_FILES` environment variable.
+
+### teTeX / TeX Live
+
+Adds the `share/texmf-nix` subdirectory of each build input to the `TEXINPUTS` environment variable.
+
+### Qt 4
+
+Sets the `QTDIR` environment variable to Qt’s path.
+
+### gdk-pixbuf {#setup-hook-gdk-pixbuf}
+
+Exports `GDK_PIXBUF_MODULE_FILE` environment variable to the builder. Add librsvg package to `buildInputs` to get svg support. See also the [setup hook description in GNOME platform docs](#ssec-gnome-hooks-gdk-pixbuf).
+
+### GHC
+
+Creates a temporary package database and registers every Haskell build input in it (TODO: how?).
+
+### GNOME platform
+
+Hooks related to GNOME platform and related libraries like GLib, GTK and GStreamer are described in <xref linkend="sec-language-gnome" />.
+
+### autoPatchelfHook {#setup-hook-autopatchelfhook}
+
+This is a special setup hook which helps in packaging proprietary software in that it automatically tries to find missing shared library dependencies of ELF files based on the given `buildInputs` and `nativeBuildInputs`.
+
+You can also specify a `runtimeDependencies` variable which lists dependencies to be unconditionally added to rpath of all executables. This is useful for programs that use dlopen 3 to load libraries at runtime.
+
+In certain situations you may want to run the main command (`autoPatchelf`) of the setup hook on a file or a set of directories instead of unconditionally patching all outputs. This can be done by setting the `dontAutoPatchelf` environment variable to a non-empty value.
+
+By default `autoPatchelf` will fail as soon as any ELF file requires a dependency which cannot be resolved via the given build inputs. In some situations you might prefer to just leave missing dependencies unpatched and continue to patch the rest. This can be achieved by setting the `autoPatchelfIgnoreMissingDeps` environment variable to a non-empty value.
+
+The `autoPatchelf` command also recognizes a `--no-recurse` command line flag, which prevents it from recursing into subdirectories.
+
+### breakpointHook
+
+This hook will make a build pause instead of stopping when a failure happens. It prevents nix from cleaning up the build environment immediately and allows the user to attach to a build environment using the `cntr` command. Upon build error it will print instructions on how to use `cntr`, which can be used to enter the environment for debugging. Installing cntr and running the command will provide shell access to the build sandbox of failed build. At `/var/lib/cntr` the sandboxed filesystem is mounted. All commands and files of the system are still accessible within the shell. To execute commands from the sandbox use the cntr exec subcommand. `cntr` is only supported on Linux-based platforms. To use it first add `cntr` to your `environment.systemPackages` on NixOS or alternatively to the root user on non-NixOS systems. Then in the package that is supposed to be inspected, add `breakpointHook` to `nativeBuildInputs`.
+
+```nix
+nativeBuildInputs = [ breakpointHook ];
+```
+
+When a build failure happens there will be an instruction printed that shows how to attach with `cntr` to the build sandbox.
+
+::: note
+::: title
+Caution with remote builds
+:::
+
+This won’t work with remote builds as the build environment is on a different machine and can’t be accessed by `cntr`. Remote builds can be turned off by setting `--option builders ''` for `nix-build` or `--builders ''` for `nix build`.
+:::
+
+### installShellFiles
+
+This hook helps with installing manpages and shell completion files. It exposes 2 shell functions `installManPage` and `installShellCompletion` that can be used from your `postInstall` hook.
+
+The `installManPage` function takes one or more paths to manpages to install. The manpages must have a section suffix, and may optionally be compressed (with `.gz` suffix). This function will place them into the correct directory.
+
+The `installShellCompletion` function takes one or more paths to shell completion files. By default it will autodetect the shell type from the completion file extension, but you may also specify it by passing one of `--bash`, `--fish`, or `--zsh`. These flags apply to all paths listed after them (up until another shell flag is given). Each path may also have a custom installation name provided by providing a flag `--name NAME` before the path. If this flag is not provided, zsh completions will be renamed automatically such that `foobar.zsh` becomes `_foobar`. A root name may be provided for all paths using the flag `--cmd NAME`; this synthesizes the appropriate name depending on the shell (e.g. `--cmd foo` will synthesize the name `foo.bash` for bash and `_foo` for zsh). The path may also be a fifo or named fd (such as produced by `<(cmd)`), in which case the shell and name must be provided.
+
+```nix
+nativeBuildInputs = [ installShellFiles ];
+postInstall = ''
+  installManPage doc/foobar.1 doc/barfoo.3
+  # explicit behavior
+  installShellCompletion --bash --name foobar.bash share/completions.bash
+  installShellCompletion --fish --name foobar.fish share/completions.fish
+  installShellCompletion --zsh --name _foobar share/completions.zsh
+  # implicit behavior
+  installShellCompletion share/completions/foobar.{bash,fish,zsh}
+  # using named fd
+  installShellCompletion --cmd foobar \
+    --bash <($out/bin/foobar --bash-completion) \
+    --fish <($out/bin/foobar --fish-completion) \
+    --zsh <($out/bin/foobar --zsh-completion)
+'';
+```
+
+### libiconv, libintl
+
+A few libraries automatically add to `NIX_LDFLAGS` their library, making their symbols automatically available to the linker. This includes libiconv and libintl (gettext). This is done to provide compatibility between GNU Linux, where libiconv and libintl are bundled in, and other systems where that might not be the case. Sometimes, this behavior is not desired. To disable this behavior, set `dontAddExtraLibs`.
+
+### validatePkgConfig
+
+The `validatePkgConfig` hook validates all pkg-config (`.pc`) files in a package. This helps catching some common errors in pkg-config files, such as undefined variables.
+
+### cmake
+
+Overrides the default configure phase to run the CMake command. By default, we use the Make generator of CMake. In addition, dependencies are added automatically to CMAKE_PREFIX_PATH so that packages are correctly detected by CMake. Some additional flags are passed in to give similar behavior to configure-based packages. You can disable this hook’s behavior by setting configurePhase to a custom value, or by setting dontUseCmakeConfigure. cmakeFlags controls flags passed only to CMake. By default, parallel building is enabled as CMake supports parallel building almost everywhere. When Ninja is also in use, CMake will detect that and use the ninja generator.
+
+### xcbuildHook
+
+Overrides the build and install phases to run the "xcbuild" command. This hook is needed when a project only comes with build files for the XCode build system. You can disable this behavior by setting buildPhase and configurePhase to a custom value. xcbuildFlags controls flags passed only to xcbuild.
+
+### Meson
+
+Overrides the configure phase to run meson to generate Ninja files. To run these files, you should accompany Meson with ninja. By default, `enableParallelBuilding` is enabled as Meson supports parallel building almost everywhere.
+
+#### Variables controlling Meson
+
+##### `mesonFlags`
+
+Controls the flags passed to meson.
+
+##### `mesonBuildType`
+
+Which [`--buildtype`](https://mesonbuild.com/Builtin-options.html#core-options) to pass to Meson. We default to `plain`.
+
+##### `mesonAutoFeatures`
+
+What value to set [`-Dauto_features=`](https://mesonbuild.com/Builtin-options.html#core-options) to. We default to `enabled`.
+
+##### `mesonWrapMode`
+
+What value to set [`-Dwrap_mode=`](https://mesonbuild.com/Builtin-options.html#core-options) to. We default to `nodownload` as we disallow network access.
+
+##### `dontUseMesonConfigure`
+
+Disables using Meson’s `configurePhase`.
+
+### ninja
+
+Overrides the build, install, and check phase to run ninja instead of make. You can disable this behavior with the `dontUseNinjaBuild`, `dontUseNinjaInstall`, and `dontUseNinjaCheck`, respectively. Parallel building is enabled by default in Ninja.
+
+### unzip
+
+This setup hook will allow you to unzip .zip files specified in `$src`. There are many similar packages like `unrar`, `undmg`, etc.
+
+### wafHook
+
+Overrides the configure, build, and install phases. This will run the “waf” script used by many projects. If `wafPath` (default `./waf`) doesn’t exist, it will copy the version of waf available in Nixpkgs. `wafFlags` can be used to pass flags to the waf script.
+
+### scons
+
+Overrides the build, install, and check phases. This uses the scons build system as a replacement for make. scons does not provide a configure phase, so everything is managed at build and install time.
+
+## Purity in Nixpkgs {#sec-purity-in-nixpkgs}
+
+*Measures taken to prevent dependencies on packages outside the store, and what you can do to prevent them.*
+
+GCC doesn’t search in locations such as `/usr/include`. In fact, attempts to add such directories through the `-I` flag are filtered out. Likewise, the linker (from GNU binutils) doesn’t search in standard locations such as `/usr/lib`. Programs built on Linux are linked against a GNU C Library that likewise doesn’t search in the default system locations.
+
+## Hardening in Nixpkgs {#sec-hardening-in-nixpkgs}
+
+There are flags available to harden packages at compile or link-time. These can be toggled using the `stdenv.mkDerivation` parameters `hardeningDisable` and `hardeningEnable`.
+
+Both parameters take a list of flags as strings. The special `"all"` flag can be passed to `hardeningDisable` to turn off all hardening. These flags can also be used as environment variables for testing or development purposes.
+
+The following flags are enabled by default and might require disabling with `hardeningDisable` if the program to package is incompatible.
+
+### `format`
+
+Adds the `-Wformat -Wformat-security -Werror=format-security` compiler options. At present, this warns about calls to `printf` and `scanf` functions where the format string is not a string literal and there are no format arguments, as in `printf(foo);`. This may be a security hole if the format string came from untrusted input and contains `%n`.
+
+This needs to be turned off or fixed for errors similar to:
+
+```
+/tmp/nix-build-zynaddsubfx-2.5.2.drv-0/zynaddsubfx-2.5.2/src/UI/guimain.cpp:571:28: error: format not a string literal and no format arguments [-Werror=format-security]
+         printf(help_message);
+                            ^
+cc1plus: some warnings being treated as errors
+```
+
+### `stackprotector`
+
+Adds the `-fstack-protector-strong --param ssp-buffer-size=4` compiler options. This adds safety checks against stack overwrites rendering many potential code injection attacks into aborting situations. In the best case this turns code injection vulnerabilities into denial of service or into non-issues (depending on the application).
+
+This needs to be turned off or fixed for errors similar to:
+
+```
+bin/blib.a(bios_console.o): In function `bios_handle_cup':
+/tmp/nix-build-ipxe-20141124-5cbdc41.drv-0/ipxe-5cbdc41/src/arch/i386/firmware/pcbios/bios_console.c:86: undefined reference to `__stack_chk_fail'
+```
+
+### `fortify`
+
+Adds the `-O2 -D_FORTIFY_SOURCE=2` compiler options. During code generation the compiler knows a great deal of information about buffer sizes (where possible), and attempts to replace insecure unlimited length buffer function calls with length-limited ones. This is especially useful for old, crufty code. Additionally, format strings in writable memory that contain `%n` are blocked. If an application depends on such a format string, it will need to be worked around.
+
+Additionally, some warnings are enabled which might trigger build failures if compiler warnings are treated as errors in the package build. In this case, set `NIX_CFLAGS_COMPILE` to `-Wno-error=warning-type`.
+
+This needs to be turned off or fixed for errors similar to:
+
+```
+malloc.c:404:15: error: return type is an incomplete type
+malloc.c:410:19: error: storage size of 'ms' isn't known
+
+strdup.h:22:1: error: expected identifier or '(' before '__extension__'
+
+strsep.c:65:23: error: register name not specified for 'delim'
+
+installwatch.c:3751:5: error: conflicting types for '__open_2'
+
+fcntl2.h:50:4: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments
+```
+
+### `pic`
+
+Adds the `-fPIC` compiler options. This options adds support for position independent code in shared libraries and thus making ASLR possible.
+
+Most notably, the Linux kernel, kernel modules and other code not running in an operating system environment like boot loaders won’t build with PIC enabled. The compiler will is most cases complain that PIC is not supported for a specific build.
+
+This needs to be turned off or fixed for assembler errors similar to:
+
+```
+ccbLfRgg.s: Assembler messages:
+ccbLfRgg.s:33: Error: missing or invalid displacement expression `private_key_len@GOTOFF'
+```
+
+### `strictoverflow`
+
+Signed integer overflow is undefined behaviour according to the C standard. If it happens, it is an error in the program as it should check for overflow before it can happen, not afterwards. GCC provides built-in functions to perform arithmetic with overflow checking, which are correct and faster than any custom implementation. As a workaround, the option `-fno-strict-overflow` makes gcc behave as if signed integer overflows were defined.
+
+This flag should not trigger any build or runtime errors.
+
+### `relro`
+
+Adds the `-z relro` linker option. During program load, several ELF memory sections need to be written to by the linker, but can be turned read-only before turning over control to the program. This prevents some GOT (and .dtors) overwrite attacks, but at least the part of the GOT used by the dynamic linker (.got.plt) is still vulnerable.
+
+This flag can break dynamic shared object loading. For instance, the module systems of Xorg and OpenCV are incompatible with this flag. In almost all cases the `bindnow` flag must also be disabled and incompatible programs typically fail with similar errors at runtime.
+
+### `bindnow`
+
+Adds the `-z bindnow` linker option. During program load, all dynamic symbols are resolved, allowing for the complete GOT to be marked read-only (due to `relro`). This prevents GOT overwrite attacks. For very large applications, this can incur some performance loss during initial load while symbols are resolved, but this shouldn’t be an issue for daemons.
+
+This flag can break dynamic shared object loading. For instance, the module systems of Xorg and PHP are incompatible with this flag. Programs incompatible with this flag often fail at runtime due to missing symbols, like:
+
+```
+intel_drv.so: undefined symbol: vgaHWFreeHWRec
+```
+
+The following flags are disabled by default and should be enabled with `hardeningEnable` for packages that take untrusted input like network services.
+
+### `pie`
+
+Adds the `-fPIE` compiler and `-pie` linker options. Position Independent Executables are needed to take advantage of Address Space Layout Randomization, supported by modern kernel versions. While ASLR can already be enforced for data areas in the stack and heap (brk and mmap), the code areas must be compiled as position-independent. Shared libraries already do this with the `pic` flag, so they gain ASLR automatically, but binary .text regions need to be build with `pie` to gain ASLR. When this happens, ROP attacks are much harder since there are no static locations to bounce off of during a memory corruption attack.
+
+For more in-depth information on these hardening flags and hardening in general, refer to the [Debian Wiki](https://wiki.debian.org/Hardening), [Ubuntu Wiki](https://wiki.ubuntu.com/Security/Features), [Gentoo Wiki](https://wiki.gentoo.org/wiki/Project:Hardened), and the [Arch Wiki](https://wiki.archlinux.org/index.php/DeveloperWiki:Security).
+
+[^footnote-stdenv-ignored-build-platform]: The build platform is ignored because it is a mere implementation detail of the package satisfying the dependency: As a general programming principle, dependencies are always *specified* as interfaces, not concrete implementation.
+[^footnote-stdenv-native-dependencies-in-path]: Currently, this means for native builds all dependencies are put on the `PATH`. But in the future that may not be the case for sake of matching cross: the platforms would be assumed to be unique for native and cross builds alike, so only the `depsBuild*` and `nativeBuildInputs` would be added to the `PATH`.
+[^footnote-stdenv-find-inputs-location]: The `findInputs` function, currently residing in `pkgs/stdenv/generic/setup.sh`, implements the propagation logic.
+[^footnote-stdenv-sys-lib-search-path]: It clears the `sys_lib_*search_path` variables in the Libtool script to prevent Libtool from using libraries in `/usr/lib` and such.
+[^footnote-stdenv-build-time-guessing-impurity]: Eventually these will be passed building natively as well, to improve determinism: build-time guessing, as is done today, is a risk of impurity.
+[^footnote-stdenv-per-platform-wrapper]: Each wrapper targets a single platform, so if binaries for multiple platforms are needed, the underlying binaries must be wrapped multiple times. As this is a property of the wrapper itself, the multiple wrappings are needed whether or not the same underlying binaries can target multiple platforms.
diff --git a/nixpkgs/doc/stdenv/stdenv.xml b/nixpkgs/doc/stdenv/stdenv.xml
deleted file mode 100644
index 21485425f268..000000000000
--- a/nixpkgs/doc/stdenv/stdenv.xml
+++ /dev/null
@@ -1,2423 +0,0 @@
-<chapter xmlns="http://docbook.org/ns/docbook"
-         xmlns:xlink="http://www.w3.org/1999/xlink"
-         xml:id="chap-stdenv">
- <title>The Standard Environment</title>
- <para>
-  The standard build environment in the Nix Packages collection provides an environment for building Unix packages that does a lot of common build tasks automatically. In fact, for Unix packages that use the standard <literal>./configure; make; make install</literal> build interface, you don’t need to write a build script at all; the standard environment does everything automatically. If <literal>stdenv</literal> doesn’t do what you need automatically, you can easily customise or override the various build phases.
- </para>
- <section xml:id="sec-using-stdenv">
-  <title>Using <literal>stdenv</literal></title>
-
-  <para>
-   To build a package with the standard environment, you use the function <varname>stdenv.mkDerivation</varname>, instead of the primitive built-in function <varname>derivation</varname>, e.g.
-<programlisting>
-stdenv.mkDerivation {
-  name = "libfoo-1.2.3";
-  src = fetchurl {
-    url = "http://example.org/libfoo-1.2.3.tar.bz2";
-    sha256 = "0x2g1jqygyr5wiwg4ma1nd7w4ydpy82z9gkcv8vh2v8dn3y58v5m";
-  };
-}</programlisting>
-   (<varname>stdenv</varname> needs to be in scope, so if you write this in a separate Nix expression from <filename>pkgs/all-packages.nix</filename>, you need to pass it as a function argument.) Specifying a <varname>name</varname> and a <varname>src</varname> is the absolute minimum Nix requires. For convenience, you can also use <varname>pname</varname> and <varname>version</varname> attributes and <literal>mkDerivation</literal> will automatically set <varname>name</varname> to <literal>"${pname}-${version}"</literal> by default. Since <link xlink:href="https://github.com/NixOS/rfcs/pull/35">RFC 0035</link>, this is preferred for packages in Nixpkgs, as it allows us to reuse the version easily:
-<programlisting>
-stdenv.mkDerivation rec {
-  pname = "libfoo";
-  version = "1.2.3";
-  src = fetchurl {
-    url = "http://example.org/libfoo-source-${version}.tar.bz2";
-    sha256 = "0x2g1jqygyr5wiwg4ma1nd7w4ydpy82z9gkcv8vh2v8dn3y58v5m";
-  };
-}</programlisting>
-  </para>
-
-  <para>
-   Many packages have dependencies that are not provided in the standard environment. It’s usually sufficient to specify those dependencies in the <varname>buildInputs</varname> attribute:
-<programlisting>
-stdenv.mkDerivation {
-  name = "libfoo-1.2.3";
-  ...
-  buildInputs = [libbar perl ncurses];
-}</programlisting>
-   This attribute ensures that the <filename>bin</filename> subdirectories of these packages appear in the <envar>PATH</envar> environment variable during the build, that their <filename>include</filename> subdirectories are searched by the C compiler, and so on. (See <xref linkend="ssec-setup-hooks"/> for details.)
-  </para>
-
-  <para>
-   Often it is necessary to override or modify some aspect of the build. To make this easier, the standard environment breaks the package build into a number of <emphasis>phases</emphasis>, all of which can be overridden or modified individually: unpacking the sources, applying patches, configuring, building, and installing. (There are some others; see <xref linkend="sec-stdenv-phases"/>.) For instance, a package that doesn’t supply a makefile but instead has to be compiled “manually” could be handled like this:
-<programlisting>
-stdenv.mkDerivation {
-  name = "fnord-4.5";
-  ...
-  buildPhase = ''
-    gcc foo.c -o foo
-  '';
-  installPhase = ''
-    mkdir -p $out/bin
-    cp foo $out/bin
-  '';
-}</programlisting>
-   (Note the use of <literal>''</literal>-style string literals, which are very convenient for large multi-line script fragments because they don’t need escaping of <literal>"</literal> and <literal>\</literal>, and because indentation is intelligently removed.)
-  </para>
-
-  <para>
-   There are many other attributes to customise the build. These are listed in <xref linkend="ssec-stdenv-attributes"/>.
-  </para>
-
-  <para>
-   While the standard environment provides a generic builder, you can still supply your own build script:
-<programlisting>
-stdenv.mkDerivation {
-  name = "libfoo-1.2.3";
-  ...
-  builder = ./builder.sh;
-}</programlisting>
-   where the builder can do anything it wants, but typically starts with
-<programlisting>
-source $stdenv/setup
-</programlisting>
-   to let <literal>stdenv</literal> set up the environment (e.g., process the <varname>buildInputs</varname>). If you want, you can still use <literal>stdenv</literal>’s generic builder:
-<programlisting>
-source $stdenv/setup
-
-buildPhase() {
-  echo "... this is my custom build phase ..."
-  gcc foo.c -o foo
-}
-
-installPhase() {
-  mkdir -p $out/bin
-  cp foo $out/bin
-}
-
-genericBuild
-</programlisting>
-  </para>
- </section>
- <section xml:id="sec-tools-of-stdenv">
-  <title>Tools provided by <literal>stdenv</literal></title>
-
-  <para>
-   The standard environment provides the following packages:
-   <itemizedlist>
-    <listitem>
-     <para>
-      The GNU C Compiler, configured with C and C++ support.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      GNU coreutils (contains a few dozen standard Unix commands).
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      GNU findutils (contains <command>find</command>).
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      GNU diffutils (contains <command>diff</command>, <command>cmp</command>).
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      GNU <command>sed</command>.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      GNU <command>grep</command>.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      GNU <command>awk</command>.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      GNU <command>tar</command>.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      <command>gzip</command>, <command>bzip2</command> and <command>xz</command>.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      GNU Make.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      Bash. This is the shell used for all builders in the Nix Packages collection. Not using <command>/bin/sh</command> removes a large source of portability problems.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      The <command>patch</command> command.
-     </para>
-    </listitem>
-   </itemizedlist>
-  </para>
-
-  <para>
-   On Linux, <literal>stdenv</literal> also includes the <command>patchelf</command> utility.
-  </para>
- </section>
- <section xml:id="ssec-stdenv-dependencies">
-  <title>Specifying dependencies</title>
-
-  <para>
-   As described in the Nix manual, almost any <filename>*.drv</filename> store path in a derivation's attribute set will induce a dependency on that derivation. <varname>mkDerivation</varname>, however, takes a few attributes intended to, between them, include all the dependencies of a package. This is done both for structure and consistency, but also so that certain other setup can take place. For example, certain dependencies need their bin directories added to the <envar>PATH</envar>. That is built-in, but other setup is done via a pluggable mechanism that works in conjunction with these dependency attributes. See <xref linkend="ssec-setup-hooks"/> for details.
-  </para>
-
-  <para>
-   Dependencies can be broken down along three axes: their host and target platforms relative to the new derivation's, and whether they are propagated. The platform distinctions are motivated by cross compilation; see <xref linkend="chap-cross"/> for exactly what each platform means.
-   <footnote xml:id="footnote-stdenv-ignored-build-platform">
-    <para>
-     The build platform is ignored because it is a mere implementation detail of the package satisfying the dependency: As a general programming principle, dependencies are always <emphasis>specified</emphasis> as interfaces, not concrete implementation.
-    </para>
-   </footnote>
-   But even if one is not cross compiling, the platforms imply whether or not the dependency is needed at run-time or build-time, a concept that makes perfect sense outside of cross compilation. By default, the run-time/build-time distinction is just a hint for mental clarity, but with <varname>strictDeps</varname> set it is mostly enforced even in the native case.
-  </para>
-
-  <para>
-   The extension of <envar>PATH</envar> with dependencies, alluded to above, proceeds according to the relative platforms alone. The process is carried out only for dependencies whose host platform matches the new derivation's build platform i.e. dependencies which run on the platform where the new derivation will be built.
-   <footnote xml:id="footnote-stdenv-native-dependencies-in-path">
-    <para>
-     Currently, this means for native builds all dependencies are put on the <envar>PATH</envar>. But in the future that may not be the case for sake of matching cross: the platforms would be assumed to be unique for native and cross builds alike, so only the <varname>depsBuild*</varname> and <varname>nativeBuildInputs</varname> would be added to the <envar>PATH</envar>.
-    </para>
-   </footnote>
-   For each dependency <replaceable>dep</replaceable> of those dependencies, <filename><replaceable>dep</replaceable>/bin</filename>, if present, is added to the <envar>PATH</envar> environment variable.
-  </para>
-
-  <para>
-   The dependency is propagated when it forces some of its other-transitive (non-immediate) downstream dependencies to also take it on as an immediate dependency. Nix itself already takes a package's transitive dependencies into account, but this propagation ensures nixpkgs-specific infrastructure like setup hooks (mentioned above) also are run as if the propagated dependency.
-  </para>
-
-  <para>
-   It is important to note that dependencies are not necessarily propagated as the same sort of dependency that they were before, but rather as the corresponding sort so that the platform rules still line up. The exact rules for dependency propagation can be given by assigning to each dependency two integers based one how its host and target platforms are offset from the depending derivation's platforms. Those offsets are given below in the descriptions of each dependency list attribute. Algorithmically, we traverse propagated inputs, accumulating every propagated dependency's propagated dependencies and adjusting them to account for the "shift in perspective" described by the current dependency's platform offsets. This results in sort a transitive closure of the dependency relation, with the offsets being approximately summed when two dependency links are combined. We also prune transitive dependencies whose combined offsets go out-of-bounds, which can be viewed as a filter over that transitive closure removing dependencies that are blatantly absurd.
-  </para>
-
-  <para>
-   We can define the process precisely with <link xlink:href="https://en.wikipedia.org/wiki/Natural_deduction">Natural Deduction</link> using the inference rules. This probably seems a bit obtuse, but so is the bash code that actually implements it!
-   <footnote xml:id="footnote-stdenv-find-inputs-location">
-    <para>
-     The <function>findInputs</function> function, currently residing in <filename>pkgs/stdenv/generic/setup.sh</filename>, implements the propagation logic.
-    </para>
-   </footnote>
-   They're confusing in very different ways so... hopefully if something doesn't make sense in one presentation, it will in the other!
-<programlisting>
-let mapOffset(h, t, i) = i + (if i &lt;= 0 then h else t - 1)
-
-propagated-dep(h0, t0, A, B)
-propagated-dep(h1, t1, B, C)
-h0 + h1 in {-1, 0, 1}
-h0 + t1 in {-1, 0, 1}
--------------------------------------- Transitive property
-propagated-dep(mapOffset(h0, t0, h1),
-               mapOffset(h0, t0, t1),
-               A, C)</programlisting>
-<programlisting>
-let mapOffset(h, t, i) = i + (if i &lt;= 0 then h else t - 1)
-
-dep(h0, _, A, B)
-propagated-dep(h1, t1, B, C)
-h0 + h1 in {-1, 0, 1}
-h0 + t1 in {-1, 0, -1}
------------------------------ Take immediate dependencies' propagated dependencies
-propagated-dep(mapOffset(h0, t0, h1),
-               mapOffset(h0, t0, t1),
-               A, C)</programlisting>
-<programlisting>
-propagated-dep(h, t, A, B)
------------------------------ Propagated dependencies count as dependencies
-dep(h, t, A, B)</programlisting>
-   Some explanation of this monstrosity is in order. In the common case, the target offset of a dependency is the successor to the target offset: <literal>t = h + 1</literal>. That means that:
-<programlisting>
-let f(h, t, i) = i + (if i &lt;= 0 then h else t - 1)
-let f(h, h + 1, i) = i + (if i &lt;= 0 then h else (h + 1) - 1)
-let f(h, h + 1, i) = i + (if i &lt;= 0 then h else h)
-let f(h, h + 1, i) = i + h
-</programlisting>
-   This is where "sum-like" comes in from above: We can just sum all of the host offsets to get the host offset of the transitive dependency. The target offset is the transitive dependency is simply the host offset + 1, just as it was with the dependencies composed to make this transitive one; it can be ignored as it doesn't add any new information.
-  </para>
-
-  <para>
-   Because of the bounds checks, the uncommon cases are <literal>h = t</literal> and <literal>h + 2 = t</literal>. In the former case, the motivation for <function>mapOffset</function> is that since its host and target platforms are the same, no transitive dependency of it should be able to "discover" an offset greater than its reduced target offsets. <function>mapOffset</function> effectively "squashes" all its transitive dependencies' offsets so that none will ever be greater than the target offset of the original <literal>h = t</literal> package. In the other case, <literal>h + 1</literal> is skipped over between the host and target offsets. Instead of squashing the offsets, we need to "rip" them apart so no transitive dependencies' offset is that one.
-  </para>
-
-  <para>
-   Overall, the unifying theme here is that propagation shouldn't be introducing transitive dependencies involving platforms the depending package is unaware of. [One can imagine the dependending package asking for dependencies with the platforms it knows about; other platforms it doesn't know how to ask for. The platform description in that scenario is a kind of unforagable capability.] The offset bounds checking and definition of <function>mapOffset</function> together ensure that this is the case. Discovering a new offset is discovering a new platform, and since those platforms weren't in the derivation "spec" of the needing package, they cannot be relevant. From a capability perspective, we can imagine that the host and target platforms of a package are the capabilities a package requires, and the depending package must provide the capability to the dependency.
-  </para>
-
-  <variablelist>
-   <title>Variables specifying dependencies</title>
-   <varlistentry xml:id="var-stdenv-depsBuildBuild">
-    <term>
-     <varname>depsBuildBuild</varname>
-    </term>
-    <listitem>
-     <para>
-      A list of dependencies whose host and target platforms are the new derivation's build platform. This means a <literal>-1</literal> host and <literal>-1</literal> target offset from the new derivation's platforms. These are programs and libraries used at build time that produce programs and libraries also used at build time. If the dependency doesn't care about the target platform (i.e. isn't a compiler or similar tool), put it in <varname>nativeBuildInputs</varname> instead. The most common use of this <literal>buildPackages.stdenv.cc</literal>, the default C compiler for this role. That example crops up more than one might think in old commonly used C libraries.
-     </para>
-     <para>
-      Since these packages are able to be run at build-time, they are always added to the <envar>PATH</envar>, as described above. But since these packages are only guaranteed to be able to run then, they shouldn't persist as run-time dependencies. This isn't currently enforced, but could be in the future.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-stdenv-nativeBuildInputs">
-    <term>
-     <varname>nativeBuildInputs</varname>
-    </term>
-    <listitem>
-     <para>
-      A list of dependencies whose host platform is the new derivation's build platform, and target platform is the new derivation's host platform. This means a <literal>-1</literal> host offset and <literal>0</literal> target offset from the new derivation's platforms. These are programs and libraries used at build-time that, if they are a compiler or similar tool, produce code to run at run-time—i.e. tools used to build the new derivation. If the dependency doesn't care about the target platform (i.e. isn't a compiler or similar tool), put it here, rather than in <varname>depsBuildBuild</varname> or <varname>depsBuildTarget</varname>. This could be called <varname>depsBuildHost</varname> but <varname>nativeBuildInputs</varname> is used for historical continuity.
-     </para>
-     <para>
-      Since these packages are able to be run at build-time, they are added to the <envar>PATH</envar>, as described above. But since these packages are only guaranteed to be able to run then, they shouldn't persist as run-time dependencies. This isn't currently enforced, but could be in the future.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-stdenv-depsBuildTarget">
-    <term>
-     <varname>depsBuildTarget</varname>
-    </term>
-    <listitem>
-     <para>
-      A list of dependencies whose host platform is the new derivation's build platform, and target platform is the new derivation's target platform. This means a <literal>-1</literal> host offset and <literal>1</literal> target offset from the new derivation's platforms. These are programs used at build time that produce code to run with code produced by the depending package. Most commonly, these are tools used to build the runtime or standard library that the currently-being-built compiler will inject into any code it compiles. In many cases, the currently-being-built-compiler is itself employed for that task, but when that compiler won't run (i.e. its build and host platform differ) this is not possible. Other times, the compiler relies on some other tool, like binutils, that is always built separately so that the dependency is unconditional.
-     </para>
-     <para>
-      This is a somewhat confusing concept to wrap one’s head around, and for good reason. As the only dependency type where the platform offsets are not adjacent integers, it requires thinking of a bootstrapping stage <emphasis>two</emphasis> away from the current one. It and its use-case go hand in hand and are both considered poor form: try to not need this sort of dependency, and try to avoid building standard libraries and runtimes in the same derivation as the compiler produces code using them. Instead strive to build those like a normal library, using the newly-built compiler just as a normal library would. In short, do not use this attribute unless you are packaging a compiler and are sure it is needed.
-     </para>
-     <para>
-      Since these packages are able to run at build time, they are added to the <envar>PATH</envar>, as described above. But since these packages are only guaranteed to be able to run then, they shouldn't persist as run-time dependencies. This isn't currently enforced, but could be in the future.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-stdenv-depsHostHost">
-    <term>
-     <varname>depsHostHost</varname>
-    </term>
-    <listitem>
-     <para>
-      A list of dependencies whose host and target platforms match the new derivation's host platform. This means a <literal>0</literal> host offset and <literal>0</literal> target offset from the new derivation's host platform. These are packages used at run-time to generate code also used at run-time. In practice, this would usually be tools used by compilers for macros or a metaprogramming system, or libraries used by the macros or metaprogramming code itself. It's always preferable to use a <varname>depsBuildBuild</varname> dependency in the derivation being built over a <varname>depsHostHost</varname> on the tool doing the building for this purpose.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-stdenv-buildInputs">
-    <term>
-     <varname>buildInputs</varname>
-    </term>
-    <listitem>
-     <para>
-      A list of dependencies whose host platform and target platform match the new derivation's. This means a <literal>0</literal> host offset and a <literal>1</literal> target offset from the new derivation's host platform. This would be called <varname>depsHostTarget</varname> but for historical continuity. If the dependency doesn't care about the target platform (i.e. isn't a compiler or similar tool), put it here, rather than in <varname>depsBuildBuild</varname>.
-     </para>
-     <para>
-      These are often programs and libraries used by the new derivation at <emphasis>run</emphasis>-time, but that isn't always the case. For example, the machine code in a statically-linked library is only used at run-time, but the derivation containing the library is only needed at build-time. Even in the dynamic case, the library may also be needed at build-time to appease the linker.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-stdenv-depsTargetTarget">
-    <term>
-     <varname>depsTargetTarget</varname>
-    </term>
-    <listitem>
-     <para>
-      A list of dependencies whose host platform matches the new derivation's target platform. This means a <literal>1</literal> offset from the new derivation's platforms. These are packages that run on the target platform, e.g. the standard library or run-time deps of standard library that a compiler insists on knowing about. It's poor form in almost all cases for a package to depend on another from a future stage [future stage corresponding to positive offset]. Do not use this attribute unless you are packaging a compiler and are sure it is needed.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-stdenv-depsBuildBuildPropagated">
-    <term>
-     <varname>depsBuildBuildPropagated</varname>
-    </term>
-    <listitem>
-     <para>
-      The propagated equivalent of <varname>depsBuildBuild</varname>. This perhaps never ought to be used, but it is included for consistency [see below for the others].
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-stdenv-propagatedNativeBuildInputs">
-    <term>
-     <varname>propagatedNativeBuildInputs</varname>
-    </term>
-    <listitem>
-     <para>
-      The propagated equivalent of <varname>nativeBuildInputs</varname>. This would be called <varname>depsBuildHostPropagated</varname> but for historical continuity. For example, if package <varname>Y</varname> has <literal>propagatedNativeBuildInputs = [X]</literal>, and package <varname>Z</varname> has <literal>buildInputs = [Y]</literal>, then package <varname>Z</varname> will be built as if it included package <varname>X</varname> in its <varname>nativeBuildInputs</varname>. If instead, package <varname>Z</varname> has <literal>nativeBuildInputs = [Y]</literal>, then <varname>Z</varname> will be built as if it included <varname>X</varname> in the <varname>depsBuildBuild</varname> of package <varname>Z</varname>, because of the sum of the two <literal>-1</literal> host offsets.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-stdenv-depsBuildTargetPropagated">
-    <term>
-     <varname>depsBuildTargetPropagated</varname>
-    </term>
-    <listitem>
-     <para>
-      The propagated equivalent of <varname>depsBuildTarget</varname>. This is prefixed for the same reason of alerting potential users.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-stdenv-depsHostHostPropagated">
-    <term>
-     <varname>depsHostHostPropagated</varname>
-    </term>
-    <listitem>
-     <para>
-      The propagated equivalent of <varname>depsHostHost</varname>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-stdenv-propagatedBuildInputs">
-    <term>
-     <varname>propagatedBuildInputs</varname>
-    </term>
-    <listitem>
-     <para>
-      The propagated equivalent of <varname>buildInputs</varname>. This would be called <varname>depsHostTargetPropagated</varname> but for historical continuity.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-stdenv-depsTargetTargetPropagated">
-    <term>
-     <varname>depsTargetTargetPropagated</varname>
-    </term>
-    <listitem>
-     <para>
-      The propagated equivalent of <varname>depsTargetTarget</varname>. This is prefixed for the same reason of alerting potential users.
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
- </section>
- <section xml:id="ssec-stdenv-attributes">
-  <title>Attributes</title>
-
-  <variablelist>
-   <title>Variables affecting <literal>stdenv</literal> initialisation</title>
-   <varlistentry xml:id="var-stdenv-NIX_DEBUG">
-    <term>
-     <varname>NIX_DEBUG</varname>
-    </term>
-    <listitem>
-     <para>
-      A natural number indicating how much information to log. If set to 1 or higher, <literal>stdenv</literal> will print moderate debugging information during the build. In particular, the <command>gcc</command> and <command>ld</command> wrapper scripts will print out the complete command line passed to the wrapped tools. If set to 6 or higher, the <literal>stdenv</literal> setup script will be run with <literal>set -x</literal> tracing. If set to 7 or higher, the <command>gcc</command> and <command>ld</command> wrapper scripts will also be run with <literal>set -x</literal> tracing.
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
-
-  <variablelist>
-   <title>Attributes affecting build properties</title>
-   <varlistentry xml:id="var-stdenv-enableParallelBuilding">
-    <term>
-     <varname>enableParallelBuilding</varname>
-    </term>
-    <listitem>
-     <para>
-      If set to <literal>true</literal>, <literal>stdenv</literal> will pass specific flags to <literal>make</literal> and other build tools to enable parallel building with up to <literal>build-cores</literal> workers.
-     </para>
-     <para>
-      Unless set to <literal>false</literal>, some build systems with good support for parallel building including <literal>cmake</literal>, <literal>meson</literal>, and <literal>qmake</literal> will set it to <literal>true</literal>.
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
-
-  <variablelist>
-   <title>Special variables</title>
-   <varlistentry xml:id="var-stdenv-passthru">
-    <term>
-     <varname>passthru</varname>
-    </term>
-    <listitem>
-     <para>
-      This is an attribute set which can be filled with arbitrary values. For example:
-<programlisting>
-passthru = {
-  foo = "bar";
-  baz = {
-    value1 = 4;
-    value2 = 5;
-  };
-}
-</programlisting>
-     </para>
-     <para>
-      Values inside it are not passed to the builder, so you can change them without triggering a rebuild. However, they can be accessed outside of a derivation directly, as if they were set inside a derivation itself, e.g. <literal>hello.baz.value1</literal>. We don't specify any usage or schema of <literal>passthru</literal> - it is meant for values that would be useful outside the derivation in other parts of a Nix expression (e.g. in other derivations). An example would be to convey some specific dependency of your derivation which contains a program with plugins support. Later, others who make derivations with plugins can use passed-through dependency to ensure that their plugin would be binary-compatible with built program.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id="var-passthru-updateScript">
-    <term>
-     <varname>passthru.updateScript</varname>
-    </term>
-    <listitem>
-     <para>
-      A script to be run by <filename>maintainers/scripts/update.nix</filename> when the package is matched. It needs to be an executable file, either on the file system:
-<programlisting>
-passthru.updateScript = ./update.sh;
-</programlisting>
-      or inside the expression itself:
-<programlisting>
-passthru.updateScript = writeScript "update-zoom-us" ''
-  #!/usr/bin/env nix-shell
-  #!nix-shell -i bash -p curl pcre common-updater-scripts
-
-  set -eu -o pipefail
-
-  version="$(curl -sI https://zoom.us/client/latest/zoom_x86_64.tar.xz | grep -Fi 'Location:' | pcregrep -o1 '/(([0-9]\.?)+)/')"
-  update-source-version zoom-us "$version"
-'';
-</programlisting>
-      The attribute can also contain a list, a script followed by arguments to be passed to it:
-<programlisting>
-passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ];
-</programlisting>
-      The script will be run with <varname>UPDATE_NIX_ATTR_PATH</varname> environment variable set to the attribute path it is supposed to update.
-      <note>
-       <para>
-        The script will be usually run from the root of the Nixpkgs repository but you should not rely on that. Also note that the update scripts will be run in parallel by default; you should avoid running <command>git commit</command> or any other commands that cannot handle that.
-       </para>
-      </note>
-     </para>
-     <para>
-      For information about how to run the updates, execute <command>nix-shell maintainers/scripts/update.nix</command>.
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
- </section>
- <section xml:id="sec-stdenv-phases">
-  <title>Phases</title>
-
-  <para>
-   The generic builder has a number of <emphasis>phases</emphasis>. Package builds are split into phases to make it easier to override specific parts of the build (e.g., unpacking the sources or installing the binaries). Furthermore, it allows a nicer presentation of build logs in the Nix build farm.
-  </para>
-
-  <para>
-   Each phase can be overridden in its entirety either by setting the environment variable <varname><replaceable>name</replaceable>Phase</varname> to a string containing some shell commands to be executed, or by redefining the shell function <varname><replaceable>name</replaceable>Phase</varname>. The former is convenient to override a phase from the derivation, while the latter is convenient from a build script. However, typically one only wants to <emphasis>add</emphasis> some commands to a phase, e.g. by defining <literal>postInstall</literal> or <literal>preFixup</literal>, as skipping some of the default actions may have unexpected consequences. The default script for each phase is defined in the file <filename>pkgs/stdenv/generic/setup.sh</filename>.
-  </para>
-
-  <section xml:id="ssec-controlling-phases">
-   <title>Controlling phases</title>
-
-   <para>
-    There are a number of variables that control what phases are executed and in what order:
-    <variablelist>
-     <title>Variables affecting phase control</title>
-     <varlistentry xml:id="var-stdenv-phases">
-      <term>
-       <varname>phases</varname>
-      </term>
-      <listitem>
-       <para>
-        Specifies the phases. You can change the order in which phases are executed, or add new phases, by setting this variable. If it’s not set, the default value is used, which is <literal>$prePhases unpackPhase patchPhase $preConfigurePhases configurePhase $preBuildPhases buildPhase checkPhase $preInstallPhases installPhase fixupPhase installCheckPhase $preDistPhases distPhase $postPhases</literal>.
-       </para>
-       <para>
-        Usually, if you just want to add a few phases, it’s more convenient to set one of the variables below (such as <varname>preInstallPhases</varname>), as you then don’t specify all the normal phases.
-       </para>
-      </listitem>
-     </varlistentry>
-     <varlistentry xml:id="var-stdenv-prePhases">
-      <term>
-       <varname>prePhases</varname>
-      </term>
-      <listitem>
-       <para>
-        Additional phases executed before any of the default phases.
-       </para>
-      </listitem>
-     </varlistentry>
-     <varlistentry xml:id="var-stdenv-preConfigurePhases">
-      <term>
-       <varname>preConfigurePhases</varname>
-      </term>
-      <listitem>
-       <para>
-        Additional phases executed just before the configure phase.
-       </para>
-      </listitem>
-     </varlistentry>
-     <varlistentry xml:id="var-stdenv-preBuildPhases">
-      <term>
-       <varname>preBuildPhases</varname>
-      </term>
-      <listitem>
-       <para>
-        Additional phases executed just before the build phase.
-       </para>
-      </listitem>
-     </varlistentry>
-     <varlistentry xml:id="var-stdenv-preInstallPhases">
-      <term>
-       <varname>preInstallPhases</varname>
-      </term>
-      <listitem>
-       <para>
-        Additional phases executed just before the install phase.
-       </para>
-      </listitem>
-     </varlistentry>
-     <varlistentry xml:id="var-stdenv-preFixupPhases">
-      <term>
-       <varname>preFixupPhases</varname>
-      </term>
-      <listitem>
-       <para>
-        Additional phases executed just before the fixup phase.
-       </para>
-      </listitem>
-     </varlistentry>
-     <varlistentry xml:id="var-stdenv-preDistPhases">
-      <term>
-       <varname>preDistPhases</varname>
-      </term>
-      <listitem>
-       <para>
-        Additional phases executed just before the distribution phase.
-       </para>
-      </listitem>
-     </varlistentry>
-     <varlistentry xml:id="var-stdenv-postPhases">
-      <term>
-       <varname>postPhases</varname>
-      </term>
-      <listitem>
-       <para>
-        Additional phases executed after any of the default phases.
-       </para>
-      </listitem>
-     </varlistentry>
-    </variablelist>
-   </para>
-  </section>
-
-  <section xml:id="ssec-unpack-phase">
-   <title>The unpack phase</title>
-
-   <para>
-    The unpack phase is responsible for unpacking the source code of the package. The default implementation of <function>unpackPhase</function> unpacks the source files listed in the <envar>src</envar> environment variable to the current directory. It supports the following files by default:
-    <variablelist>
-     <varlistentry>
-      <term>
-       Tar files
-      </term>
-      <listitem>
-       <para>
-        These can optionally be compressed using <command>gzip</command> (<filename>.tar.gz</filename>, <filename>.tgz</filename> or <filename>.tar.Z</filename>), <command>bzip2</command> (<filename>.tar.bz2</filename>, <filename>.tbz2</filename> or <filename>.tbz</filename>) or <command>xz</command> (<filename>.tar.xz</filename>, <filename>.tar.lzma</filename> or <filename>.txz</filename>).
-       </para>
-      </listitem>
-     </varlistentry>
-     <varlistentry>
-      <term>
-       Zip files
-      </term>
-      <listitem>
-       <para>
-        Zip files are unpacked using <command>unzip</command>. However, <command>unzip</command> is not in the standard environment, so you should add it to <varname>nativeBuildInputs</varname> yourself.
-       </para>
-      </listitem>
-     </varlistentry>
-     <varlistentry>
-      <term>
-       Directories in the Nix store
-      </term>
-      <listitem>
-       <para>
-        These are simply copied to the current directory. The hash part of the file name is stripped, e.g. <filename>/nix/store/1wydxgby13cz...-my-sources</filename> would be copied to <filename>my-sources</filename>.
-       </para>
-      </listitem>
-     </varlistentry>
-    </variablelist>
-    Additional file types can be supported by setting the <varname>unpackCmd</varname> variable (see below).
-   </para>
-
-   <para></para>
-
-   <variablelist>
-    <title>Variables controlling the unpack phase</title>
-    <varlistentry xml:id="var-stdenv-src">
-     <term>
-      <varname>srcs</varname> / <varname>src</varname>
-     </term>
-     <listitem>
-      <para>
-       The list of source files or directories to be unpacked or copied. One of these must be set.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-sourceRoot">
-     <term>
-      <varname>sourceRoot</varname>
-     </term>
-     <listitem>
-      <para>
-       After running <function>unpackPhase</function>, the generic builder changes the current directory to the directory created by unpacking the sources. If there are multiple source directories, you should set <varname>sourceRoot</varname> to the name of the intended directory.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-setSourceRoot">
-     <term>
-      <varname>setSourceRoot</varname>
-     </term>
-     <listitem>
-      <para>
-       Alternatively to setting <varname>sourceRoot</varname>, you can set <varname>setSourceRoot</varname> to a shell command to be evaluated by the unpack phase after the sources have been unpacked. This command must set <varname>sourceRoot</varname>.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-preUnpack">
-     <term>
-      <varname>preUnpack</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the start of the unpack phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-postUnpack">
-     <term>
-      <varname>postUnpack</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the end of the unpack phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-dontUnpack">
-     <term>
-      <varname>dontUnpack</varname>
-     </term>
-     <listitem>
-      <para>
-       Set to true to skip the unpack phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-dontMakeSourcesWritable">
-     <term>
-      <varname>dontMakeSourcesWritable</varname>
-     </term>
-     <listitem>
-      <para>
-       If set to <literal>1</literal>, the unpacked sources are <emphasis>not</emphasis> made writable. By default, they are made writable to prevent problems with read-only sources. For example, copied store directories would be read-only without this.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-unpackCmd">
-     <term>
-      <varname>unpackCmd</varname>
-     </term>
-     <listitem>
-      <para>
-       The unpack phase evaluates the string <literal>$unpackCmd</literal> for any unrecognised file. The path to the current source file is contained in the <varname>curSrc</varname> variable.
-      </para>
-     </listitem>
-    </varlistentry>
-   </variablelist>
-  </section>
-
-  <section xml:id="ssec-patch-phase">
-   <title>The patch phase</title>
-
-   <para>
-    The patch phase applies the list of patches defined in the <varname>patches</varname> variable.
-   </para>
-
-   <variablelist>
-    <title>Variables controlling the patch phase</title>
-    <varlistentry xml:id="var-stdenv-dontPatch">
-     <term>
-      <varname>dontPatch</varname>
-     </term>
-     <listitem>
-      <para>
-       Set to true to skip the patch phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-patches">
-     <term>
-      <varname>patches</varname>
-     </term>
-     <listitem>
-      <para>
-       The list of patches. They must be in the format accepted by the <command>patch</command> command, and may optionally be compressed using <command>gzip</command> (<filename>.gz</filename>), <command>bzip2</command> (<filename>.bz2</filename>) or <command>xz</command> (<filename>.xz</filename>).
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-patchFlags">
-     <term>
-      <varname>patchFlags</varname>
-     </term>
-     <listitem>
-      <para>
-       Flags to be passed to <command>patch</command>. If not set, the argument <option>-p1</option> is used, which causes the leading directory component to be stripped from the file names in each patch.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-prePatch">
-     <term>
-      <varname>prePatch</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the start of the patch phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-postPatch">
-     <term>
-      <varname>postPatch</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the end of the patch phase.
-      </para>
-     </listitem>
-    </varlistentry>
-   </variablelist>
-  </section>
-
-  <section xml:id="ssec-configure-phase">
-   <title>The configure phase</title>
-
-   <para>
-    The configure phase prepares the source tree for building. The default <function>configurePhase</function> runs <filename>./configure</filename> (typically an Autoconf-generated script) if it exists.
-   </para>
-
-   <variablelist>
-    <title>Variables controlling the configure phase</title>
-    <varlistentry xml:id="var-stdenv-configureScript">
-     <term>
-      <varname>configureScript</varname>
-     </term>
-     <listitem>
-      <para>
-       The name of the configure script. It defaults to <filename>./configure</filename> if it exists; otherwise, the configure phase is skipped. This can actually be a command (like <literal>perl ./Configure.pl</literal>).
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-configureFlags">
-     <term>
-      <varname>configureFlags</varname>
-     </term>
-     <listitem>
-      <para>
-       A list of strings passed as additional arguments to the configure script.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-dontConfigure">
-     <term>
-      <varname>dontConfigure</varname>
-     </term>
-     <listitem>
-      <para>
-       Set to true to skip the configure phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-configureFlagsArray">
-     <term>
-      <varname>configureFlagsArray</varname>
-     </term>
-     <listitem>
-      <para>
-       A shell array containing additional arguments passed to the configure script. You must use this instead of <varname>configureFlags</varname> if the arguments contain spaces.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-dontAddPrefix">
-     <term>
-      <varname>dontAddPrefix</varname>
-     </term>
-     <listitem>
-      <para>
-       By default, the flag <literal>--prefix=$prefix</literal> is added to the configure flags. If this is undesirable, set this variable to true.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-prefix">
-     <term>
-      <varname>prefix</varname>
-     </term>
-     <listitem>
-      <para>
-       The prefix under which the package must be installed, passed via the <option>--prefix</option> option to the configure script. It defaults to <option>$out</option>.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-prefixKey">
-     <term>
-      <varname>prefixKey</varname>
-     </term>
-     <listitem>
-      <para>
-       The key to use when specifying the prefix. By default, this is set to <option>--prefix=</option> as that is used by the majority of packages.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-dontAddDisableDepTrack">
-     <term>
-      <varname>dontAddDisableDepTrack</varname>
-     </term>
-     <listitem>
-      <para>
-       By default, the flag <literal>--disable-dependency-tracking</literal> is added to the configure flags to speed up Automake-based builds. If this is undesirable, set this variable to true.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-dontFixLibtool">
-     <term>
-      <varname>dontFixLibtool</varname>
-     </term>
-     <listitem>
-      <para>
-       By default, the configure phase applies some special hackery to all files called <filename>ltmain.sh</filename> before running the configure script in order to improve the purity of Libtool-based packages
-       <footnote xml:id="footnote-stdenv-sys-lib-search-path">
-        <para>
-         It clears the <varname>sys_lib_<replaceable>*</replaceable>search_path</varname> variables in the Libtool script to prevent Libtool from using libraries in <filename>/usr/lib</filename> and such.
-        </para>
-       </footnote>
-       . If this is undesirable, set this variable to true.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-dontDisableStatic">
-     <term>
-      <varname>dontDisableStatic</varname>
-     </term>
-     <listitem>
-      <para>
-       By default, when the configure script has <option>--enable-static</option>, the option <option>--disable-static</option> is added to the configure flags.
-      </para>
-      <para>
-       If this is undesirable, set this variable to true.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-configurePlatforms">
-     <term>
-      <varname>configurePlatforms</varname>
-     </term>
-     <listitem>
-      <para>
-       By default, when cross compiling, the configure script has <option>--build=...</option> and <option>--host=...</option> passed. Packages can instead pass <literal>[ "build" "host" "target" ]</literal> or a subset to control exactly which platform flags are passed. Compilers and other tools can use this to also pass the target platform.
-       <footnote xml:id="footnote-stdenv-build-time-guessing-impurity">
-        <para>
-         Eventually these will be passed building natively as well, to improve determinism: build-time guessing, as is done today, is a risk of impurity.
-        </para>
-       </footnote>
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-preConfigure">
-     <term>
-      <varname>preConfigure</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the start of the configure phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-postConfigure">
-     <term>
-      <varname>postConfigure</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the end of the configure phase.
-      </para>
-     </listitem>
-    </varlistentry>
-   </variablelist>
-  </section>
-
-  <section xml:id="build-phase">
-   <title>The build phase</title>
-
-   <para>
-    The build phase is responsible for actually building the package (e.g. compiling it). The default <function>buildPhase</function> simply calls <command>make</command> if a file named <filename>Makefile</filename>, <filename>makefile</filename> or <filename>GNUmakefile</filename> exists in the current directory (or the <varname>makefile</varname> is explicitly set); otherwise it does nothing.
-   </para>
-
-   <variablelist>
-    <title>Variables controlling the build phase</title>
-    <varlistentry xml:id="var-stdenv-dontBuild">
-     <term>
-      <varname>dontBuild</varname>
-     </term>
-     <listitem>
-      <para>
-       Set to true to skip the build phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-makefile">
-     <term>
-      <varname>makefile</varname>
-     </term>
-     <listitem>
-      <para>
-       The file name of the Makefile.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-makeFlags">
-     <term>
-      <varname>makeFlags</varname>
-     </term>
-     <listitem>
-      <para>
-       A list of strings passed as additional flags to <command>make</command>. These flags are also used by the default install and check phase. For setting make flags specific to the build phase, use <varname>buildFlags</varname> (see below).
-<programlisting>
-makeFlags = [ "PREFIX=$(out)" ];
-</programlisting>
-       <note>
-        <para>
-         The flags are quoted in bash, but environment variables can be specified by using the make syntax.
-        </para>
-       </note>
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-makeFlagsArray">
-     <term>
-      <varname>makeFlagsArray</varname>
-     </term>
-     <listitem>
-      <para>
-       A shell array containing additional arguments passed to <command>make</command>. You must use this instead of <varname>makeFlags</varname> if the arguments contain spaces, e.g.
-<programlisting>
-preBuild = ''
-  makeFlagsArray+=(CFLAGS="-O0 -g" LDFLAGS="-lfoo -lbar")
-'';
-</programlisting>
-       Note that shell arrays cannot be passed through environment variables, so you cannot set <varname>makeFlagsArray</varname> in a derivation attribute (because those are passed through environment variables): you have to define them in shell code.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-buildFlags">
-     <term>
-      <varname>buildFlags</varname> / <varname>buildFlagsArray</varname>
-     </term>
-     <listitem>
-      <para>
-       A list of strings passed as additional flags to <command>make</command>. Like <varname>makeFlags</varname> and <varname>makeFlagsArray</varname>, but only used by the build phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-preBuild">
-     <term>
-      <varname>preBuild</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the start of the build phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-postBuild">
-     <term>
-      <varname>postBuild</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the end of the build phase.
-      </para>
-     </listitem>
-    </varlistentry>
-   </variablelist>
-
-   <para>
-    You can set flags for <command>make</command> through the <varname>makeFlags</varname> variable.
-   </para>
-
-   <para>
-    Before and after running <command>make</command>, the hooks <varname>preBuild</varname> and <varname>postBuild</varname> are called, respectively.
-   </para>
-  </section>
-
-  <section xml:id="ssec-check-phase">
-   <title>The check phase</title>
-
-   <para>
-    The check phase checks whether the package was built correctly by running its test suite. The default <function>checkPhase</function> calls <command>make check</command>, but only if the <varname>doCheck</varname> variable is enabled.
-   </para>
-
-   <variablelist>
-    <title>Variables controlling the check phase</title>
-    <varlistentry xml:id="var-stdenv-doCheck">
-     <term>
-      <varname>doCheck</varname>
-     </term>
-     <listitem>
-      <para>
-       Controls whether the check phase is executed. By default it is skipped, but if <varname>doCheck</varname> is set to true, the check phase is usually executed. Thus you should set
-<programlisting>doCheck = true;</programlisting>
-       in the derivation to enable checks. The exception is cross compilation. Cross compiled builds never run tests, no matter how <varname>doCheck</varname> is set, as the newly-built program won't run on the platform used to build it.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <varname>makeFlags</varname> / <varname>makeFlagsArray</varname> / <varname>makefile</varname>
-     </term>
-     <listitem>
-      <para>
-       See the <link xlink:href="#var-stdenv-makeFlags">build phase</link> for details.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-checkTarget">
-     <term>
-      <varname>checkTarget</varname>
-     </term>
-     <listitem>
-      <para>
-       The make target that runs the tests. Defaults to <literal>check</literal>.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-checkFlags">
-     <term>
-      <varname>checkFlags</varname> / <varname>checkFlagsArray</varname>
-     </term>
-     <listitem>
-      <para>
-       A list of strings passed as additional flags to <command>make</command>. Like <varname>makeFlags</varname> and <varname>makeFlagsArray</varname>, but only used by the check phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-checkInputs">
-     <term>
-      <varname>checkInputs</varname>
-     </term>
-     <listitem>
-      <para>
-       A list of dependencies used by the phase. This gets included in <varname>nativeBuildInputs</varname> when <varname>doCheck</varname> is set.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-preCheck">
-     <term>
-      <varname>preCheck</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the start of the check phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-postCheck">
-     <term>
-      <varname>postCheck</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the end of the check phase.
-      </para>
-     </listitem>
-    </varlistentry>
-   </variablelist>
-  </section>
-
-  <section xml:id="ssec-install-phase">
-   <title>The install phase</title>
-
-   <para>
-    The install phase is responsible for installing the package in the Nix store under <envar>out</envar>. The default <function>installPhase</function> creates the directory <literal>$out</literal> and calls <command>make install</command>.
-   </para>
-
-   <variablelist>
-    <title>Variables controlling the install phase</title>
-     <varlistentry xml:id="var-stdenv-dontInstall">
-     <term>
-       <varname>dontInstall</varname>
-     </term>
-     <listitem>
-      <para>
-       Set to true to skip the install phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <varname>makeFlags</varname> / <varname>makeFlagsArray</varname> / <varname>makefile</varname>
-     </term>
-     <listitem>
-      <para>
-       See the <link xlink:href="#var-stdenv-makeFlags">build phase</link> for details.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-installTargets">
-     <term>
-      <varname>installTargets</varname>
-     </term>
-     <listitem>
-      <para>
-       The make targets that perform the installation. Defaults to <literal>install</literal>. Example:
-<programlisting>
-installTargets = "install-bin install-doc";</programlisting>
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-installFlags">
-     <term>
-      <varname>installFlags</varname> / <varname>installFlagsArray</varname>
-     </term>
-     <listitem>
-      <para>
-       A list of strings passed as additional flags to <command>make</command>. Like <varname>makeFlags</varname> and <varname>makeFlagsArray</varname>, but only used by the install phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-preInstall">
-     <term>
-      <varname>preInstall</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the start of the install phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-postInstall">
-     <term>
-      <varname>postInstall</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the end of the install phase.
-      </para>
-     </listitem>
-    </varlistentry>
-   </variablelist>
-  </section>
-
-  <section xml:id="ssec-fixup-phase">
-   <title>The fixup phase</title>
-
-   <para>
-    The fixup phase performs some (Nix-specific) post-processing actions on the files installed under <filename>$out</filename> by the install phase. The default <function>fixupPhase</function> does the following:
-    <itemizedlist>
-     <listitem>
-      <para>
-       It moves the <filename>man/</filename>, <filename>doc/</filename> and <filename>info/</filename> subdirectories of <envar>$out</envar> to <filename>share/</filename>.
-      </para>
-     </listitem>
-     <listitem>
-      <para>
-       It strips libraries and executables of debug information.
-      </para>
-     </listitem>
-     <listitem>
-      <para>
-       On Linux, it applies the <command>patchelf</command> command to ELF executables and libraries to remove unused directories from the <literal>RPATH</literal> in order to prevent unnecessary runtime dependencies.
-      </para>
-     </listitem>
-     <listitem>
-      <para>
-       It rewrites the interpreter paths of shell scripts to paths found in <envar>PATH</envar>. E.g., <filename>/usr/bin/perl</filename> will be rewritten to <filename>/nix/store/<replaceable>some-perl</replaceable>/bin/perl</filename> found in <envar>PATH</envar>.
-      </para>
-     </listitem>
-    </itemizedlist>
-   </para>
-
-   <variablelist>
-    <title>Variables controlling the fixup phase</title>
-    <varlistentry xml:id="var-stdenv-dontFixup">
-     <term>
-      <varname>dontFixup</varname>
-     </term>
-     <listitem>
-      <para>
-       Set to true to skip the fixup phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-dontStrip">
-     <term>
-      <varname>dontStrip</varname>
-     </term>
-     <listitem>
-      <para>
-       If set, libraries and executables are not stripped. By default, they are.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-dontStripHost">
-     <term>
-      <varname>dontStripHost</varname>
-     </term>
-     <listitem>
-      <para>
-       Like <varname>dontStrip</varname>, but only affects the <command>strip</command> command targetting the package's host platform. Useful when supporting cross compilation, but otherwise feel free to ignore.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-dontStripTarget">
-     <term>
-      <varname>dontStripTarget</varname>
-     </term>
-     <listitem>
-      <para>
-       Like <varname>dontStrip</varname>, but only affects the <command>strip</command> command targetting the packages' target platform. Useful when supporting cross compilation, but otherwise feel free to ignore.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-dontMoveSbin">
-     <term>
-      <varname>dontMoveSbin</varname>
-     </term>
-     <listitem>
-      <para>
-       If set, files in <filename>$out/sbin</filename> are not moved to <filename>$out/bin</filename>. By default, they are.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-stripAllList">
-     <term>
-      <varname>stripAllList</varname>
-     </term>
-     <listitem>
-      <para>
-       List of directories to search for libraries and executables from which <emphasis>all</emphasis> symbols should be stripped. By default, it’s empty. Stripping all symbols is risky, since it may remove not just debug symbols but also ELF information necessary for normal execution.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-stripAllFlags">
-     <term>
-      <varname>stripAllFlags</varname>
-     </term>
-     <listitem>
-      <para>
-       Flags passed to the <command>strip</command> command applied to the files in the directories listed in <varname>stripAllList</varname>. Defaults to <option>-s</option> (i.e. <option>--strip-all</option>).
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-stripDebugList">
-     <term>
-      <varname>stripDebugList</varname>
-     </term>
-     <listitem>
-      <para>
-       List of directories to search for libraries and executables from which only debugging-related symbols should be stripped. It defaults to <literal>lib lib32 lib64 libexec bin sbin</literal>.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-stripDebugFlags">
-     <term>
-      <varname>stripDebugFlags</varname>
-     </term>
-     <listitem>
-      <para>
-       Flags passed to the <command>strip</command> command applied to the files in the directories listed in <varname>stripDebugList</varname>. Defaults to <option>-S</option> (i.e. <option>--strip-debug</option>).
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-dontPatchELF">
-     <term>
-      <varname>dontPatchELF</varname>
-     </term>
-     <listitem>
-      <para>
-       If set, the <command>patchelf</command> command is not used to remove unnecessary <literal>RPATH</literal> entries. Only applies to Linux.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-dontPatchShebangs">
-     <term>
-      <varname>dontPatchShebangs</varname>
-     </term>
-     <listitem>
-      <para>
-       If set, scripts starting with <literal>#!</literal> do not have their interpreter paths rewritten to paths in the Nix store.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-dontPruneLibtoolFiles">
-     <term>
-      <varname>dontPruneLibtoolFiles</varname>
-     </term>
-     <listitem>
-      <para>
-       If set, libtool <literal>.la</literal> files associated with shared libraries won't have their <literal>dependency_libs</literal> field cleared.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-forceShare">
-     <term>
-      <varname>forceShare</varname>
-     </term>
-     <listitem>
-      <para>
-       The list of directories that must be moved from <filename>$out</filename> to <filename>$out/share</filename>. Defaults to <literal>man doc info</literal>.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-setupHook">
-     <term>
-      <varname>setupHook</varname>
-     </term>
-     <listitem>
-      <para>
-       A package can export a <link linkend="ssec-setup-hooks">setup hook</link> by setting this variable. The setup hook, if defined, is copied to <filename>$out/nix-support/setup-hook</filename>. Environment variables are then substituted in it using <function
-       linkend="fun-substituteAll">substituteAll</function>.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-preFixup">
-     <term>
-      <varname>preFixup</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the start of the fixup phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-postFixup">
-     <term>
-      <varname>postFixup</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the end of the fixup phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="stdenv-separateDebugInfo">
-     <term>
-      <varname>separateDebugInfo</varname>
-     </term>
-     <listitem>
-      <para>
-       If set to <literal>true</literal>, the standard environment will enable debug information in C/C++ builds. After installation, the debug information will be separated from the executables and stored in the output named <literal>debug</literal>. (This output is enabled automatically; you don’t need to set the <varname>outputs</varname> attribute explicitly.) To be precise, the debug information is stored in <filename><replaceable>debug</replaceable>/lib/debug/.build-id/<replaceable>XX</replaceable>/<replaceable>YYYY…</replaceable></filename>, where <replaceable>XXYYYY…</replaceable> is the <replaceable>build ID</replaceable> of the binary — a SHA-1 hash of the contents of the binary. Debuggers like GDB use the build ID to look up the separated debug information.
-      </para>
-      <para>
-       For example, with GDB, you can add
-<programlisting>
-set debug-file-directory ~/.nix-profile/lib/debug
-</programlisting>
-       to <filename>~/.gdbinit</filename>. GDB will then be able to find debug information installed via <literal>nix-env -i</literal>.
-      </para>
-     </listitem>
-    </varlistentry>
-   </variablelist>
-  </section>
-
-  <section xml:id="ssec-installCheck-phase">
-   <title>The installCheck phase</title>
-
-   <para>
-    The installCheck phase checks whether the package was installed correctly by running its test suite against the installed directories. The default <function>installCheck</function> calls <command>make installcheck</command>.
-   </para>
-
-   <variablelist>
-    <title>Variables controlling the installCheck phase</title>
-    <varlistentry xml:id="var-stdenv-doInstallCheck">
-     <term>
-      <varname>doInstallCheck</varname>
-     </term>
-     <listitem>
-      <para>
-       Controls whether the installCheck phase is executed. By default it is skipped, but if <varname>doInstallCheck</varname> is set to true, the installCheck phase is usually executed. Thus you should set
-<programlisting>doInstallCheck = true;</programlisting>
-       in the derivation to enable install checks. The exception is cross compilation. Cross compiled builds never run tests, no matter how <varname>doInstallCheck</varname> is set, as the newly-built program won't run on the platform used to build it.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-installCheckTarget">
-     <term>
-      <varname>installCheckTarget</varname>
-     </term>
-     <listitem>
-      <para>
-       The make target that runs the install tests. Defaults to <literal>installcheck</literal>.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-installCheckFlags">
-     <term>
-      <varname>installCheckFlags</varname> / <varname>installCheckFlagsArray</varname>
-     </term>
-     <listitem>
-      <para>
-       A list of strings passed as additional flags to <command>make</command>. Like <varname>makeFlags</varname> and <varname>makeFlagsArray</varname>, but only used by the installCheck phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-installCheckInputs">
-     <term>
-      <varname>installCheckInputs</varname>
-     </term>
-     <listitem>
-      <para>
-       A list of dependencies used by the phase. This gets included in <varname>nativeBuildInputs</varname> when <varname>doInstallCheck</varname> is set.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-preInstallCheck">
-     <term>
-      <varname>preInstallCheck</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the start of the installCheck phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-postInstallCheck">
-     <term>
-      <varname>postInstallCheck</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the end of the installCheck phase.
-      </para>
-     </listitem>
-    </varlistentry>
-   </variablelist>
-  </section>
-
-  <section xml:id="ssec-distribution-phase">
-   <title>The distribution phase</title>
-
-   <para>
-    The distribution phase is intended to produce a source distribution of the package. The default <function>distPhase</function> first calls <command>make dist</command>, then it copies the resulting source tarballs to <filename>$out/tarballs/</filename>. This phase is only executed if the attribute <varname>doDist</varname> is set.
-   </para>
-
-   <variablelist>
-    <title>Variables controlling the distribution phase</title>
-    <varlistentry xml:id="var-stdenv-distTarget">
-     <term>
-      <varname>distTarget</varname>
-     </term>
-     <listitem>
-      <para>
-       The make target that produces the distribution. Defaults to <literal>dist</literal>.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-distFlags">
-     <term>
-      <varname>distFlags</varname> / <varname>distFlagsArray</varname>
-     </term>
-     <listitem>
-      <para>
-       Additional flags passed to <command>make</command>.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-tarballs">
-     <term>
-      <varname>tarballs</varname>
-     </term>
-     <listitem>
-      <para>
-       The names of the source distribution files to be copied to <filename>$out/tarballs/</filename>. It can contain shell wildcards. The default is <filename>*.tar.gz</filename>.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-dontCopyDist">
-     <term>
-      <varname>dontCopyDist</varname>
-     </term>
-     <listitem>
-      <para>
-       If set, no files are copied to <filename>$out/tarballs/</filename>.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-preDist">
-     <term>
-      <varname>preDist</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the start of the distribution phase.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="var-stdenv-postDist">
-     <term>
-      <varname>postDist</varname>
-     </term>
-     <listitem>
-      <para>
-       Hook executed at the end of the distribution phase.
-      </para>
-     </listitem>
-    </varlistentry>
-   </variablelist>
-  </section>
- </section>
- <section xml:id="ssec-stdenv-functions">
-  <title>Shell functions</title>
-
-  <para>
-   The standard environment provides a number of useful functions.
-  </para>
-
-  <variablelist>
-   <varlistentry xml:id='fun-makeWrapper'>
-    <term>
-     <function>makeWrapper</function> <replaceable>executable</replaceable> <replaceable>wrapperfile</replaceable> <replaceable>args</replaceable>
-    </term>
-    <listitem>
-     <para>
-      Constructs a wrapper for a program with various possible arguments. For example:
-<programlisting>
-# adds `FOOBAR=baz` to `$out/bin/foo`’s environment
-makeWrapper $out/bin/foo $wrapperfile --set FOOBAR baz
-
-# prefixes the binary paths of `hello` and `git`
-# Be advised that paths often should be patched in directly
-# (via string replacements or in `configurePhase`).
-makeWrapper $out/bin/foo $wrapperfile --prefix PATH : ${lib.makeBinPath [ hello git ]}
-</programlisting>
-      There’s many more kinds of arguments, they are documented in <literal>nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh</literal>.
-     </para>
-     <para>
-      <literal>wrapProgram</literal> is a convenience function you probably want to use most of the time.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id='fun-substitute'>
-    <term>
-     <function>substitute</function> <replaceable>infile</replaceable> <replaceable>outfile</replaceable> <replaceable>subs</replaceable>
-    </term>
-    <listitem>
-     <para>
-      Performs string substitution on the contents of <replaceable>infile</replaceable>, writing the result to <replaceable>outfile</replaceable>. The substitutions in <replaceable>subs</replaceable> are of the following form:
-      <variablelist>
-       <varlistentry>
-        <term>
-         <option>--replace</option> <replaceable>s1</replaceable> <replaceable>s2</replaceable>
-        </term>
-        <listitem>
-         <para>
-          Replace every occurrence of the string <replaceable>s1</replaceable> by <replaceable>s2</replaceable>.
-         </para>
-        </listitem>
-       </varlistentry>
-       <varlistentry>
-        <term>
-         <option>--subst-var</option> <replaceable>varName</replaceable>
-        </term>
-        <listitem>
-         <para>
-          Replace every occurrence of <literal>@<replaceable>varName</replaceable>@</literal> by the contents of the environment variable <replaceable>varName</replaceable>. This is useful for generating files from templates, using <literal>@<replaceable>...</replaceable>@</literal> in the template as placeholders.
-         </para>
-        </listitem>
-       </varlistentry>
-       <varlistentry>
-        <term>
-         <option>--subst-var-by</option> <replaceable>varName</replaceable> <replaceable>s</replaceable>
-        </term>
-        <listitem>
-         <para>
-          Replace every occurrence of <literal>@<replaceable>varName</replaceable>@</literal> by the string <replaceable>s</replaceable>.
-         </para>
-        </listitem>
-       </varlistentry>
-      </variablelist>
-     </para>
-     <para>
-      Example:
-<programlisting>
-substitute ./foo.in ./foo.out \
-    --replace /usr/bin/bar $bar/bin/bar \
-    --replace "a string containing spaces" "some other text" \
-    --subst-var someVar
-</programlisting>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id='fun-substituteInPlace'>
-    <term>
-     <function>substituteInPlace</function> <replaceable>file</replaceable> <replaceable>subs</replaceable>
-    </term>
-    <listitem>
-     <para>
-      Like <function>substitute</function>, but performs the substitutions in place on the file <replaceable>file</replaceable>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id='fun-substituteAll'>
-    <term>
-     <function>substituteAll</function> <replaceable>infile</replaceable> <replaceable>outfile</replaceable>
-    </term>
-    <listitem>
-     <para>
-      Replaces every occurrence of <literal>@<replaceable>varName</replaceable>@</literal>, where <replaceable>varName</replaceable> is any environment variable, in <replaceable>infile</replaceable>, writing the result to <replaceable>outfile</replaceable>. For instance, if <replaceable>infile</replaceable> has the contents
-<programlisting>
-#! @bash@/bin/sh
-PATH=@coreutils@/bin
-echo @foo@
-</programlisting>
-      and the environment contains <literal>bash=/nix/store/bmwp0q28cf21...-bash-3.2-p39</literal> and <literal>coreutils=/nix/store/68afga4khv0w...-coreutils-6.12</literal>, but does not contain the variable <varname>foo</varname>, then the output will be
-<programlisting>
-#! /nix/store/bmwp0q28cf21...-bash-3.2-p39/bin/sh
-PATH=/nix/store/68afga4khv0w...-coreutils-6.12/bin
-echo @foo@
-</programlisting>
-      That is, no substitution is performed for undefined variables.
-     </para>
-     <para>
-      Environment variables that start with an uppercase letter or an underscore are filtered out, to prevent global variables (like <literal>HOME</literal>) or private variables (like <literal>__ETC_PROFILE_DONE</literal>) from accidentally getting substituted. The variables also have to be valid bash “names”, as defined in the bash manpage (alphanumeric or <literal>_</literal>, must not start with a number).
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id='fun-substituteAllInPlace'>
-    <term>
-     <function>substituteAllInPlace</function> <replaceable>file</replaceable>
-    </term>
-    <listitem>
-     <para>
-      Like <function>substituteAll</function>, but performs the substitutions in place on the file <replaceable>file</replaceable>.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id='fun-stripHash'>
-    <term>
-     <function>stripHash</function> <replaceable>path</replaceable>
-    </term>
-    <listitem>
-     <para>
-      Strips the directory and hash part of a store path, outputting the name part to <literal>stdout</literal>. For example:
-<programlisting>
-# prints coreutils-8.24
-stripHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
-</programlisting>
-      If you wish to store the result in another variable, then the following idiom may be useful:
-<programlisting>
-name="/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24"
-someVar=$(stripHash $name)
-</programlisting>
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry xml:id='fun-wrapProgram'>
-    <term>
-     <function>wrapProgram</function> <replaceable>executable</replaceable> <replaceable>makeWrapperArgs</replaceable>
-    </term>
-    <listitem>
-     <para>
-      Convenience function for <literal>makeWrapper</literal> that automatically creates a sane wrapper file. It takes all the same arguments as <literal>makeWrapper</literal>, except for <literal>--argv0</literal>.
-     </para>
-     <para>
-      It cannot be applied multiple times, since it will overwrite the wrapper file.
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
- </section>
- <section xml:id="ssec-setup-hooks">
-  <title>Package setup hooks</title>
-
-  <para>
-   Nix itself considers a build-time dependency as merely something that should previously be built and accessible at build time—packages themselves are on their own to perform any additional setup. In most cases, that is fine, and the downstream derivation can deal with its own dependencies. But for a few common tasks, that would result in almost every package doing the same sort of setup work—depending not on the package itself, but entirely on which dependencies were used.
-  </para>
-
-  <para>
-   In order to alleviate this burden, the <firstterm>setup hook</firstterm> mechanism was written, where any package can include a shell script that [by convention rather than enforcement by Nix], any downstream reverse-dependency will source as part of its build process. That allows the downstream dependency to merely specify its dependencies, and lets those dependencies effectively initialize themselves. No boilerplate mirroring the list of dependencies is needed.
-  </para>
-
-  <para>
-   The setup hook mechanism is a bit of a sledgehammer though: a powerful feature with a broad and indiscriminate area of effect. The combination of its power and implicit use may be expedient, but isn't without costs. Nix itself is unchanged, but the spirit of added dependencies being effect-free is violated even if the letter isn't. For example, if a derivation path is mentioned more than once, Nix itself doesn't care and simply makes sure the dependency derivation is already built just the same—depending is just needing something to exist, and needing is idempotent. However, a dependency specified twice will have its setup hook run twice, and that could easily change the build environment (though a well-written setup hook will therefore strive to be idempotent so this is in fact not observable). More broadly, setup hooks are anti-modular in that multiple dependencies, whether the same or different, should not interfere and yet their setup hooks may well do so.
-  </para>
-
-  <para>
-   The most typical use of the setup hook is actually to add other hooks which are then run (i.e. after all the setup hooks) on each dependency. For example, the C compiler wrapper's setup hook feeds itself flags for each dependency that contains relevant libraries and headers. This is done by defining a bash function, and appending its name to one of <envar>envBuildBuildHooks</envar>, <envar>envBuildHostHooks</envar>, <envar>envBuildTargetHooks</envar>, <envar>envHostHostHooks</envar>, <envar>envHostTargetHooks</envar>, or <envar>envTargetTargetHooks</envar>. These 6 bash variables correspond to the 6 sorts of dependencies by platform (there's 12 total but we ignore the propagated/non-propagated axis).
-  </para>
-
-  <para>
-   Packages adding a hook should not hard code a specific hook, but rather choose a variable <emphasis>relative</emphasis> to how they are included. Returning to the C compiler wrapper example, if the wrapper itself is an <literal>n</literal> dependency, then it only wants to accumulate flags from <literal>n + 1</literal> dependencies, as only those ones match the compiler's target platform. The <envar>hostOffset</envar> variable is defined with the current dependency's host offset <envar>targetOffset</envar> with its target offset, before its setup hook is sourced. Additionally, since most environment hooks don't care about the target platform, that means the setup hook can append to the right bash array by doing something like
-<programlisting language="bash">
-addEnvHooks "$hostOffset" myBashFunction
-</programlisting>
-  </para>
-
-  <para>
-   The <emphasis>existence</emphasis> of setups hooks has long been documented and packages inside Nixpkgs are free to use this mechanism. Other packages, however, should not rely on these mechanisms not changing between Nixpkgs versions. Because of the existing issues with this system, there's little benefit from mandating it be stable for any period of time.
-  </para>
-
-  <para>
-   First, let’s cover some setup hooks that are part of Nixpkgs default stdenv. This means that they are run for every package built using <function>stdenv.mkDerivation</function>. Some of these are platform specific, so they may run on Linux but not Darwin or vice-versa.
-   <variablelist>
-    <varlistentry>
-     <term>
-      <literal>move-docs.sh</literal>
-     </term>
-     <listitem>
-      <para>
-       This setup hook moves any installed documentation to the <literal>/share</literal> subdirectory directory. This includes the man, doc and info directories. This is needed for legacy programs that do not know how to use the <literal>share</literal> subdirectory.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <literal>compress-man-pages.sh</literal>
-     </term>
-     <listitem>
-      <para>
-       This setup hook compresses any man pages that have been installed. The compression is done using the gzip program. This helps to reduce the installed size of packages.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <literal>strip.sh</literal>
-     </term>
-     <listitem>
-      <para>
-       This runs the strip command on installed binaries and libraries. This removes unnecessary information like debug symbols when they are not needed. This also helps to reduce the installed size of packages.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <literal>patch-shebangs.sh</literal>
-     </term>
-     <listitem>
-      <para>
-       This setup hook patches installed scripts to use the full path to the shebang interpreter. A shebang interpreter is the first commented line of a script telling the operating system which program will run the script (e.g <literal>#!/bin/bash</literal>). In Nix, we want an exact path to that interpreter to be used. This often replaces <literal>/bin/sh</literal> with a path in the Nix store.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <literal>audit-tmpdir.sh</literal>
-     </term>
-     <listitem>
-      <para>
-       This verifies that no references are left from the install binaries to the directory used to build those binaries. This ensures that the binaries do not need things outside the Nix store. This is currently supported in Linux only.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <literal>multiple-outputs.sh</literal>
-     </term>
-     <listitem>
-      <para>
-       This setup hook adds configure flags that tell packages to install files into any one of the proper outputs listed in <literal>outputs</literal>. This behavior can be turned off by setting <literal>setOutputFlags</literal> to false in the derivation environment. See <xref linkend="chap-multiple-output"/> for more information.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <literal>move-sbin.sh</literal>
-     </term>
-     <listitem>
-      <para>
-       This setup hook moves any binaries installed in the sbin subdirectory into bin. In addition, a link is provided from sbin to bin for compatibility.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <literal>move-lib64.sh</literal>
-     </term>
-     <listitem>
-      <para>
-       This setup hook moves any libraries installed in the lib64 subdirectory into lib. In addition, a link is provided from lib64 to lib for compatibility.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <literal>move-systemd-user-units.sh</literal>
-     </term>
-     <listitem>
-      <para>
-       This setup hook moves any systemd user units installed in the lib
-       subdirectory into share. In addition, a link is provided from share to
-       lib for compatibility. This is needed for systemd to find user services
-       when installed into the user profile.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      <literal>set-source-date-epoch-to-latest.sh</literal>
-     </term>
-     <listitem>
-      <para>
-       This sets <literal>SOURCE_DATE_EPOCH</literal> to the modification time of the most recent file.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      Bintools Wrapper
-     </term>
-     <listitem>
-      <para>
-       The Bintools Wrapper wraps the binary utilities for a bunch of miscellaneous purposes. These are GNU Binutils when targetting Linux, and a mix of cctools and GNU binutils for Darwin. [The "Bintools" name is supposed to be a compromise between "Binutils" and "cctools" not denoting any specific implementation.] Specifically, the underlying bintools package, and a C standard library (glibc or Darwin's libSystem, just for the dynamic loader) are all fed in, and dependency finding, hardening (see below), and purity checks for each are handled by the Bintools Wrapper. Packages typically depend on CC Wrapper, which in turn (at run time) depends on the Bintools Wrapper.
-      </para>
-      <para>
-       The Bintools Wrapper was only just recently split off from CC Wrapper, so the division of labor is still being worked out. For example, it shouldn't care about the C standard library, but just take a derivation with the dynamic loader (which happens to be the glibc on linux). Dependency finding however is a task both wrappers will continue to need to share, and probably the most important to understand. It is currently accomplished by collecting directories of host-platform dependencies (i.e. <varname>buildInputs</varname> and <varname>nativeBuildInputs</varname>) in environment variables. The Bintools Wrapper's setup hook causes any <filename>lib</filename> and <filename>lib64</filename> subdirectories to be added to <envar>NIX_LDFLAGS</envar>. Since the CC Wrapper and the Bintools Wrapper use the same strategy, most of the Bintools Wrapper code is sparsely commented and refers to the CC Wrapper. But the CC Wrapper's code, by contrast, has quite lengthy comments. The Bintools Wrapper merely cites those, rather than repeating them, to avoid falling out of sync.
-      </para>
-      <para>
-       A final task of the setup hook is defining a number of standard environment variables to tell build systems which executables fulfill which purpose. They are defined to just be the base name of the tools, under the assumption that the Bintools Wrapper's binaries will be on the path. Firstly, this helps poorly-written packages, e.g. ones that look for just <command>gcc</command> when <envar>CC</envar> isn't defined yet <command>clang</command> is to be used. Secondly, this helps packages not get confused when cross-compiling, in which case multiple Bintools Wrappers may simultaneously be in use.
-       <footnote xml:id="footnote-stdenv-per-platform-wrapper">
-        <para>
-         Each wrapper targets a single platform, so if binaries for multiple platforms are needed, the underlying binaries must be wrapped multiple times. As this is a property of the wrapper itself, the multiple wrappings are needed whether or not the same underlying binaries can target multiple platforms.
-        </para>
-       </footnote>
-       <envar>BUILD_</envar>- and <envar>TARGET_</envar>-prefixed versions of the normal environment variable are defined for additional Bintools Wrappers, properly disambiguating them.
-      </para>
-      <para>
-       A problem with this final task is that the Bintools Wrapper is honest and defines <envar>LD</envar> as <command>ld</command>. Most packages, however, firstly use the C compiler for linking, secondly use <envar>LD</envar> anyways, defining it as the C compiler, and thirdly, only so define <envar>LD</envar> when it is undefined as a fallback. This triple-threat means Bintools Wrapper will break those packages, as LD is already defined as the actual linker which the package won't override yet doesn't want to use. The workaround is to define, just for the problematic package, <envar>LD</envar> as the C compiler. A good way to do this would be <command>preConfigure = "LD=$CC"</command>.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      CC Wrapper
-     </term>
-     <listitem>
-      <para>
-       The CC Wrapper wraps a C toolchain for a bunch of miscellaneous purposes. Specifically, a C compiler (GCC or Clang), wrapped binary tools, and a C standard library (glibc or Darwin's libSystem, just for the dynamic loader) are all fed in, and dependency finding, hardening (see below), and purity checks for each are handled by the CC Wrapper. Packages typically depend on the CC Wrapper, which in turn (at run-time) depends on the Bintools Wrapper.
-      </para>
-      <para>
-       Dependency finding is undoubtedly the main task of the CC Wrapper. This works just like the Bintools Wrapper, except that any <filename>include</filename> subdirectory of any relevant dependency is added to <envar>NIX_CFLAGS_COMPILE</envar>. The setup hook itself contains some lengthy comments describing the exact convoluted mechanism by which this is accomplished.
-      </para>
-      <para>
-       Similarly, the CC Wrapper follows the Bintools Wrapper in defining standard environment variables with the names of the tools it wraps, for the same reasons described above. Importantly, while it includes a <command>cc</command> symlink to the c compiler for portability, the <envar>CC</envar> will be defined using the compiler's "real name" (i.e. <command>gcc</command> or <command>clang</command>). This helps lousy build systems that inspect on the name of the compiler rather than run it.
-      </para>
-     </listitem>
-    </varlistentry>
-   </variablelist>
-  </para>
-
-  <para>
-   Here are some more packages that provide a setup hook. Since the list of hooks is extensible, this is not an exhaustive list. The mechanism is only to be used as a last resort, so it might cover most uses.
-   <variablelist>
-    <varlistentry>
-     <term>
-      Perl
-     </term>
-     <listitem>
-      <para>
-       Adds the <filename>lib/site_perl</filename> subdirectory of each build input to the <envar>PERL5LIB</envar> environment variable. For instance, if <varname>buildInputs</varname> contains Perl, then the <filename>lib/site_perl</filename> subdirectory of each input is added to the <envar>PERL5LIB</envar> environment variable.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      Python
-     </term>
-     <listitem>
-      <para>
-       Adds the <filename>lib/${python.libPrefix}/site-packages</filename> subdirectory of each build input to the <envar>PYTHONPATH</envar> environment variable.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      pkg-config
-     </term>
-     <listitem>
-      <para>
-       Adds the <filename>lib/pkgconfig</filename> and <filename>share/pkgconfig</filename> subdirectories of each build input to the <envar>PKG_CONFIG_PATH</envar> environment variable.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      Automake
-     </term>
-     <listitem>
-      <para>
-       Adds the <filename>share/aclocal</filename> subdirectory of each build input to the <envar>ACLOCAL_PATH</envar> environment variable.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      Autoconf
-     </term>
-     <listitem>
-      <para>
-       The <varname>autoreconfHook</varname> derivation adds <varname>autoreconfPhase</varname>, which runs autoreconf, libtoolize and automake, essentially preparing the configure script in autotools-based builds. Most autotools-based packages come with the configure script pre-generated, but this hook is necessary for a few packages and when you need to patch the package’s configure scripts.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      libxml2
-     </term>
-     <listitem>
-      <para>
-       Adds every file named <filename>catalog.xml</filename> found under the <filename>xml/dtd</filename> and <filename>xml/xsl</filename> subdirectories of each build input to the <envar>XML_CATALOG_FILES</envar> environment variable.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      teTeX / TeX Live
-     </term>
-     <listitem>
-      <para>
-       Adds the <filename>share/texmf-nix</filename> subdirectory of each build input to the <envar>TEXINPUTS</envar> environment variable.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      Qt 4
-     </term>
-     <listitem>
-      <para>
-       Sets the <envar>QTDIR</envar> environment variable to Qt’s path.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      gdk-pixbuf
-     </term>
-     <listitem>
-      <para>
-       Exports <envar>GDK_PIXBUF_MODULE_FILE</envar> environment variable to the builder. Add librsvg package to <varname>buildInputs</varname> to get svg support. See also the <link linkend="ssec-gnome-hooks-gdk-pixbuf">setup hook description in GNOME platform docs</link>.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      GHC
-     </term>
-     <listitem>
-      <para>
-       Creates a temporary package database and registers every Haskell build input in it (TODO: how?).
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      GNOME platform
-     </term>
-     <listitem>
-      <para>
-       Hooks related to GNOME platform and related libraries like GLib, GTK and GStreamer are described in <xref linkend="sec-language-gnome" />.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry xml:id="setup-hook-autopatchelfhook">
-     <term>
-      autoPatchelfHook
-     </term>
-     <listitem>
-      <para>
-       This is a special setup hook which helps in packaging proprietary software in that it automatically tries to find missing shared library dependencies of ELF files based on the given <varname>buildInputs</varname> and <varname>nativeBuildInputs</varname>.
-      </para>
-      <para>
-       You can also specify a <varname>runtimeDependencies</varname> variable which lists dependencies to be unconditionally added to <glossterm>rpath</glossterm> of all executables.
-       This is useful for programs that use <citerefentry>
-       <refentrytitle>dlopen</refentrytitle>
-       <manvolnum>3</manvolnum> </citerefentry> to load libraries at runtime.
-      </para>
-      <para>
-       In certain situations you may want to run the main command (<command>autoPatchelf</command>) of the setup hook on a file or a set of directories instead of unconditionally patching all outputs. This can be done by setting the <varname>dontAutoPatchelf</varname> environment variable to a non-empty value.
-      </para>
-      <para>
-       By default <command>autoPatchelf</command> will fail as soon as any ELF file requires a dependency which cannot be resolved via the given build inputs. In some situations you might prefer to just leave missing dependencies unpatched and continue to patch the rest. This can be achieved by setting the <envar>autoPatchelfIgnoreMissingDeps</envar> environment variable to a non-empty value.
-      </para>
-      <para>
-       The <command>autoPatchelf</command> command also recognizes a <parameter class="command">--no-recurse</parameter> command line flag, which prevents it from recursing into subdirectories.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      breakpointHook
-     </term>
-     <listitem>
-      <para>
-       This hook will make a build pause instead of stopping when a failure happens. It prevents nix from cleaning up the build environment immediately and allows the user to attach to a build environment using the <command>cntr</command> command. Upon build error it will print instructions on how to use <command>cntr</command>, which can be used to enter the environment for debugging. Installing cntr and running the command will provide shell access to the build sandbox of failed build. At <filename>/var/lib/cntr</filename> the sandboxed filesystem is mounted. All commands and files of the system are still accessible within the shell. To execute commands from the sandbox use the cntr exec subcommand. <command>cntr</command> is only supported on Linux-based platforms. To use it first add <literal>cntr</literal> to your <literal>environment.systemPackages</literal> on NixOS or alternatively to the root user on non-NixOS systems. Then in the package that is supposed to be inspected, add <literal>breakpointHook</literal> to <literal>nativeBuildInputs</literal>.
-<programlisting>
-nativeBuildInputs = [ breakpointHook ];
-</programlisting>
-       When a build failure happens there will be an instruction printed that shows how to attach with <literal>cntr</literal> to the build sandbox.
-      </para>
-      <note>
-       <title>Caution with remote builds</title>
-       <para>
-        This won't work with remote builds as the build environment is on a different machine and can't be accessed by <command>cntr</command>. Remote builds can be turned off by setting <literal>--option builders ''</literal> for <command>nix-build</command> or <literal>--builders ''</literal> for <command>nix build</command>.
-       </para>
-      </note>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      installShellFiles
-     </term>
-     <listitem>
-      <para>
-       This hook helps with installing manpages and shell completion files. It exposes 2 shell functions <literal>installManPage</literal> and <literal>installShellCompletion</literal> that can be used from your <literal>postInstall</literal> hook.
-      </para>
-      <para>
-       The <literal>installManPage</literal> function takes one or more paths to manpages to install. The manpages must have a section suffix, and may optionally be compressed (with <literal>.gz</literal> suffix). This function will place them into the correct directory.
-      </para>
-      <para>
-       The <literal>installShellCompletion</literal> function takes one or more paths to shell completion files. By default it will autodetect the shell type from the completion file extension, but you may also specify it by passing one of <literal>--bash</literal>, <literal>--fish</literal>, or <literal>--zsh</literal>. These flags apply to all paths listed after them (up until another shell flag is given). Each path may also have a custom installation name provided by providing a flag <literal>--name NAME</literal> before the path. If this flag is not provided, zsh completions will be renamed automatically such that <literal>foobar.zsh</literal> becomes <literal>_foobar</literal>. A root name may be provided for all paths using the flag <literal>--cmd NAME</literal>; this synthesizes the appropriate name depending on the shell (e.g. <literal>--cmd foo</literal> will synthesize the name <literal>foo.bash</literal> for bash and <literal>_foo</literal> for zsh). The path may also be a fifo or named fd (such as produced by <literal>&lt;(cmd)</literal>), in which case the shell and name must be provided.
-<programlisting>
-nativeBuildInputs = [ installShellFiles ];
-postInstall = ''
-  installManPage doc/foobar.1 doc/barfoo.3
-  # explicit behavior
-  installShellCompletion --bash --name foobar.bash share/completions.bash
-  installShellCompletion --fish --name foobar.fish share/completions.fish
-  installShellCompletion --zsh --name _foobar share/completions.zsh
-  # implicit behavior
-  installShellCompletion share/completions/foobar.{bash,fish,zsh}
-  # using named fd
-  installShellCompletion --cmd foobar \
-    --bash &lt;($out/bin/foobar --bash-completion) \
-    --fish &lt;($out/bin/foobar --fish-completion) \
-    --zsh &lt;($out/bin/foobar --zsh-completion)
-'';
-</programlisting>
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      libiconv, libintl
-     </term>
-     <listitem>
-      <para>
-       A few libraries automatically add to <literal>NIX_LDFLAGS</literal> their library, making their symbols automatically available to the linker. This includes libiconv and libintl (gettext). This is done to provide compatibility between GNU Linux, where libiconv and libintl are bundled in, and other systems where that might not be the case. Sometimes, this behavior is not desired. To disable this behavior, set <literal>dontAddExtraLibs</literal>.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      validatePkgConfig
-     </term>
-     <listitem>
-      <para>
-       The <literal>validatePkgConfig</literal> hook validates all pkg-config (<filename>.pc</filename>) files in a package. This helps catching some common errors in pkg-config files, such as undefined variables.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      cmake
-     </term>
-     <listitem>
-      <para>
-       Overrides the default configure phase to run the CMake command. By default, we use the Make generator of CMake. In addition, dependencies are added automatically to CMAKE_PREFIX_PATH so that packages are correctly detected by CMake. Some additional flags are passed in to give similar behavior to configure-based packages. You can disable this hook’s behavior by setting configurePhase to a custom value, or by setting dontUseCmakeConfigure. cmakeFlags controls flags passed only to CMake. By default, parallel building is enabled as CMake supports parallel building almost everywhere. When Ninja is also in use, CMake will detect that and use the ninja generator.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      xcbuildHook
-     </term>
-     <listitem>
-      <para>
-       Overrides the build and install phases to run the “xcbuild” command. This hook is needed when a project only comes with build files for the XCode build system. You can disable this behavior by setting buildPhase and configurePhase to a custom value. xcbuildFlags controls flags passed only to xcbuild.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      Meson
-     </term>
-     <listitem>
-      <para>
-       Overrides the configure phase to run meson to generate Ninja files. To run these files, you should accompany Meson with ninja. By default, <varname>enableParallelBuilding</varname> is enabled as Meson supports parallel building almost everywhere.
-      </para>
-      <variablelist>
-       <title>Variables controlling Meson</title>
-       <varlistentry>
-        <term>
-         <varname>mesonFlags</varname>
-        </term>
-        <listitem>
-         <para>
-          Controls the flags passed to meson.
-         </para>
-        </listitem>
-       </varlistentry>
-       <varlistentry>
-        <term>
-         <varname>mesonBuildType</varname>
-        </term>
-        <listitem>
-         <para>
-          Which <link
-          xlink:href="https://mesonbuild.com/Builtin-options.html#core-options"><command>--buildtype</command></link> to pass to Meson. We default to <literal>plain</literal>.
-         </para>
-        </listitem>
-       </varlistentry>
-       <varlistentry>
-        <term>
-         <varname>mesonAutoFeatures</varname>
-        </term>
-        <listitem>
-         <para>
-          What value to set <link
-          xlink:href="https://mesonbuild.com/Builtin-options.html#core-options"><command>-Dauto_features=</command></link> to. We default to <command>enabled</command>.
-         </para>
-        </listitem>
-       </varlistentry>
-       <varlistentry>
-        <term>
-         <varname>mesonWrapMode</varname>
-        </term>
-        <listitem>
-         <para>
-          What value to set <link
-          xlink:href="https://mesonbuild.com/Builtin-options.html#core-options"><command>-Dwrap_mode=</command></link> to. We default to <command>nodownload</command> as we disallow network access.
-         </para>
-        </listitem>
-       </varlistentry>
-       <varlistentry>
-        <term>
-         <varname>dontUseMesonConfigure</varname>
-        </term>
-        <listitem>
-         <para>
-          Disables using Meson's <varname>configurePhase</varname>.
-         </para>
-        </listitem>
-       </varlistentry>
-      </variablelist>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      ninja
-     </term>
-     <listitem>
-      <para>
-       Overrides the build, install, and check phase to run ninja instead of make. You can disable this behavior with the dontUseNinjaBuild, dontUseNinjaInstall, and dontUseNinjaCheck, respectively. Parallel building is enabled by default in Ninja.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      unzip
-     </term>
-     <listitem>
-      <para>
-       This setup hook will allow you to unzip .zip files specified in $src. There are many similar packages like unrar, undmg, etc.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      wafHook
-     </term>
-     <listitem>
-      <para>
-       Overrides the configure, build, and install phases. This will run the "waf" script used by many projects. If wafPath (default ./waf) doesn’t exist, it will copy the version of waf available in Nixpkgs. wafFlags can be used to pass flags to the waf script.
-      </para>
-     </listitem>
-    </varlistentry>
-    <varlistentry>
-     <term>
-      scons
-     </term>
-     <listitem>
-      <para>
-       Overrides the build, install, and check phases. This uses the scons build system as a replacement for make. scons does not provide a configure phase, so everything is managed at build and install time.
-      </para>
-     </listitem>
-    </varlistentry>
-   </variablelist>
-  </para>
- </section>
- <section xml:id="sec-purity-in-nixpkgs">
-  <title>Purity in Nixpkgs</title>
-
-  <para>
-   [measures taken to prevent dependencies on packages outside the store, and what you can do to prevent them]
-  </para>
-
-  <para>
-   GCC doesn't search in locations such as <filename>/usr/include</filename>. In fact, attempts to add such directories through the <option>-I</option> flag are filtered out. Likewise, the linker (from GNU binutils) doesn't search in standard locations such as <filename>/usr/lib</filename>. Programs built on Linux are linked against a GNU C Library that likewise doesn't search in the default system locations.
-  </para>
- </section>
- <section xml:id="sec-hardening-in-nixpkgs">
-  <title>Hardening in Nixpkgs</title>
-
-  <para>
-   There are flags available to harden packages at compile or link-time. These can be toggled using the <varname>stdenv.mkDerivation</varname> parameters <varname>hardeningDisable</varname> and <varname>hardeningEnable</varname>.
-  </para>
-
-  <para>
-   Both parameters take a list of flags as strings. The special <varname>"all"</varname> flag can be passed to <varname>hardeningDisable</varname> to turn off all hardening. These flags can also be used as environment variables for testing or development purposes.
-  </para>
-
-  <para>
-   The following flags are enabled by default and might require disabling with <varname>hardeningDisable</varname> if the program to package is incompatible.
-  </para>
-
-  <variablelist>
-   <varlistentry>
-    <term>
-     <varname>format</varname>
-    </term>
-    <listitem>
-     <para>
-      Adds the <option>-Wformat -Wformat-security -Werror=format-security</option> compiler options. At present, this warns about calls to <varname>printf</varname> and <varname>scanf</varname> functions where the format string is not a string literal and there are no format arguments, as in <literal>printf(foo);</literal>. This may be a security hole if the format string came from untrusted input and contains <literal>%n</literal>.
-     </para>
-     <para>
-      This needs to be turned off or fixed for errors similar to:
-     </para>
-<programlisting>
-/tmp/nix-build-zynaddsubfx-2.5.2.drv-0/zynaddsubfx-2.5.2/src/UI/guimain.cpp:571:28: error: format not a string literal and no format arguments [-Werror=format-security]
-         printf(help_message);
-                            ^
-cc1plus: some warnings being treated as errors
-</programlisting>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>stackprotector</varname>
-    </term>
-    <listitem>
-     <para>
-      Adds the <option>-fstack-protector-strong --param ssp-buffer-size=4</option> compiler options. This adds safety checks against stack overwrites rendering many potential code injection attacks into aborting situations. In the best case this turns code injection vulnerabilities into denial of service or into non-issues (depending on the application).
-     </para>
-     <para>
-      This needs to be turned off or fixed for errors similar to:
-     </para>
-<programlisting>
-bin/blib.a(bios_console.o): In function `bios_handle_cup':
-/tmp/nix-build-ipxe-20141124-5cbdc41.drv-0/ipxe-5cbdc41/src/arch/i386/firmware/pcbios/bios_console.c:86: undefined reference to `__stack_chk_fail'
-</programlisting>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>fortify</varname>
-    </term>
-    <listitem>
-     <para>
-      Adds the <option>-O2 -D_FORTIFY_SOURCE=2</option> compiler options. During code generation the compiler knows a great deal of information about buffer sizes (where possible), and attempts to replace insecure unlimited length buffer function calls with length-limited ones. This is especially useful for old, crufty code. Additionally, format strings in writable memory that contain '%n' are blocked. If an application depends on such a format string, it will need to be worked around.
-     </para>
-     <para>
-      Additionally, some warnings are enabled which might trigger build failures if compiler warnings are treated as errors in the package build. In this case, set <option>NIX_CFLAGS_COMPILE</option> to <option>-Wno-error=warning-type</option>.
-     </para>
-     <para>
-      This needs to be turned off or fixed for errors similar to:
-     </para>
-<programlisting>
-malloc.c:404:15: error: return type is an incomplete type
-malloc.c:410:19: error: storage size of 'ms' isn't known
-</programlisting>
-<programlisting>
-strdup.h:22:1: error: expected identifier or '(' before '__extension__'
-</programlisting>
-<programlisting>
-strsep.c:65:23: error: register name not specified for 'delim'
-</programlisting>
-<programlisting>
-installwatch.c:3751:5: error: conflicting types for '__open_2'
-</programlisting>
-<programlisting>
-fcntl2.h:50:4: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments
-</programlisting>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>pic</varname>
-    </term>
-    <listitem>
-     <para>
-      Adds the <option>-fPIC</option> compiler options. This options adds support for position independent code in shared libraries and thus making ASLR possible.
-     </para>
-     <para>
-      Most notably, the Linux kernel, kernel modules and other code not running in an operating system environment like boot loaders won't build with PIC enabled. The compiler will is most cases complain that PIC is not supported for a specific build.
-     </para>
-     <para>
-      This needs to be turned off or fixed for assembler errors similar to:
-     </para>
-<programlisting>
-ccbLfRgg.s: Assembler messages:
-ccbLfRgg.s:33: Error: missing or invalid displacement expression `private_key_len@GOTOFF'
-</programlisting>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>strictoverflow</varname>
-    </term>
-    <listitem>
-     <para>
-      Signed integer overflow is undefined behaviour according to the C standard. If it happens, it is an error in the program as it should check for overflow before it can happen, not afterwards. GCC provides built-in functions to perform arithmetic with overflow checking, which are correct and faster than any custom implementation. As a workaround, the option <option>-fno-strict-overflow</option> makes gcc behave as if signed integer overflows were defined.
-     </para>
-     <para>
-      This flag should not trigger any build or runtime errors.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>relro</varname>
-    </term>
-    <listitem>
-     <para>
-      Adds the <option>-z relro</option> linker option. During program load, several ELF memory sections need to be written to by the linker, but can be turned read-only before turning over control to the program. This prevents some GOT (and .dtors) overwrite attacks, but at least the part of the GOT used by the dynamic linker (.got.plt) is still vulnerable.
-     </para>
-     <para>
-      This flag can break dynamic shared object loading. For instance, the module systems of Xorg and OpenCV are incompatible with this flag. In almost all cases the <varname>bindnow</varname> flag must also be disabled and incompatible programs typically fail with similar errors at runtime.
-     </para>
-    </listitem>
-   </varlistentry>
-   <varlistentry>
-    <term>
-     <varname>bindnow</varname>
-    </term>
-    <listitem>
-     <para>
-      Adds the <option>-z bindnow</option> linker option. During program load, all dynamic symbols are resolved, allowing for the complete GOT to be marked read-only (due to <varname>relro</varname>). This prevents GOT overwrite attacks. For very large applications, this can incur some performance loss during initial load while symbols are resolved, but this shouldn't be an issue for daemons.
-     </para>
-     <para>
-      This flag can break dynamic shared object loading. For instance, the module systems of Xorg and PHP are incompatible with this flag. Programs incompatible with this flag often fail at runtime due to missing symbols, like:
-     </para>
-<programlisting>
-intel_drv.so: undefined symbol: vgaHWFreeHWRec
-</programlisting>
-    </listitem>
-   </varlistentry>
-  </variablelist>
-
-  <para>
-   The following flags are disabled by default and should be enabled with <varname>hardeningEnable</varname> for packages that take untrusted input like network services.
-  </para>
-
-  <variablelist>
-   <varlistentry>
-    <term>
-     <varname>pie</varname>
-    </term>
-    <listitem>
-     <para>
-      Adds the <option>-fPIE</option> compiler and <option>-pie</option> linker options. Position Independent Executables are needed to take advantage of Address Space Layout Randomization, supported by modern kernel versions. While ASLR can already be enforced for data areas in the stack and heap (brk and mmap), the code areas must be compiled as position-independent. Shared libraries already do this with the <varname>pic</varname> flag, so they gain ASLR automatically, but binary .text regions need to be build with <varname>pie</varname> to gain ASLR. When this happens, ROP attacks are much harder since there are no static locations to bounce off of during a memory corruption attack.
-     </para>
-    </listitem>
-   </varlistentry>
-  </variablelist>
-
-  <para>
-   For more in-depth information on these hardening flags and hardening in general, refer to the <link xlink:href="https://wiki.debian.org/Hardening">Debian Wiki</link>, <link xlink:href="https://wiki.ubuntu.com/Security/Features">Ubuntu Wiki</link>, <link xlink:href="https://wiki.gentoo.org/wiki/Project:Hardened">Gentoo Wiki</link>, and the <link xlink:href="https://wiki.archlinux.org/index.php/DeveloperWiki:Security"> Arch Wiki</link>.
-  </para>
- </section>
-</chapter>
diff --git a/nixpkgs/doc/using/configuration.xml b/nixpkgs/doc/using/configuration.xml
index 2cd2615f54ae..3ef39733458c 100644
--- a/nixpkgs/doc/using/configuration.xml
+++ b/nixpkgs/doc/using/configuration.xml
@@ -151,26 +151,26 @@
    </listitem>
    <listitem>
     <para>
-     It is also possible to whitelist and blacklist licenses that are specifically acceptable or not acceptable, using <literal>whitelistedLicenses</literal> and <literal>blacklistedLicenses</literal>, respectively.
+     It is also possible to allow and block licenses that are specifically acceptable or not acceptable, using <literal>allowlistedLicenses</literal> and <literal>blocklistedLicenses</literal>, respectively.
     </para>
     <para>
-     The following example configuration whitelists the licenses <literal>amd</literal> and <literal>wtfpl</literal>:
+     The following example configuration allowlists the licenses <literal>amd</literal> and <literal>wtfpl</literal>:
 <programlisting>
 {
-  whitelistedLicenses = with lib.licenses; [ amd wtfpl ];
+  allowlistedLicenses = with lib.licenses; [ amd wtfpl ];
 }
 </programlisting>
     </para>
     <para>
-     The following example configuration blacklists the <literal>gpl3Only</literal> and <literal>agpl3Only</literal> licenses:
+     The following example configuration blocklists the <literal>gpl3Only</literal> and <literal>agpl3Only</literal> licenses:
 <programlisting>
 {
-  blacklistedLicenses = with lib.licenses; [ agpl3Only gpl3Only ];
+  blocklistedLicenses = with lib.licenses; [ agpl3Only gpl3Only ];
 }
 </programlisting>
     </para>
     <para>
-      Note that <literal>whitelistedLicenses</literal> only applies to unfree licenses unless <literal>allowUnfree</literal> is enabled. It is not a generic whitelist for all types of licenses. <literal>blacklistedLicenses</literal> applies to all licenses.
+     Note that <literal>allowlistedLicenses</literal> only applies to unfree licenses unless <literal>allowUnfree</literal> is enabled. It is not a generic allowlist for all types of licenses. <literal>blocklistedLicenses</literal> applies to all licenses.
     </para>
    </listitem>
   </itemizedlist>
diff --git a/nixpkgs/doc/using/overlays.xml b/nixpkgs/doc/using/overlays.xml
index 8bda235d43d8..8f12aad2adad 100644
--- a/nixpkgs/doc/using/overlays.xml
+++ b/nixpkgs/doc/using/overlays.xml
@@ -28,8 +28,7 @@
    </para>
 
    <para>
-    NOTE: DO NOT USE THIS in nixpkgs.
-    Further overlays can be added by calling the <literal>pkgs.extend</literal> or <literal>pkgs.appendOverlays</literal>, although it is often preferable to avoid these functions, because they recompute the Nixpkgs fixpoint, which is somewhat expensive to do.
+    NOTE: DO NOT USE THIS in nixpkgs. Further overlays can be added by calling the <literal>pkgs.extend</literal> or <literal>pkgs.appendOverlays</literal>, although it is often preferable to avoid these functions, because they recompute the Nixpkgs fixpoint, which is somewhat expensive to do.
    </para>
   </section>
 
@@ -139,98 +138,72 @@ self: super:
   </para>
  </section>
  <section xml:id="sec-overlays-alternatives">
-   <title>Using overlays to configure alternatives</title>
+  <title>Using overlays to configure alternatives</title>
+
+  <para>
+   Certain software packages have different implementations of the same interface. Other distributions have functionality to switch between these. For example, Debian provides <link
+     xlink:href="https://wiki.debian.org/DebianAlternatives">DebianAlternatives</link>. Nixpkgs has what we call <literal>alternatives</literal>, which are configured through overlays.
+  </para>
+
+  <section xml:id="sec-overlays-alternatives-blas-lapack">
+   <title>BLAS/LAPACK</title>
+
    <para>
-     Certain software packages have different implementations of the
-     same interface. Other distributions have functionality to switch
-     between these. For example, Debian provides <link
-     xlink:href="https://wiki.debian.org/DebianAlternatives">DebianAlternatives</link>.
-     Nixpkgs has what we call <literal>alternatives</literal>, which
-     are configured through overlays.
+    In Nixpkgs, we have multiple implementations of the BLAS/LAPACK numerical linear algebra interfaces. They are:
    </para>
-   <section xml:id="sec-overlays-alternatives-blas-lapack">
-     <title>BLAS/LAPACK</title>
+
+   <itemizedlist>
+    <listitem>
      <para>
-       In Nixpkgs, we have multiple implementations of the BLAS/LAPACK
-       numerical linear algebra interfaces. They are:
+      <link xlink:href="https://www.openblas.net/">OpenBLAS</link>
      </para>
-     <itemizedlist>
-       <listitem>
-         <para>
-           <link xlink:href="https://www.openblas.net/">OpenBLAS</link>
-         </para>
-         <para>
-           The Nixpkgs attribute is <literal>openblas</literal> for
-           ILP64 (integer width = 64 bits) and
-           <literal>openblasCompat</literal> for LP64 (integer width =
-           32 bits). <literal>openblasCompat</literal> is the default.
-         </para>
-       </listitem>
-       <listitem>
-         <para>
-           <link xlink:href="http://www.netlib.org/lapack/">LAPACK
-           reference</link> (also provides BLAS)
-         </para>
-         <para>
-           The Nixpkgs attribute is <literal>lapack-reference</literal>.
-         </para>
-       </listitem>
-       <listitem>
-         <para>
-           <link
-           xlink:href="https://software.intel.com/en-us/mkl">Intel
-           MKL</link> (only works on the x86_64 architecture, unfree)
-         </para>
-         <para>
-           The Nixpkgs attribute is <literal>mkl</literal>.
-         </para>
-       </listitem>
-       <listitem>
-         <para>
-           <link
+     <para>
+      The Nixpkgs attribute is <literal>openblas</literal> for ILP64 (integer width = 64 bits) and <literal>openblasCompat</literal> for LP64 (integer width = 32 bits). <literal>openblasCompat</literal> is the default.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+      <link xlink:href="http://www.netlib.org/lapack/">LAPACK reference</link> (also provides BLAS)
+     </para>
+     <para>
+      The Nixpkgs attribute is <literal>lapack-reference</literal>.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+      <link
+           xlink:href="https://software.intel.com/en-us/mkl">Intel MKL</link> (only works on the x86_64 architecture, unfree)
+     </para>
+     <para>
+      The Nixpkgs attribute is <literal>mkl</literal>.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+      <link
            xlink:href="https://github.com/flame/blis">BLIS</link>
-         </para>
-         <para>
-          BLIS, available through the attribute
-          <literal>blis</literal>, is a framework for linear algebra kernels. In
-          addition, it implements the BLAS interface.
-         </para>
-       </listitem>
-       <listitem>
-         <para>
-          <link
-           xlink:href="https://developer.amd.com/amd-aocl/blas-library/">AMD
-          BLIS/LIBFLAME</link> (optimized for modern AMD x86_64 CPUs)
-         </para>
-         <para>
-          The AMD fork of the BLIS library, with attribute
-          <literal>amd-blis</literal>, extends BLIS with optimizations for
-          modern AMD CPUs. The changes are usually submitted to
-          the upstream BLIS project after some time. However, AMD BLIS
-          typically provides some performance improvements on AMD Zen CPUs.
-          The complementary AMD LIBFLAME library, with attribute
-          <literal>amd-libflame</literal>, provides a LAPACK implementation.
-         </para>
-       </listitem>
-     </itemizedlist>
+     </para>
      <para>
-       Introduced in <link
-       xlink:href="https://github.com/NixOS/nixpkgs/pull/83888">PR
-       #83888</link>, we are able to override the <literal>blas</literal>
-       and <literal>lapack</literal> packages to use different implementations,
-       through the <literal>blasProvider</literal> and
-       <literal>lapackProvider</literal> argument. This can be used
-       to select a different provider. BLAS providers will have
-       symlinks in <literal>$out/lib/libblas.so.3</literal> and
-       <literal>$out/lib/libcblas.so.3</literal> to their respective
-       BLAS libraries. Likewise, LAPACK providers will have symlinks
-       in <literal>$out/lib/liblapack.so.3</literal> and
-       <literal>$out/lib/liblapacke.so.3</literal> to their respective
-       LAPACK libraries. For example, Intel MKL is both a BLAS and
-       LAPACK provider. An overlay can be created to use Intel MKL
-       that looks like:
+      BLIS, available through the attribute <literal>blis</literal>, is a framework for linear algebra kernels. In addition, it implements the BLAS interface.
      </para>
-     <programlisting>
+    </listitem>
+    <listitem>
+     <para>
+      <link
+           xlink:href="https://developer.amd.com/amd-aocl/blas-library/">AMD BLIS/LIBFLAME</link> (optimized for modern AMD x86_64 CPUs)
+     </para>
+     <para>
+      The AMD fork of the BLIS library, with attribute <literal>amd-blis</literal>, extends BLIS with optimizations for modern AMD CPUs. The changes are usually submitted to the upstream BLIS project after some time. However, AMD BLIS typically provides some performance improvements on AMD Zen CPUs. The complementary AMD LIBFLAME library, with attribute <literal>amd-libflame</literal>, provides a LAPACK implementation.
+     </para>
+    </listitem>
+   </itemizedlist>
+
+   <para>
+    Introduced in <link
+       xlink:href="https://github.com/NixOS/nixpkgs/pull/83888">PR #83888</link>, we are able to override the <literal>blas</literal> and <literal>lapack</literal> packages to use different implementations, through the <literal>blasProvider</literal> and <literal>lapackProvider</literal> argument. This can be used to select a different provider. BLAS providers will have symlinks in <literal>$out/lib/libblas.so.3</literal> and <literal>$out/lib/libcblas.so.3</literal> to their respective BLAS libraries. Likewise, LAPACK providers will have symlinks in <literal>$out/lib/liblapack.so.3</literal> and <literal>$out/lib/liblapacke.so.3</literal> to their respective LAPACK libraries. For example, Intel MKL is both a BLAS and LAPACK provider. An overlay can be created to use Intel MKL that looks like:
+   </para>
+
+<programlisting>
 self: super:
 
 {
@@ -243,46 +216,24 @@ self: super:
   };
 }
 </programlisting>
-     <para>
-       This overlay uses Intel’s MKL library for both BLAS and LAPACK
-       interfaces. Note that the same can be accomplished at runtime
-       using <literal>LD_LIBRARY_PATH</literal> of
-       <literal>libblas.so.3</literal> and
-       <literal>liblapack.so.3</literal>. For instance:
-     </para>
+
+   <para>
+    This overlay uses Intel’s MKL library for both BLAS and LAPACK interfaces. Note that the same can be accomplished at runtime using <literal>LD_LIBRARY_PATH</literal> of <literal>libblas.so.3</literal> and <literal>liblapack.so.3</literal>. For instance:
+   </para>
+
 <screen>
 <prompt>$ </prompt>LD_LIBRARY_PATH=$(nix-build -A mkl)/lib:$LD_LIBRARY_PATH nix-shell -p octave --run octave
 </screen>
-     <para>
-       Intel MKL requires an <literal>openmp</literal> implementation
-       when running with multiple processors. By default,
-       <literal>mkl</literal> will use Intel’s <literal>iomp</literal>
-       implementation if no other is specified, but this is a
-       runtime-only dependency and binary compatible with the LLVM
-       implementation. To use that one instead, Intel recommends users
-       set it with <literal>LD_PRELOAD</literal>. Note that
-       <literal>mkl</literal> is only available on
-       <literal>x86_64-linux</literal> and
-       <literal>x86_64-darwin</literal>. Moreover, Hydra is not
-       building and distributing pre-compiled binaries using it.
-     </para>
-     <para>
-       For BLAS/LAPACK switching to work correctly, all packages must
-       depend on <literal>blas</literal> or <literal>lapack</literal>.
-       This ensures that only one BLAS/LAPACK library is used at one
-       time. There are two versions versions of BLAS/LAPACK currently
-       in the wild, <literal>LP64</literal> (integer size = 32 bits)
-       and <literal>ILP64</literal> (integer size = 64 bits). Some
-       software needs special flags or patches to work with
-       <literal>ILP64</literal>. You can check if
-       <literal>ILP64</literal> is used in Nixpkgs with
-       <varname>blas.isILP64</varname> and
-       <varname>lapack.isILP64</varname>. Some software does NOT work
-       with <literal>ILP64</literal>, and derivations need to specify
-       an assertion to prevent this. You can prevent
-       <literal>ILP64</literal> from being used with the following:
-     </para>
-     <programlisting>
+
+   <para>
+    Intel MKL requires an <literal>openmp</literal> implementation when running with multiple processors. By default, <literal>mkl</literal> will use Intel’s <literal>iomp</literal> implementation if no other is specified, but this is a runtime-only dependency and binary compatible with the LLVM implementation. To use that one instead, Intel recommends users set it with <literal>LD_PRELOAD</literal>. Note that <literal>mkl</literal> is only available on <literal>x86_64-linux</literal> and <literal>x86_64-darwin</literal>. Moreover, Hydra is not building and distributing pre-compiled binaries using it.
+   </para>
+
+   <para>
+    For BLAS/LAPACK switching to work correctly, all packages must depend on <literal>blas</literal> or <literal>lapack</literal>. This ensures that only one BLAS/LAPACK library is used at one time. There are two versions of BLAS/LAPACK currently in the wild, <literal>LP64</literal> (integer size = 32 bits) and <literal>ILP64</literal> (integer size = 64 bits). Some software needs special flags or patches to work with <literal>ILP64</literal>. You can check if <literal>ILP64</literal> is used in Nixpkgs with <varname>blas.isILP64</varname> and <varname>lapack.isILP64</varname>. Some software does NOT work with <literal>ILP64</literal>, and derivations need to specify an assertion to prevent this. You can prevent <literal>ILP64</literal> from being used with the following:
+   </para>
+
+<programlisting>
 { stdenv, blas, lapack, ... }:
 
 assert (!blas.isILP64) &amp;&amp; (!lapack.isILP64);
@@ -291,41 +242,38 @@ stdenv.mkDerivation {
   ...
 }
 </programlisting>
-   </section>
-   <section xml:id="sec-overlays-alternatives-mpi">
-     <title>Switching the MPI implementation</title>
-     <para>
-       All programs that are built with
-       <link xlink:href="https://en.wikipedia.org/wiki/Message_Passing_Interface">MPI</link>
-       support use the generic attribute <varname>mpi</varname>
-       as an input. At the moment Nixpkgs natively provides two different
-       MPI implementations:
-       <itemizedlist>
-         <listitem>
-           <para>
-             <link xlink:href="https://www.open-mpi.org/">Open MPI</link>
-             (default), attribute name <varname>openmpi</varname>
-           </para>
-         </listitem>
-         <listitem>
-           <para>
-             <link xlink:href="https://www.mpich.org/">MPICH</link>,
-             attribute name <varname>mpich</varname>
-           </para>
-         </listitem>
-       </itemizedlist>
-     </para>
-     <para>
-       To provide MPI enabled applications that use <literal>MPICH</literal>, instead
-       of the default <literal>Open MPI</literal>, simply use the following overlay:
-     </para>
-     <programlisting>
+  </section>
+
+  <section xml:id="sec-overlays-alternatives-mpi">
+   <title>Switching the MPI implementation</title>
+
+   <para>
+    All programs that are built with <link xlink:href="https://en.wikipedia.org/wiki/Message_Passing_Interface">MPI</link> support use the generic attribute <varname>mpi</varname> as an input. At the moment Nixpkgs natively provides two different MPI implementations:
+    <itemizedlist>
+     <listitem>
+      <para>
+       <link xlink:href="https://www.open-mpi.org/">Open MPI</link> (default), attribute name <varname>openmpi</varname>
+      </para>
+     </listitem>
+     <listitem>
+      <para>
+       <link xlink:href="https://www.mpich.org/">MPICH</link>, attribute name <varname>mpich</varname>
+      </para>
+     </listitem>
+    </itemizedlist>
+   </para>
+
+   <para>
+    To provide MPI enabled applications that use <literal>MPICH</literal>, instead of the default <literal>Open MPI</literal>, simply use the following overlay:
+   </para>
+
+<programlisting>
 self: super:
 
 {
   mpi = self.mpich;
 }
      </programlisting>
-   </section>
+  </section>
  </section>
 </chapter>