From 06cd7c15a3f2d990316b8c685226d8155f0304cf Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 3 Sep 2018 23:03:38 -0400 Subject: [PATCH] mkDerivation: Fix cross compilation Derivations where drawing their `system` attribute from `hostPlatform` instead of `buildPlatform`. Fix that, and add an explanatory commment. Fixes #45993 --- pkgs/stdenv/generic/make-derivation.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 8af6d0e040085..e1ce3200e8c94 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -187,7 +187,15 @@ rec { builder = attrs.realBuilder or stdenv.shell; args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)]; inherit stdenv; - inherit (stdenv.hostPlatform) system; + + # The `system` attribute of a derivation has special meaning to Nix. + # Derivations set it to choose what sort of machine could be used to + # execute the build, The build platform entirely determines this, + # indeed more finely than Nix knows or cares about. The `system` + # attribute of `buildPlatfom` matches Nix's degree of specificity. + # exactly. + inherit (stdenv.buildPlatform) system; + userHook = config.stdenv.userHook or null; __ignoreNulls = true;