nix-community / crate2nix

rebuild only changed crates in CI with crate2nix and nix
https://nix-community.github.io/crate2nix/
Apache License 2.0
335 stars 82 forks source link

Overriding `crateConfig` for generated `Cargo.nix` #339

Open thehabbos007 opened 3 months ago

thehabbos007 commented 3 months ago

Hey, I'm in a situation where I'd like to pass custom buildRustCrate configuration for all of my crates. I saw that there's a crateConfig option at the top level of the generated Cargo.nix, I can't seem to find any documentation for it, is it a deprecated field?

https://github.com/nix-community/crate2nix/blob/e494b56b7445ba59ef049bcfdc889f5c558768d4/crate2nix/templates/Cargo.nix.tera#L24-L27

It seems like a useful configuration option. I was thinking it could be called defaultCrateConfig and override the per-crate crateConfig here:

https://github.com/nix-community/crate2nix/blob/e494b56b7445ba59ef049bcfdc889f5c558768d4/crate2nix/templates/nix/crate2nix/default.nix#L289-L290

With something like this:

            crateConfig = 
              lib.attrsets.recursiveUpdate 
                (builtins.removeAttrs crateConfig' [ "resolvedDefaultFeatures" "devDependencies" ]) 
                defaultCrateConfig;