No description
Find a file
Nicolas Mattia ccc838126d
Merge pull request #14 from zimbatm/nixpkgs-fmt
format with nixpkgs-fmt
2019-11-20 11:18:09 +01:00
.circleci Add .circleci/config.yml 2019-10-08 11:10:28 +02:00
builtins stylistic changes 2019-11-19 20:12:42 +00:00
nix Use rust stable 2019-10-08 11:20:30 +02:00
test Copy paths from the [patch] section into the dummy-src 2019-10-29 14:57:28 +01:00
build.nix stylistic changes 2019-11-19 20:12:42 +00:00
config.nix stylistic changes 2019-11-19 20:12:42 +00:00
default.nix stylistic changes 2019-11-19 20:12:42 +00:00
lib.nix format nix code with nixpkgs-fmt v0.6.1 2019-11-19 20:12:36 +00:00
README.md Mention attribute set or path in README 2019-11-18 18:17:25 +01:00
test.nix stylistic changes 2019-11-19 20:12:42 +00:00

Naersk

CircleCI

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.

The buildPackage function also accepts an attribute set. For more information, consult config.nix.

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.