diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/languages-frameworks/rust.md | 35 | ||||
-rw-r--r-- | doc/meta.xml | 2 |
2 files changed, 34 insertions, 3 deletions
diff --git a/doc/languages-frameworks/rust.md b/doc/languages-frameworks/rust.md index d3a25e9d1358..f0498eac5b19 100644 --- a/doc/languages-frameworks/rust.md +++ b/doc/languages-frameworks/rust.md @@ -58,6 +58,8 @@ To install crates with nix there is also an experimental project called ## Compiling Rust crates using Nix instead of Cargo +### Simple operation + When run, `cargo build` produces a file called `Cargo.lock`, containing pinned versions of all dependencies. Nixpkgs contains a tool called `carnix` (`nix-env -iA nixos.carnix`), which can be used @@ -153,6 +155,8 @@ Here, the `libc` crate has no `src` attribute, so `buildRustCrate` will fetch it from [crates.io](https://crates.io). A `sha256` attribute is still needed for Nix purity. +### Handling external dependencies + Some crates require external libraries. For crates from [crates.io](https://crates.io), such libraries can be specified in `defaultCrateOverrides` package in nixpkgs itself. @@ -210,7 +214,10 @@ with import <nixpkgs> {}; } ``` -Three more parameters can be overridden: +### Options and phases configuration + +Actually, the overrides introduced in the previous section are more +general. A number of other parameters can be overridden: - The version of rustc used to compile the crate: @@ -232,6 +239,30 @@ Three more parameters can be overridden: (hello {}).override { verbose = false; }; ``` +- Extra arguments to be passed to `rustc`: + + ``` + (hello {}).override { extraRustcOpts = "-Z debuginfo=2"; }; + ``` + +- Phases, just like in any other derivation, can be specified using + the following attributes: `preUnpack`, `postUnpack`, `prePatch`, + `patches`, `postPatch`, `preConfigure` (in the case of a Rust crate, + this is run before calling the "build" script), `postConfigure` + (after the "build" script),`preBuild`, `postBuild`, `preInstall` and + `postInstall`. As an example, here is how to create a new module + before running the build script: + + ``` + (hello {}).override { + preConfigure = '' + echo "pub const PATH=\"${hi.out}\";" >> src/path.rs" + ''; + }; + ``` + +### Features + One can also supply features switches. For example, if we want to compile `diesel_cli` only with the `postgres` feature, and no default features, we would write: @@ -243,7 +274,7 @@ features, we would write: } ``` - +Where `diesel.nix` is the file generated by Carnix, as explained above. ## Using the Rust nightlies overlay diff --git a/doc/meta.xml b/doc/meta.xml index 0f9dccfb91b5..356325991860 100644 --- a/doc/meta.xml +++ b/doc/meta.xml @@ -53,7 +53,7 @@ $ nix-env -qa hello --json "x86_64-linux", "armv5tel-linux", "armv7l-linux", - "mips64el-linux", + "mips32-linux", "x86_64-darwin", "i686-cygwin", "i686-freebsd", |