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

buildRustPackage: add support for non-default bins #80869

Closed
wants to merge 1 commit into from

Conversation

crawford
Copy link
Contributor

Motivation for this change

In order to eventually package sccache-dist, I need to plumb through the --bin flag to cargo build (i.e. cargo build --bin sccache-dist).

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)
  • 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.

Some Rust crates can generate multiple executables. In order to build
executables other than the default, cargo's `--bin` flag is necessary.
This patch adds a `buildBins` parameter to `buildRustPackage` so that
these executables may be built.
@andir
Copy link
Member

andir commented Feb 23, 2020 via email

@crawford
Copy link
Contributor Author

In my case, I’m trying to package sccache-dist separately from sccache (which is already packaged by someone else). Both sccache and sccache-dist are designed to be used on their own or in conjunction, so I think it makes sense to allow these to be installed independently. If I were to use --bins in the sccache-dist derivation, that would cause a conflict with the sccache derivation (both would install sccache).

@andir
Copy link
Member

andir commented Feb 24, 2020 via email

@crawford
Copy link
Contributor Author

Let me clarify. Cargo will build both binaries with the --bins flag (each one will have the respective name specified in Cargo.toml). The issue is just that if I install the sccache derivation, I won’t be able to install the (as of yet nonexistent) sccache-dist derivation (due to both providing sccache).

@andir
Copy link
Member

andir commented Feb 24, 2020 via email

@crawford
Copy link
Contributor Author

Ah, interesting. That does sound more like what I’m after. With that approach, this PR doesn’t seem necessary.

Thanks for your review!

@crawford crawford closed this Feb 24, 2020
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