Skip to content

Commit

Permalink
rustPlatform.importCargoLock: add test cases for importCargoLock
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldk committed May 28, 2021
1 parent b3969f3 commit d3769e4
Show file tree
Hide file tree
Showing 16 changed files with 1,086 additions and 0 deletions.
83 changes: 83 additions & 0 deletions pkgs/build-support/rust/test/import-cargo-lock/basic/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "basic"
version = "0.1.0"
authors = ["Daniël de Kok <me@danieldk.eu>"]
edition = "2018"

[dependencies]
rand = "0.8"
18 changes: 18 additions & 0 deletions pkgs/build-support/rust/test/import-cargo-lock/basic/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ rustPlatform }:

rustPlatform.buildRustPackage {
pname = "basic";
version = "0.1.0";

src = ./.;

cargoLock = {
lockFile = ./Cargo.lock;
};

doInstallCheck = true;

installCheckPhase = ''
$out/bin/basic
'';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use rand::Rng;

fn main() {
let mut rng = rand::thread_rng();

// Always draw zero :).
let roll: u8 = rng.gen_range(0..1);
assert_eq!(roll, 0);
}
8 changes: 8 additions & 0 deletions pkgs/build-support/rust/test/import-cargo-lock/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ callPackage }:

{
basic = callPackage ./basic { };
gitDependency = callPackage ./git-dependency { };
gitDependencyNoRev = callPackage ./git-dependency-no-rev { };
maturin = callPackage ./maturin { };
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "git-dependency-no-rev"
version = "0.1.0"
authors = ["Daniël de Kok <me@danieldk.eu>"]
edition = "2018"

[dependencies]
rand = { git = "https://github.com/rust-random/rand.git" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ rustPlatform }:

rustPlatform.buildRustPackage {
pname = "git-dependency-no-rev";
version = "0.1.0";

src = ./.;

cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"rand-0.8.3" = "0ya2hia3cn31qa8894s3av2s8j5bjwb6yq92k0jsnlx7jid0jwqa";
};
};

doInstallCheck = true;

installCheckPhase = ''
$out/bin/git-dependency-no-rev
'';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use rand::Rng;

fn main() {
let mut rng = rand::thread_rng();

// Always draw zero :).
let roll: u8 = rng.gen_range(0..1);
assert_eq!(roll, 0);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "git-dependency"
version = "0.1.0"
authors = ["Daniël de Kok <me@danieldk.eu>"]
edition = "2018"

[dependencies]
rand = { git = "https://github.com/rust-random/rand.git", rev = "0.8.3" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ rustPlatform }:

rustPlatform.buildRustPackage {
pname = "git-dependency";
version = "0.1.0";

src = ./.;

cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"rand-0.8.3" = "0l3p174bpwia61vcvxz5mw65a13ri3wy94z04xrnyy5lzciykz4f";
};
};

doInstallCheck = true;

installCheckPhase = ''
$out/bin/git-dependency
'';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use rand::Rng;

fn main() {
let mut rng = rand::thread_rng();

// Always draw zero :).
let roll: u8 = rng.gen_range(0..1);
assert_eq!(roll, 0);
}
Loading

0 comments on commit d3769e4

Please sign in to comment.