Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] Add example on how to override compile flags for a package #23123

Closed

Conversation

matthiasbeyer
Copy link
Contributor

And again I was able to feel the pain and uglyness of writing XML! shiver

Closes #22668

@mention-bot
Copy link

@matthiasbeyer, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Profpatsch, @lethalman and @abbradar to be potential reviewers.

@joachifm
Copy link
Contributor

joachifm commented Feb 23, 2017

To me, the complexity of this overshadows the point; this'd be clearer:

foo.overrideAttrs (attrs: {
  NIX_CFLAGS_COMPILE = (attrs.NIX_CFLAGS_COMPILE or "") + " -fgo-fast"
})

or some variation thereof. I also think it's redundant to say that it compiles foo with the listed flags: it is self-evident.

EDIT: syntax error

@matthiasbeyer
Copy link
Contributor Author

@joachifm Thanks for the suggestion. It is complicated because I couldn't find documentation on how to do this, so I had to hack this together myself. I will test your suggestions and update this PR shortly! 👍

@matthiasbeyer
Copy link
Contributor Author

Don't merge! I guess I missed a blank before the flag

@matthiasbeyer
Copy link
Contributor Author

Okay. I'm ready to fix things up!

@joachifm
Copy link
Contributor

What about moving that utility function to lib/ instead? While much more convenient than the expanded form, it makes the example less crisp, imo. Consider that readers must 1) process more information in total; 2) spend more effort to parse out the relevant parts of the example. I think it'd be better if the cflags example was more in line with the separateDebug example above it.

(As a side note, I think the cflags example is strictly redundant in the context of a function reference, as it fails to teach the reader anything new about overrideAttrs, but I suppose we can find a better home for it later).

@FRidh
Copy link
Member

FRidh commented Feb 26, 2017

@matthiasbeyer I think you could be a bit more explicit about what this env var does. It passes the flag directly to the compiler, and therefore it typically won't be shown during configuration as you found out. I think this is worth mentioning.

@matthiasbeyer
Copy link
Contributor Author

@joachifm you mean I should put this function into nixpkgs/lib?

@joachifm
Copy link
Contributor

@matthiasbeyer something like that. A function reference is not a good place for utility functions, imo.

@joachifm
Copy link
Contributor

I wonder whether https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/configuration/customizing-packages.xml would be a better place for this?

@matthiasbeyer
Copy link
Contributor Author

@joachifm this way? 😄

@matthiasbeyer
Copy link
Contributor Author

Will this get merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants