2022-12-27 01:27:13 +03:00
|
|
|
The crane library can be instantiated with a specific version of nixpkgs as
|
|
|
|
follows. For more information, see the [API docs] for `mkLib`.
|
|
|
|
|
|
|
|
```nix
|
|
|
|
# Instantiating for a specific `system`
|
|
|
|
crane.mkLib (import nixpkgs {
|
|
|
|
system = "armv7l-linux";
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
```nix
|
|
|
|
# Instantiating for cross compiling
|
|
|
|
crane.mkLib (import nixpkgs {
|
|
|
|
localSystem = "x86_64-linux";
|
|
|
|
crossSystem = "aarch64-linux";
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
The crane library can also be instantiated with a particular rust toolchain:
|
|
|
|
|
|
|
|
```nix
|
|
|
|
# For example, using rust-overlay
|
|
|
|
let
|
|
|
|
system = "x86_64-linux";
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [ (import rust-overlay) ];
|
|
|
|
};
|
|
|
|
in
|
2024-06-29 21:29:52 +03:00
|
|
|
(crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.stable.latest.default.override {
|
|
|
|
targets = [ "wasm32-wasi" ];
|
|
|
|
})
|
2022-12-27 01:27:13 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
Finally, specific inputs can be overridden for the entire library via the
|
2024-02-08 06:38:28 +03:00
|
|
|
`overrideScope` API as follows. For more information, see the [API
|
2022-12-27 01:27:13 +03:00
|
|
|
docs](../API.md) for `mkLib`/`overrideToolchain`, or checkout the
|
|
|
|
[custom-toolchain](../../examples/custom-toolchain) example.
|
|
|
|
|
|
|
|
```nix
|
2024-05-19 04:07:07 +03:00
|
|
|
(crane.mkLib pkgs).overrideScope (final: prev: {
|
2022-12-27 01:27:13 +03:00
|
|
|
cargo-tarpaulin = myCustomCargoTarpaulinVersion;
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
[API docs]: ../API.md
|