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
doc: Add rust documentation #23510
Conversation
@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. |
I re-used large parts of the mail from @nbp and I'd like him to approve that I re-used it, before merging. |
There was a problem hiding this 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.
doc/languages-frameworks/rust.md
Outdated
|
||
## Using Rust nightlies (with an overlay) | ||
|
||
Mozilla provides a overlay for nixpkgs which can be used to bring a nightly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: provides an overlay
doc/languages-frameworks/rust.md
Outdated
$ 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: |
There was a problem hiding this comment.
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:
doc/languages-frameworks/rust.md
Outdated
|
||
Rust is packaged with nixpkgs, although there are no rust crates packaged in | ||
nixpkgs. | ||
Therefor, one has to use `cargo` directly. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
379393a
to
f5d342a
Compare
doc/languages-frameworks/rust.md
Outdated
using the fetchurl builtin function to pull the same file as rustup do | ||
through https. | ||
|
||
The `*.toml` manifest file is then parsed (yes, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
doc/languages-frameworks/rust.md
Outdated
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/). |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
I added some more documentation regarding packaging rust applications. |
doc/languages-frameworks/rust.md
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo “creates”.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
doc/languages-frameworks/rust.md
Outdated
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. 😞
doc/languages-frameworks/rust.md
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update -> updates
doc/languages-frameworks/rust.md
Outdated
$ nix-shell -p nixos.rustChannels.stable.rust | ||
|
||
To install the beta or nightly channel, "stable" should be substituted by | ||
"nightly" and "beta", or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and -> or
doc/languages-frameworks/rust.md
Outdated
|
||
Rust applications are packaged by using the `buildRustPackage` helper from `rustPlatform`: | ||
|
||
``` from |
There was a problem hiding this comment.
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
(cherry picked from commit 315e1a2)
As far as I can see you squashed things for me, right? |
yes |
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
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)