···11+# Build helpers {#part-builders}
22+33+A build helper is a function that produces derivations.
44+55+:::{.warning}
66+This is not to be confused with the [`builder` argument of the Nix `derivation` primitive](https://nixos.org/manual/nix/unstable/language/derivations.html), which refers to the executable that produces the build result, or [remote builder](https://nixos.org/manual/nix/stable/advanced-topics/distributed-builds.html), which refers to a remote machine that could run such an executable.
77+:::
88+99+Such a function is usually designed to abstract over a typical workflow for a given programming language or framework.
1010+This allows declaring a build recipe by setting a limited number of options relevant to the particular use case instead of using the `derivation` function directly.
1111+1212+[`stdenv.mkDerivation`](#part-stdenv) is the most widely used build helper, and serves as a basis for many others.
1313+In addition, it offers various options to customize parts of the builds.
1414+1515+There is no uniform interface for build helpers.
1616+[Trivial build helpers](#chap-trivial-builders) and [fetchers](#chap-pkgs-fetchers) have various input types for convenience.
1717+[Language- or framework-specific build helpers](#chap-language-support) usually follow the style of `stdenv.mkDerivation`, which accepts an attribute set or a fixed-point function taking an attribute set.
1818+1919+```{=include=} chapters
2020+build-helpers/fetchers.chapter.md
2121+build-helpers/trivial-build-helpers.chapter.md
2222+build-helpers/testers.chapter.md
2323+build-helpers/special.md
2424+build-helpers/images.md
2525+hooks/index.md
2626+languages-frameworks/index.md
2727+packages/index.md
2828+```
+10
doc/build-helpers/special.md
···11+# Special build helpers {#chap-special}
22+33+This chapter describes several special build helpers.
44+55+```{=include=} sections
66+special/fhs-environments.section.md
77+special/makesetuphook.section.md
88+special/mkshell.section.md
99+special/vm-tools.section.md
1010+```
···11# darwin.linux-builder {#sec-darwin-builder}
2233-`darwin.linux-builder` provides a way to bootstrap a Linux builder on a macOS machine.
33+`darwin.linux-builder` provides a way to bootstrap a Linux remote builder on a macOS machine.
4455This requires macOS version 12.4 or later.
6677-The builder runs on host port 31022 by default.
77+The remote builder runs on host port 31022 by default.
88You can change it by overriding `virtualisation.darwin-builder.hostPort`.
99See the [example](#sec-darwin-builder-example-flake).
1010···1515extra-trusted-users = <your username goes here>
1616```
17171818-To launch the builder, run the following flake:
1818+To launch the remote builder, run the following flake:
19192020```ShellSession
2121$ nix run nixpkgs#darwin.linux-builder
···5757builders-use-substitutes = true
5858```
59596060-To allow Nix to connect to a builder not running on port 22, you will also need to create a new file at `/etc/ssh/ssh_config.d/100-linux-builder.conf`:
6060+To allow Nix to connect to a remote builder not running on port 22, you will also need to create a new file at `/etc/ssh/ssh_config.d/100-linux-builder.conf`:
61616262```
6363Host linux-builder
···130130}
131131```
132132133133-## Reconfiguring the builder {#sec-darwin-builder-reconfiguring}
133133+## Reconfiguring the remote builder {#sec-darwin-builder-reconfiguring}
134134135135-Initially you should not change the builder configuration else you will not be
136136-able to use the binary cache. However, after you have the builder running locally
137137-you may use it to build a modified builder with additional storage or memory.
135135+Initially you should not change the remote builder configuration else you will not be
136136+able to use the binary cache. However, after you have the remote builder running locally
137137+you may use it to build a modified remote builder with additional storage or memory.
138138139139To do this, you just need to set the `virtualisation.darwin-builder.*` parameters as
140140in the example below and rebuild.
···11# pkgs.makeSetupHook {#sec-pkgs.makeSetupHook}
2233-`pkgs.makeSetupHook` is a builder that produces hooks that go in to `nativeBuildInputs`
33+`pkgs.makeSetupHook` is a build helper that produces hooks that go in to `nativeBuildInputs`
4455## Usage {#sec-pkgs.makeSetupHook-usage}
66
···11-# Trivial builders {#chap-trivial-builders}
11+# Trivial build helpers {#chap-trivial-builders}
2233Nixpkgs provides a couple of functions that help with building derivations. The most important one, `stdenv.mkDerivation`, has already been documented above. The following functions wrap `stdenv.mkDerivation`, making it easier to use in certain cases.
44
···528528```
529529:::
530530531531-### Recursive attributes in `mkDerivation` {#mkderivation-recursive-attributes}
531531+### Fixed-point arguments of `mkDerivation` {#mkderivation-recursive-attributes}
532532533533If you pass a function to `mkDerivation`, it will receive as its argument the final arguments, including the overrides when reinvoked via `overrideAttrs`. For example:
534534