What are the "host and target platforms" of a dependency?

Nixpkgs 23.05 manual | Nix & NixOS says:

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 Cross-compilation for exactly what each platform
means. [1] 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. [2] For each dependency of those
dependencies, dep/bin, if present, is added to the PATH environment

A dependency is said to be propagated when some of its
other-transitive (non-immediate) downstream dependencies also need it
as an immediate dependency. [3]

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
. To determine the exact rules for dependency propagation, we start
by assigning to each dependency a couple of ternary numbers (-1 for
build, 0 for host, and 1 for target) representing its dependency type,
which captures how its host and target platforms are each “offset”
from the depending derivation’s host and target platforms.
following table summarize the different combinations that can be
obtained: …

What are the three axes? I only saw two:

  • their host and target platforms relative to the new derivation’s,
  • whether they are propagated.

What do the following parts from the quote mean:

  • the “host and target platforms” of a dependency, as in the first paragraph;

  • “build”, as in “assigning to each dependency a couple of ternary numbers (-1 for build, 0 for host, and 1 for target) representing its dependency type” in the last paragraph; (Is “build” another platform of a dependency, besides the dependency’s “host and target platforms”?)

  • “their host and target platforms relative to the new derivation’s”;

  • the two sentences in bold and in the last paragraph.


Can someone rephrase it in a way easier to understand?


First i could be totally wrong
Second my fake scenario could be impractical


Assume there are two computers

  • my pc (Windows)
  • my friend pc (Linux)

I wrote some code and want to compile it then give it to my friend
Code is written in C and also need xlib library to run
So xlib and gcc (c compiler) are dependencies
I need Windows version of gcc but i have to use Linux version of xlib
why? because gcc will run on my Windows machine but xlib will run on my friend’s one which is Linux


my Windows machine is build platform
my friend’s machine is host/target platform
gcc is build-time dependency
xlib is run-time dependency

some additional info that maybe you don’t need to know for now

gcc will be in nativeBuildInputs
xlib will be in buildInputs

1 Like

Thanks. What differences are between host and target platforms?

www.uber.com/blog/bootstrapping-ubers-infrastructure-on-arm64-with-zig/ says:

A host is the machine that is compiling the binary. A target is the machine that will run the binary. In native compilation the host and target are the same platform (i.e., operating system, processor architecture, and shared libraries are the same).

Does it say something different from you? What differences are between host platform defined in it and build platform in your definition?

yes it’s different

Short answer

  • target is something nix has for compatibility and i guess it’s when you are cross compiling a cross compiler
  • host is the thing i explained in previous post

Long answer

from nixpkgs manual

In summary, build is the platform on which a package is being built, host is the platform on which it will run. The third attribute, target, is relevant only for certain specific compilers and build tools.

this is also helpful

The host platform is always where the output artifacts from the compiler will be executed whether the output is another compiler or not. The target platform is used when cross-compiling cross compilers, it represents what type of object code the package will produce; otherwise the target platform setting is irrelevant.