Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Cleanup buildRustCrate expression #75563
Motivation for this change
I am working on test support for
There is probably more stuff that we can cleanup and rework here but before this gets too big I'd like to land this.
I did successfully rebuild two of my larger private projects, carnix, toml2nix & the entire
The expression is already long and confusing enough without the color stuff sprinkled in. Moving it to a dedicated file makes sense. I switched a bit of the color support code to pure Nix since there wasn't much point in doing that in bash while we can just do it in Nix.
I already have a few changes in here that will trigger rebuilds so I might as well do that substitution now.
That code had been in the derivation for a while but no explanation was given why that is needed. It might be helpful to our future selfs to document why things are done the way they are.
This should carry the function better then `makeDeps` as it isn't producing deps but the rustc arguments required to link against those.
This should make it more obvious that we have three parts to it and not just one long gibberish string that makes up all of it.
We can get rid of a bunch of workarounds that were in the build script before by just passing on the `crateBin` attribute. Before we converted the list of attributes to a string only to convert it back in bash during the build phase. We can do the entire looping through builds in Nix and thus need no conversion and parsing of attributes over and over again. The big part that still remains bash is the heuristic that cargo introduced and that we can't do at eval time.
The previous lines were only different in the kind of dependencies but otherwise exactly the same. It makes the entire thing a bit more readable by moving this into a function that takes care of this.
This means we aren't rebuilding hat file for each crate we are building and the buildPhase expression is a lot easier to comprehent.