···1+# Build helpers {#part-builders}
2+3+A build helper is a function that produces derivations.
4+5+:::{.warning}
6+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.
7+:::
8+9+Such a function is usually designed to abstract over a typical workflow for a given programming language or framework.
10+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.
11+12+[`stdenv.mkDerivation`](#part-stdenv) is the most widely used build helper, and serves as a basis for many others.
13+In addition, it offers various options to customize parts of the builds.
14+15+There is no uniform interface for build helpers.
16+[Trivial build helpers](#chap-trivial-builders) and [fetchers](#chap-pkgs-fetchers) have various input types for convenience.
17+[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.
18+19+```{=include=} chapters
20+build-helpers/fetchers.chapter.md
21+build-helpers/trivial-build-helpers.chapter.md
22+build-helpers/testers.chapter.md
23+build-helpers/special.md
24+build-helpers/images.md
25+hooks/index.md
26+languages-frameworks/index.md
27+packages/index.md
28+```
+10
doc/build-helpers/special.md
···0000000000
···1+# Special build helpers {#chap-special}
2+3+This chapter describes several special build helpers.
4+5+```{=include=} sections
6+special/fhs-environments.section.md
7+special/makesetuphook.section.md
8+special/mkshell.section.md
9+special/vm-tools.section.md
10+```
···1# darwin.linux-builder {#sec-darwin-builder}
23-`darwin.linux-builder` provides a way to bootstrap a Linux builder on a macOS machine.
45This requires macOS version 12.4 or later.
67-The builder runs on host port 31022 by default.
8You can change it by overriding `virtualisation.darwin-builder.hostPort`.
9See the [example](#sec-darwin-builder-example-flake).
10···15extra-trusted-users = <your username goes here>
16```
1718-To launch the builder, run the following flake:
1920```ShellSession
21$ nix run nixpkgs#darwin.linux-builder
···57builders-use-substitutes = true
58```
5960-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`:
6162```
63Host linux-builder
···130}
131```
132133-## Reconfiguring the builder {#sec-darwin-builder-reconfiguring}
134135-Initially you should not change the builder configuration else you will not be
136-able to use the binary cache. However, after you have the builder running locally
137-you may use it to build a modified builder with additional storage or memory.
138139To do this, you just need to set the `virtualisation.darwin-builder.*` parameters as
140in the example below and rebuild.
···1# darwin.linux-builder {#sec-darwin-builder}
23+`darwin.linux-builder` provides a way to bootstrap a Linux remote builder on a macOS machine.
45This requires macOS version 12.4 or later.
67+The remote builder runs on host port 31022 by default.
8You can change it by overriding `virtualisation.darwin-builder.hostPort`.
9See the [example](#sec-darwin-builder-example-flake).
10···15extra-trusted-users = <your username goes here>
16```
1718+To launch the remote builder, run the following flake:
1920```ShellSession
21$ nix run nixpkgs#darwin.linux-builder
···57builders-use-substitutes = true
58```
5960+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`:
6162```
63Host linux-builder
···130}
131```
132133+## Reconfiguring the remote builder {#sec-darwin-builder-reconfiguring}
134135+Initially you should not change the remote builder configuration else you will not be
136+able to use the binary cache. However, after you have the remote builder running locally
137+you may use it to build a modified remote builder with additional storage or memory.
138139To do this, you just need to set the `virtualisation.darwin-builder.*` parameters as
140in the example below and rebuild.
···1# pkgs.makeSetupHook {#sec-pkgs.makeSetupHook}
23-`pkgs.makeSetupHook` is a builder that produces hooks that go in to `nativeBuildInputs`
45## Usage {#sec-pkgs.makeSetupHook-usage}
6
···1# pkgs.makeSetupHook {#sec-pkgs.makeSetupHook}
23+`pkgs.makeSetupHook` is a build helper that produces hooks that go in to `nativeBuildInputs`
45## Usage {#sec-pkgs.makeSetupHook-usage}
6
···1-# Trivial builders {#chap-trivial-builders}
23Nixpkgs 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.
4
···1+# Trivial build helpers {#chap-trivial-builders}
23Nixpkgs 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.
4
···528```
529:::
530531-### Recursive attributes in `mkDerivation` {#mkderivation-recursive-attributes}
532533If you pass a function to `mkDerivation`, it will receive as its argument the final arguments, including the overrides when reinvoked via `overrideAttrs`. For example:
534
···528```
529:::
530531+### Fixed-point arguments of `mkDerivation` {#mkderivation-recursive-attributes}
532533If you pass a function to `mkDerivation`, it will receive as its argument the final arguments, including the overrides when reinvoked via `overrideAttrs`. For example:
534