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

How to add overrides to defaultCrateOverrides #15

Closed
Profpatsch opened this issue Jul 23, 2019 · 4 comments
Closed

How to add overrides to defaultCrateOverrides #15

Profpatsch opened this issue Jul 23, 2019 · 4 comments
Labels
before-1.0 This needs to be worked on/fixed before a 1.0. good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Profpatsch
Copy link

The README mentions

If your library with native dependencies is not yet supported, you can create an overlay to add the needed configuration to the defaultCrateOverrides

But it’s not clear to me how that can be done. For example, I can’t find the string defaultCrateOverrides in the generated nix file.

@kolloch kolloch added good first issue Good for newcomers help wanted Extra attention is needed labels Sep 2, 2019
@kolloch
Copy link
Collaborator

kolloch commented Sep 2, 2019

Note that this is part of the "standard" buildRustCrate support that comes with NixOS. I think it would be very valuable to document this well!

Some rudimentary doc is here: https://git.mayflower.de/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.md#compiling-rust-crates-using-nix-instead-of-cargo

I appreciate pull requests for the README.md for crate2nix or the nixos doc itself.

@kolloch kolloch added the before-1.0 This needs to be worked on/fixed before a 1.0. label Sep 2, 2019
@danieldk
Copy link
Contributor

danieldk commented Sep 7, 2019

Could you give a hint of how to do this? Normally buildRustCrate gives a derivation that is overridable, which allows overriding crateOverrides, so that something like the following works:

with import <nixpkgs> {};
((import ./hello.nix).hello {}).override {
  crateOverrides = defaultCrateOverrides // {
    hello = attrs: { buildInputs = [ openssl ]; };
  };
}

However, the file generated by crate2nix uses makeOverrideable again on the derivation (in buildRustCrateWithFeatures), for providing the feature overriding functionality. However, this seems to 'override the override', hiding the buildRustCrate variant?

Something like the above fails with:

error: anonymous function at /home/daniel/.config/nixpkgs/nix-nlp/pkgs/finalfrontier/finalfrontier.nix:2182:8 called with unexpected argument 'crateOverrides', at /home/daniel/git/nixpkgs/lib/customisation.nix:69:12

@danieldk
Copy link
Contributor

danieldk commented Sep 7, 2019

Just to confirm, if I apply this diff to the generated Nix file, I can use crateOverrides:

-  buildRustCrateWithFeatures = {packageId, features}:
-    lib.makeOverridable
-      ({features}: buildRustCrateWithFeaturesImpl {inherit packageId features;})
-      { inherit features; };
+  buildRustCrateWithFeatures = buildRustCrateWithFeaturesImpl;

@kolloch
Copy link
Collaborator

kolloch commented Nov 10, 2019

You could also override the defaultCrateOverrides in pkgs with an overlay. Thanks for the detective work.

I'll add crateOverrides to the overridable parameters since it would be an incompatibility otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
before-1.0 This needs to be worked on/fixed before a 1.0. good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants