Navigation Menu

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

buildRustCrate: Search for matching Cargo.toml in sub directories #82155

Merged
merged 2 commits into from Mar 10, 2020

Conversation

kolloch
Copy link
Contributor

@kolloch kolloch commented Mar 9, 2020

Motivation for this change

When cargo builds a git dependency, it will search for a matching Cargo.toml in any sub directory. buildRustCrate assumes the top-level directory by default which results in the following build failures:

nix-community/crate2nix#33
nix-community/crate2nix#53

In theory, workspace_member could be set to the appropriate sub directory upfront but allowing workspace_member = null to trigger a search is much mroe convenient. This PR will NOT change the default behavior because the current buildRustCrate does not depend on any Cargo.toml being present and we'd like to preserve that.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests):
    nix build -I nixpkgs=. '((import <nixpkgs> {}).callPackage pkgs/build-support/rust/build-rust-crate/test {}).test'
    
    
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

* Make errors include the crate name and make them much more prominent.
* Move more code into lib.sh
* Already source generated logging code and lib.sh in configure
…sub directories

This is what cargo does for git repositories.

See related issues:

* nix-community/crate2nix#53
* nix-community/crate2nix#33
@andir
Copy link
Member

andir commented Mar 9, 2020

@GrahamcOfBorg build buildRustCrateTests

@kolloch
Copy link
Contributor Author

kolloch commented Mar 9, 2020

buildRustCrateTests on x86_64-darwin times out on building rustc itself:

building of '/nix/store/na14i3gf8w4wl60kbhia9gp2a388b21d-rustc-1.41.0.drv' timed out after 3600 seconds

https://logs.nix.ci/?attempt_id=cc2ccc7c-25d3-4115-b4bf-8f068cff8650&key=nixos%2Fnixpkgs.82155

@kolloch
Copy link
Contributor Author

kolloch commented Mar 9, 2020

I think that if I do that, darwin will not rebuild but I'll try ;)

@GrahamcOfBorg build buildRustCrateTests

@andir
Copy link
Member

andir commented Mar 10, 2020

@GrahamcOfBorg build carnix cargo-download

@andir
Copy link
Member

andir commented Mar 10, 2020

The build failure of cargo-download (https://gist.githubusercontent.com/andir/47cefa42982b873e213ab4328419991c/raw/f7bca737264bbb4126f85e69fee25484620bd024/i9n0z4hcqkx9z7vf5pil4hlx83knymva-rust_url-1.6.0.drv.log) seems to be unrelated to this change. It fails due to a newer rustc version (is my first guess).

The tests also look fine and pass (on at least linux).

Thank you for adding this! 👍

@andir andir merged commit e968961 into NixOS:master Mar 10, 2020
kolloch added a commit to nix-community/crate2nix that referenced this pull request Mar 11, 2020
Cargo does this for git repositories as well:

rust-lang/cargo#1462 (comment)

This will fix #33, #53 -- integration tests pending.

It depends on a nixpkgs buildRustCrate feature PR:

NixOS/nixpkgs#82155
kolloch added a commit to nix-community/crate2nix that referenced this pull request Mar 12, 2020
Cargo does this for git repositories as well:

rust-lang/cargo#1462 (comment)

This will fix #33, #53 -- integration tests pending.

It depends on a nixpkgs buildRustCrate feature PR:

NixOS/nixpkgs#82155
kolloch added a commit to nix-community/crate2nix that referenced this pull request Mar 12, 2020
Cargo does this for git repositories as well:

rust-lang/cargo#1462 (comment)

This will fix #33, #53 -- integration tests pending.

It depends on a nixpkgs buildRustCrate feature PR:

NixOS/nixpkgs#82155
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

2 participants