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 996 <varlistentry> 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> 1005 </varlistentry> 1006 1007 <varlistentry> ··· 1280 1281 <varlistentry> 1282 <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> 1289 </varlistentry> 1290 1291 <varlistentry>
··· 995 996 <varlistentry> 997 <term><varname>doCheck</varname></term> 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> 1006 </varlistentry> 1007 1008 <varlistentry> ··· 1281 1282 <varlistentry> 1283 <term><varname>doInstallCheck</varname></term> 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> 1292 </varlistentry> 1293 1294 <varlistentry>
+17 -2
pkgs/stdenv/generic/make-derivation.nix
··· 36 , depsTargetTarget ? [] # 1 -> 1 37 , depsTargetTargetPropagated ? [] # 1 -> 1 38 39 , configureFlags ? [] 40 , # Target is not included by default because most programs don't care. 41 # Including it then would cause needless mass rebuilds. ··· 44 configurePlatforms ? lib.optionals 45 (stdenv.hostPlatform != stdenv.buildPlatform) 46 [ "build" "host" ] 47 , crossConfig ? null 48 , meta ? {} 49 , passthru ? {} ··· 60 61 , hardeningEnable ? [] 62 , hardeningDisable ? [] 63 , ... } @ attrs: 64 65 # TODO(@Ericson2314): Make this more modular, and not O(n^2). ··· 178 "/bin/sh" 179 ]; 180 __propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps; 181 - } // (if outputs' != [ "out" ] then { 182 outputs = outputs'; 183 - } else { })); 184 185 # The meta attribute is passed in the resulting attribute set, 186 # but it's not part of the actual derivation, i.e., it's not
··· 36 , depsTargetTarget ? [] # 1 -> 1 37 , depsTargetTargetPropagated ? [] # 1 -> 1 38 39 + # Configure Phase 40 , configureFlags ? [] 41 , # Target is not included by default because most programs don't care. 42 # Including it then would cause needless mass rebuilds. ··· 45 configurePlatforms ? lib.optionals 46 (stdenv.hostPlatform != stdenv.buildPlatform) 47 [ "build" "host" ] 48 + 49 + # Check phase 50 + , doCheck ? false 51 + 52 + # InstallCheck phase 53 + , doInstallCheck ? false 54 + 55 , crossConfig ? null 56 , meta ? {} 57 , passthru ? {} ··· 68 69 , hardeningEnable ? [] 70 , hardeningDisable ? [] 71 + 72 , ... } @ attrs: 73 74 # TODO(@Ericson2314): Make this more modular, and not O(n^2). ··· 187 "/bin/sh" 188 ]; 189 __propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps; 190 + } // lib.optionalAttrs (outputs' != [ "out" ]) { 191 outputs = outputs'; 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 + }); 199 200 # The meta attribute is passed in the resulting attribute set, 201 # but it's not part of the actual derivation, i.e., it's not