diff options
author | matthewcroughan <matt@croughan.sh> | 2021-08-24 10:17:22 +0100 |
---|---|---|
committer | tomberek <tomberek@users.noreply.github.com> | 2022-01-29 21:23:12 -0500 |
commit | b0c0e0d7eb099a61479b2ca6b390d3b0809a5519 (patch) | |
tree | c7f768a49160d9a795751f383238fca1a29f665d /pkgs/stdenv | |
parent | 9721abadfdb42738ba3591f8b1da06a340b85309 (diff) |
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>
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r-- | pkgs/stdenv/adapters.nix | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 971be95e935d7..9884c219ff609 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -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}"; + }); + }); } |