C: Difference between revisions

imported>Mic92
document overrideCC and wrapCCWith
imported>Doronbehar
→‎Use a different compiler version: Show better new way to do it
Line 234: Line 234:


Adding a different c compiler to `buildInputs` in a nix expression will not change the default compiler
Adding a different c compiler to `buildInputs` in a nix expression will not change the default compiler
available in `$PATH`. Instead nixpkgs provides a `overrideCC` function:
available in `$PATH`. Instead, nixpkgs provides a several alternative `stdenv` which you can search with `nix search stdenv` so for example:


<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
(overrideCC stdenv gcc8).mkDerivation {
gcc8Stdenv.mkDerivation {
   name = "env";
   name = "env";
}
}