You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to make it easy to build a crate with default features etc but also to customize it. So far, I have allowed this by providing .build attribute which contains the derivation with the default arguments. That derivation is returned by buildRustCrateWithFeatures which uses makeOverridable to allow overriding its paramters.
Unfortunately, buildRustCrate in nixpkgs also uses makeOverridable to allow customization. Sometimes, it might be good to customize the derivation on that level.
I can think of multiple ways to achieve this:
Instead or in addition of the build attribute, I would introduce a builder attribute which is a function that you can call with an empty attr set {} to get the old behavior -- or specify additional parameters to override behavior.
Add an overridable buildRustCrateOverride parameter to buildRustCrateWithFeatures. That parameter would contain a function which is passed to override on the buildRustCrate return value. E.g.:
kolloch
changed the title
Do not use override anymore for customizing buildRustCrate
Allow overriding the returned deriviations with .overrideJan 27, 2020
kolloch
changed the title
Allow overriding the returned deriviations with .override
What is a good .override pattern?
Jan 27, 2020
kolloch
changed the title
What is a good .override pattern?
Allow overriding underlying buildRustCrate invocation
Jan 27, 2020
I want to make it easy to build a crate with default features etc but also to customize it. So far, I have allowed this by providing
.build
attribute which contains the derivation with the default arguments. That derivation is returned bybuildRustCrateWithFeatures
which usesmakeOverridable
to allow overriding its paramters.Unfortunately,
buildRustCrate
in nixpkgs also usesmakeOverridable
to allow customization. Sometimes, it might be good to customize the derivation on that level.I can think of multiple ways to achieve this:
build
attribute, I would introduce abuilder
attribute which is a function that you can call with an empty attr set{}
to get the old behavior -- or specify additional parameters to override behavior.buildRustCrateOverride
parameter tobuildRustCrateWithFeatures
. That parameter would contain a function which is passed tooverride
on thebuildRustCrate
return value. E.g.:.overrideBuildRustCrate
function which crates an override on buildRustCrate using 2 or similar.Tell me if that sounds like a good plan.
The text was updated successfully, but these errors were encountered: