No description
Find a file
Nicolas Mattia 95cf3bb609
Merge pull request #11 from basvandijk/cargolock-cargotoml-via-file
Pass cargolock/cargotoml via file instead of via env var
2019-08-26 11:30:38 +02:00
builtins Pass cargolock/cargotoml via file instead of via env var 2019-08-26 11:05:41 +02:00
nix Fix workspaces 2019-07-11 11:39:40 +02:00
test Fix workspaces 2019-07-11 11:39:40 +02:00
build.nix Pass cargolock/cargotoml via file instead of via env var 2019-08-26 11:05:41 +02:00
default.nix Avoid IFD as much as possible 2019-07-31 15:53:30 +02:00
lib.nix wip 2019-07-31 13:41:34 +02:00
README.md Add comparison to rustPlatform and carnix 2019-08-06 20:08:30 +02:00
test.nix Fix cargo build 2019-07-31 15:54:51 +02:00

Naersk

Nix support for building cargo crates.

Install

Use niv:

$ niv add nmattia/naersk

And then

let
    pkgs = import <nixpkgs> {};
    sources = import ./nix/sources.nix;
    naersk = pkgs.callPackage sources.naersk {};
in naersk.buildPackage ./path/to/rust {}

NOTE: ./path/to/rust/ should contain a Cargo.lock.

Comparison

There are two other notable Rust frameworks in Nix: rustPlatform and carnix.

naersk uses cargo directly, as opposed to carnix which emulates cargo's build logic. Moreover naersk sources build information directly from the project's Cargo.lock which makes any code generation unnecessary.

For the same reason, naersk does not need anything like rustPlatform's cargoSha256. All crates are downloaded using the sha256 checksums provided in the project's Cargo.lock. Because cargo doesn't register checksums for git dependencies, naersk does not support git dependencies.

Finally naersk supports incremental builds by first performing a dependency-only build, and then a build that depends on the top-level crate's code and configuration.