Remove build scripts during dummyfication

Otherwise builds fail with an error like:

Compiling simple-dep v0.1.0 (/private/var/folders/5h/b11m6fxj2tqgbxwz5bgjy42c0000gn/T/nix-build-some-name.drv-0/dummy-src)
error: couldn't read build.rs: No such file or directory (os error 2)
This commit is contained in:
Bas van Dijk 2019-10-09 15:07:36 +02:00
parent e344a3a480
commit a9cade2ca2
6 changed files with 25 additions and 15 deletions

10
lib.nix
View file

@ -91,9 +91,13 @@ rec
config = writeText "config" cargoconfig;
cargolock' = builtinz.writeTOML "Cargo.toml" cargolock;
fixupCargoToml = cargotoml:
# Since we pretend everything is a lib, we remove any mentions of
# binaries
removeAttrs cargotoml ["bin" "example" "lib" "test" "bench" ];
let attrs =
# Since we pretend everything is a lib, we remove any mentions
# of binaries
removeAttrs cargotoml [ "bin" "example" "lib" "test" "bench" ];
in attrs // lib.optionalAttrs (lib.hasAttr "package" attrs) {
package = removeAttrs attrs.package [ "build" ];
};
cargotomlss = writeText "foo"
(lib.concatStrings (lib.mapAttrsToList
(k: v: "${k}\n${builtinz.writeTOML "Cargo.toml-ds-aa" (fixupCargoToml v)}\n")

View file

@ -80,10 +80,10 @@ rec
(pkgs.lib.cleanSource ./test/simple-dep)
{};
binary = naersk.buildPackage
(pkgs.lib.cleanSource ./test/binary)
dummyfication = naersk.buildPackage
(pkgs.lib.cleanSource ./test/dummyfication)
{};
binary_test = pkgs.runCommand "binary-test" { buildInputs = [ binary ]; }
dummyfication_test = pkgs.runCommand "dummyfication-test" { buildInputs = [ dummyfication ]; }
"my-bin > $out";
workspace = naersk.buildPackage

View file

@ -1,3 +1,5 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "aho-corasick"
version = "0.7.6"
@ -6,14 +8,6 @@ dependencies = [
"memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "binary"
version = "0.1.0"
dependencies = [
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "c2-chacha"
version = "0.2.2"
@ -28,6 +22,14 @@ name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "dummyfication"
version = "0.1.0"
dependencies = [
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "getrandom"
version = "0.1.12"

View file

@ -1,8 +1,9 @@
[package]
name = "binary"
name = "dummyfication"
version = "0.1.0"
authors = ["nicolas <nicolas@nmattia.com>"]
edition = "2018"
build = "build.rs"
[dependencies]
rand = "0.7.0"

View file

@ -0,0 +1,3 @@
fn main() {
println!("Running a custom build...");
}