Build flags: Difference between revisions

imported>Appetrosyan
Moved to templates and fixed rendering.
imported>Symphorien
mention stdenv.hostPlatform.*support
Line 24: Line 24:
nix-build optimised_openssl.nix --option system-features gccarch-skylake
nix-build optimised_openssl.nix --option system-features gccarch-skylake
</code>
</code>
==== Adapting a derivation to specific plaforms ====
The technique above should pass the correct flags to gcc so that it uses the processor to its fullest. However, some build systems or configure scripts want to know whether to enable some processor-specific instructions, for example sse. One way to do so is to inspect the <code>stdenv.hostPlatform.*Support</code> predicates: here is an example from g2o:
<code>
cmakeFlags = [  "-DDISABLE_SSE3=${  if stdenv.hostPlatform.sse3Support  then "OFF" else "ON"}" ]
</code>
Available flags are defined in [https://github.com/NixOS/nixpkgs/blob/master/lib/systems/architectures.nix lib/systems/architectures.nix].


==== Building the whole system on NixOS ====
==== Building the whole system on NixOS ====