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

doc: Add rust documentation #23510

Merged
merged 9 commits into from Mar 20, 2017
Merged

Conversation

matthiasbeyer
Copy link
Contributor

Motivation for this change

Rust is/was not documented. Also: http://lists.science.uu.nl/pipermail/nix-dev/2017-March/022947.html by @nbp .

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@matthiasbeyer, thanks for your PR! By analyzing the history of the files in this pull request, we identified @vcunat, @cko and @edolstra to be potential reviewers.

@matthiasbeyer matthiasbeyer mentioned this pull request Mar 5, 2017
7 tasks
@matthiasbeyer
Copy link
Contributor Author

I re-used large parts of the mail from @nbp and I'd like him to approve that I re-used it, before merging.

Copy link
Member

@nbp nbp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds good to me.


## Using Rust nightlies (with an overlay)

Mozilla provides a overlay for nixpkgs which can be used to bring a nightly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: provides an overlay

$ mkdir -p ~/.config/nixpkgs/overlays
$ ln -s $(pwd)/nixpkgs-mozilla/rust-overlay.nix ~/.config/nixpkgs/overlays/rust-overlay.nix

Once installed, one can install the latest versions with the following commands:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self-nit: the following command:


Rust is packaged with nixpkgs, although there are no rust crates packaged in
nixpkgs.
Therefor, one has to use `cargo` directly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tried it yet, but maybe it might be worth to add a reference to https://github.com/fractalide/nixcrates

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on a side-note for this.

Copy link
Member

@Mic92 Mic92 Mar 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While crates are not precompiled there is buildRustPackage to build Rust projects:

$ ag buildRustPackage | wc -l       
27

using the fetchurl builtin function to pull the same file as rustup do
through https.

The `*.toml` manifest file is then parsed (yes,
Copy link
Member

@Mic92 Mic92 Mar 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the second paragraph here relevant to end users? I guess educated nix user can figure it out on their own how it works in detail, while it is too low level for the others.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems to be a good point. Do you want me to remove this paragraph?

pull the prebuilt binaries and to change the interpreter of the binaries using
patchelf.

The overlay automatically update itself as it uses the same source as [rustup](https://www.rustup.rs/).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think I skipped something important in this sentence?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I think it is appropriate.

@Mic92
Copy link
Member

Mic92 commented Mar 6, 2017

I added some more documentation regarding packaging rust applications.

fake checksum into the expression and building the package once. The correct
checksum can be then take from the failed build.

To install creates with nix there is also an experimental project called

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo “creates”.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

To install the beta or nightly channel, "stable" should be substituted by
"nightly" and "beta", or
use the function provided by this overlay to pull a version based on a
build date.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know how to use this function? If yes, it would be great to add a small example here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works exactly like all overlays work, which is documentaed afaik.

Copy link
Member

@Mic92 Mic92 Mar 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the function to pull a rust version based on the build date.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, well no, I don't know how to do this. 😞

@fpletz fpletz added this to the 17.03 milestone Mar 19, 2017
use the function provided by this overlay to pull a version based on a
build date.

The overlay automatically update itself as it uses the same source as
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update -> updates

$ nix-shell -p nixos.rustChannels.stable.rust

To install the beta or nightly channel, "stable" should be substituted by
"nightly" and "beta", or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and -> or


Rust applications are packaged by using the `buildRustPackage` helper from `rustPlatform`:

``` from
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the "from" looks like a rogue copy & paste or similar

@globin globin merged commit 315e1a2 into NixOS:master Mar 20, 2017
globin pushed a commit that referenced this pull request Mar 20, 2017
@matthiasbeyer
Copy link
Contributor Author

As far as I can see you squashed things for me, right?

@matthiasbeyer matthiasbeyer deleted the doc-rust-language branch March 21, 2017 07:34
@Mic92
Copy link
Member

Mic92 commented Mar 23, 2017

yes

@Mic92 Mic92 mentioned this pull request Apr 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants