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

build-support/rust: Add target option #71899

Merged

Conversation

exFalso
Copy link
Contributor

@exFalso exFalso commented Oct 24, 2019

Motivation for this change

This PR adds a flag to buildRustPackage that can override the --target flag to cargo.

Things done

Added the flag, adjusted corresponding paths in the code.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions (Arch Linux)
  • 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 nix-review --run "nix-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.
Notify maintainers

cc @andir @Mic92

@Mic92
Copy link
Member

Mic92 commented Oct 24, 2019

I am curious how do you use this flag, given that our rustc expression does not allow set a target different from stdenv.targetPlatform.config.

@exFalso
Copy link
Contributor Author

exFalso commented Oct 24, 2019

We use an overridden nightly rust, i.e.

  mozillaOverlay = nixpkgs.fetchFromGitHub {
    owner = "mozilla";
    repo = "nixpkgs-mozilla";
    rev = "b52a8b7de89b1fac49302cbaffd4caed4551515f";
    sha256 = "1np4fmcrg6kwlmairyacvhprqixrk7x9h89k813safnlgbgqwrqb";
  };
  rustOverlay = import "${mozillaOverlay.out}/rust-overlay.nix" nixpkgs.pkgs nixpkgs.pkgs;
  rustNightly = rustOverlay.rustChannelOf {
      sha256 = "1siwx5k3jk637zf16ygmx2wxkm26wdkgl6bqh35f7j0cnfhlpz58";
      date = "2019-09-27";
      channel = "nightly";
  };
  rustSgx = rustNightly.rust.override {
    targets = [ "x86_64-fortanix-unknown-sgx" ];
  };

then

pkgs.rustPlatform.buildRustPackage {
  .. bla bla ..
  target = "x86_64-fortanix-unknown-sgx";
}

@Mic92
Copy link
Member

Mic92 commented Oct 25, 2019

Can you add an example to our some documentation as well? (doc/languages-frameworks/rust.section.md)

@exFalso exFalso force-pushed the aslemmer/build-rust-package-add-target branch from a982015 to bb7184d Compare November 1, 2019 14:19
@exFalso
Copy link
Contributor Author

exFalso commented Nov 1, 2019

Can you add an example to our some documentation as well? (doc/languages-frameworks/rust.section.md)

Added a small paragraph

@Mic92 Mic92 merged commit 56240d7 into NixOS:master Nov 1, 2019
@exFalso exFalso deleted the aslemmer/build-rust-package-add-target branch November 1, 2019 19:14
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