Conversation
|
Don't feel like |
|
@sternenseemann Edit: Are you replying to Gytis' #135533 (comment) comment here? It seems like what you're saying fits that more. |
|
Ah sorry, you are right, I misread your diff. This indeed belongs in there, although I'd suggest the function should not take an attribute set, but instead two arguments: The functions suggested in #135533 (comment) OTOH belong somewhere else since they interact with packages, not |
@sternenseemann I made an attrset on the advice of @cleverca22 who suggested the errors are more appropriate when you don't supply one of the arguments. If I were to do it like you suggested, then it would not be clear in the error message which argument was missing. This way, it will fail and report in the log that "compilerFlags" or "stdenv" is missing, by name. |
But then it's much more cumbersome to use currying to make additional adapters out of the adapter: let
optimize2Adapter = withCFlags [ "-O2" ];
sanitizeAdapter = withCFlags [ "-fsanitize=address" ];
inversus let
optimize2Adapter = stdenv: withCFlags { compilerFlags = [ "-O2" ]; inherit stdenv; };
sanitizeAdapter = stdenv: withCFlags { compilerFlags = [ "-fsanitize=address" ]; inherit stdenv; };
inSince all adapters are made like I suggested, the consistency should make this quite obvious, whereas you need to remember the |
|
@sternenseemann After learning more about Nix, I think what you're exactly right. Do you have any more suggestions? If not, I'll squash and someone can merge it. |
2cf74f4 to
9c8fff6
Compare
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>
9c8fff6 to
ef33586
Compare
|
Not my area of expertise I must admit. Didn't see anything obvious but might have missed something. |
|
@SuperSandro2000 No problem, thanks for looking. |
Motivation for this change
This PR adds an easy method of appending compiler flags to your stdenv via a list.
It adds a new function called
withCFlagswhich lets anyone create a new stdenv with a list of compiler flags, or anything one might want to add to the CLI of each gcc invocation.In my own system, I wanted to have everything use
-O3and-funroll-loopsso I did that like this.Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"./result/bin/)