stdenv: introduce withCFlags
Adds an easy method of appending compiler flags to your stdenv via a list. Co-authored-by: tomberek <tomberek@users.noreply.github.com> Co-authored-by: Gytis Ivaskevicius <gytis02.21@gmail.com> Co-authored-by: sternenseemann <sternenseemann@systemli.org>
This commit is contained in:
parent
9721abadfd
commit
b0c0e0d7eb
1 changed files with 21 additions and 0 deletions
|
@ -270,4 +270,25 @@ rec {
|
|||
allowSubstitutes = false;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/* Modify a stdenv so that it builds binaries with the specified list of
|
||||
compilerFlags appended and passed to the compiler.
|
||||
|
||||
This example would recompile every derivation on the system with
|
||||
-funroll-loops and -O3 passed to each gcc invocation.
|
||||
|
||||
Example:
|
||||
nixpkgs.overlays = [
|
||||
(self: super: {
|
||||
stdenv = super.withCFlags [ "-funroll-loops" "-O3" ] super.stdenv;
|
||||
})
|
||||
];
|
||||
*/
|
||||
withCFlags = compilerFlags: stdenv:
|
||||
stdenv.override (old: {
|
||||
mkDerivationFromStdenv = extendMkDerivationArgs old (args: {
|
||||
NIX_CFLAGS_COMPILE = toString (args.NIX_CFLAGS_COMPILE or "") + " ${toString compilerFlags}";
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue