about summary refs log tree commit diff
path: root/doc/languages-frameworks
diff options
context:
space:
mode:
authorPierre-Etienne Meunier <pierre-etienne.meunier@inria.fr>2018-02-20 08:55:04 +0100
committerJoachim Schiele <js@lastlog.de>2018-02-20 08:55:04 +0100
commit8e5ab6e7ac582d2787ba2e10eabbcacf09da270c (patch)
tree8f48892431486d38cf3e1dd41d73b60b6cb93554 /doc/languages-frameworks
parent507a3a9a39d772c51a76ce4598042d57f45e2ed0 (diff)
downloadnixlib-8e5ab6e7ac582d2787ba2e10eabbcacf09da270c.tar
nixlib-8e5ab6e7ac582d2787ba2e10eabbcacf09da270c.tar.gz
nixlib-8e5ab6e7ac582d2787ba2e10eabbcacf09da270c.tar.bz2
nixlib-8e5ab6e7ac582d2787ba2e10eabbcacf09da270c.tar.lz
nixlib-8e5ab6e7ac582d2787ba2e10eabbcacf09da270c.tar.xz
nixlib-8e5ab6e7ac582d2787ba2e10eabbcacf09da270c.tar.zst
nixlib-8e5ab6e7ac582d2787ba2e10eabbcacf09da270c.zip
BuildRustCrate: more general overrides, and handling the "dylib" crate type (#35171)
* buildRustCrate: adding a symlink from libblah-xxxxx.so to libblah.so
* BuildRustCrate: overriding phases
* Carnix: 0.6.5 -> 0.6.6
* Fixing symlink_dependencies --buildDep
* Shorter symlink_dependencies
* running `runHook postBuild` *after* the build
Diffstat (limited to 'doc/languages-frameworks')
-rw-r--r--doc/languages-frameworks/rust.md35
1 files changed, 33 insertions, 2 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