stdenv: Force `doCheck` and `doInstallCheck` to be false when we are cross compiling

I hope this will be a temporary measure. If there is consensus around
issue #33599, then we can follow an explicit `dontCheck`, but default to
not checking during cross builds when none is given.

+33 -15
+16 -13
doc/stdenv.xml
··· 995 995 996 996 <varlistentry> 997 997 <term><varname>doCheck</varname></term> 998 - <listitem><para>If set to a non-empty string, the check phase is 999 - executed, otherwise it is skipped (default). Thus you should set 1000 - 1001 - <programlisting> 1002 - doCheck = true;</programlisting> 1003 - 1004 - in the derivation to enable checks.</para></listitem> 998 + <listitem><para> 999 + Controls whether the check phase is executed. 1000 + By default it is skipped, but if <varname>doCheck</varname> is set to true, the check phase is usually executed. 1001 + Thus you should set <programlisting>doCheck = true;</programlisting> in the derivation to enable checks. 1002 + The exception is cross compilation. 1003 + Cross compiled builds never run tests, no matter how <varname>doCheck</varname> is set, 1004 + as the newly-built program won't run on the platform used to build it. 1005 + </para></listitem> 1005 1006 </varlistentry> 1006 1007 1007 1008 <varlistentry> ··· 1280 1281 1281 1282 <varlistentry> 1282 1283 <term><varname>doInstallCheck</varname></term> 1283 - <listitem><para>If set to a non-empty string, the installCheck phase is 1284 - executed, otherwise it is skipped (default). Thus you should set 1285 - 1286 - <programlisting>doInstallCheck = true;</programlisting> 1287 - 1288 - in the derivation to enable install checks.</para></listitem> 1284 + <listitem><para> 1285 + Controls whether the installCheck phase is executed. 1286 + By default it is skipped, but if <varname>doInstallCheck</varname> is set to true, the installCheck phase is usually executed. 1287 + Thus you should set <programlisting>doInstallCheck = true;</programlisting> in the derivation to enable install checks. 1288 + The exception is cross compilation. 1289 + Cross compiled builds never run tests, no matter how <varname>doInstallCheck</varname> is set, 1290 + as the newly-built program won't run on the platform used to build it. 1291 + </para></listitem> 1289 1292 </varlistentry> 1290 1293 1291 1294 <varlistentry>
+17 -2
pkgs/stdenv/generic/make-derivation.nix
··· 36 36 , depsTargetTarget ? [] # 1 -> 1 37 37 , depsTargetTargetPropagated ? [] # 1 -> 1 38 38 39 + # Configure Phase 39 40 , configureFlags ? [] 40 41 , # Target is not included by default because most programs don't care. 41 42 # Including it then would cause needless mass rebuilds. ··· 44 45 configurePlatforms ? lib.optionals 45 46 (stdenv.hostPlatform != stdenv.buildPlatform) 46 47 [ "build" "host" ] 48 + 49 + # Check phase 50 + , doCheck ? false 51 + 52 + # InstallCheck phase 53 + , doInstallCheck ? false 54 + 47 55 , crossConfig ? null 48 56 , meta ? {} 49 57 , passthru ? {} ··· 60 68 61 69 , hardeningEnable ? [] 62 70 , hardeningDisable ? [] 71 + 63 72 , ... } @ attrs: 64 73 65 74 # TODO(@Ericson2314): Make this more modular, and not O(n^2). ··· 178 187 "/bin/sh" 179 188 ]; 180 189 __propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps; 181 - } // (if outputs' != [ "out" ] then { 190 + } // lib.optionalAttrs (outputs' != [ "out" ]) { 182 191 outputs = outputs'; 183 - } else { })); 192 + } // lib.optionalAttrs (attrs ? doCheck) { 193 + # TODO(@Ericson2314): Make unconditional / resolve #33599 194 + doCheck = doCheck && (stdenv.hostPlatform == stdenv.targetPlatform); 195 + } // lib.optionalAttrs (attrs ? doInstallCheck) { 196 + # TODO(@Ericson2314): Make unconditional / resolve #33599 197 + doInstallCheck = doInstallCheck && (stdenv.hostPlatform == stdenv.targetPlatform); 198 + }); 184 199 185 200 # The meta attribute is passed in the resulting attribute set, 186 201 # but it's not part of the actual derivation, i.e., it's not