From a9cade2ca2a88da2eebb5d0904b69b0b845a17d4 Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Wed, 9 Oct 2019 15:07:36 +0200 Subject: [PATCH] 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) --- lib.nix | 10 +++++++--- test.nix | 6 +++--- test/{binary => dummyfication}/Cargo.lock | 18 ++++++++++-------- test/{binary => dummyfication}/Cargo.toml | 3 ++- test/dummyfication/build.rs | 3 +++ test/{binary => dummyfication}/src/exe.rs | 0 6 files changed, 25 insertions(+), 15 deletions(-) rename test/{binary => dummyfication}/Cargo.lock (98%) rename test/{binary => dummyfication}/Cargo.toml (81%) create mode 100644 test/dummyfication/build.rs rename test/{binary => dummyfication}/src/exe.rs (100%) diff --git a/lib.nix b/lib.nix index 339642b..a4f1da1 100644 --- a/lib.nix +++ b/lib.nix @@ -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") diff --git a/test.nix b/test.nix index 2502a5d..b88b740 100644 --- a/test.nix +++ b/test.nix @@ -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 diff --git a/test/binary/Cargo.lock b/test/dummyfication/Cargo.lock similarity index 98% rename from test/binary/Cargo.lock rename to test/dummyfication/Cargo.lock index daa581d..83038e1 100644 --- a/test/binary/Cargo.lock +++ b/test/dummyfication/Cargo.lock @@ -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" diff --git a/test/binary/Cargo.toml b/test/dummyfication/Cargo.toml similarity index 81% rename from test/binary/Cargo.toml rename to test/dummyfication/Cargo.toml index 229fe72..3e960db 100644 --- a/test/binary/Cargo.toml +++ b/test/dummyfication/Cargo.toml @@ -1,8 +1,9 @@ [package] -name = "binary" +name = "dummyfication" version = "0.1.0" authors = ["nicolas "] edition = "2018" +build = "build.rs" [dependencies] rand = "0.7.0" diff --git a/test/dummyfication/build.rs b/test/dummyfication/build.rs new file mode 100644 index 0000000..d00823e --- /dev/null +++ b/test/dummyfication/build.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Running a custom build..."); +} diff --git a/test/binary/src/exe.rs b/test/dummyfication/src/exe.rs similarity index 100% rename from test/binary/src/exe.rs rename to test/dummyfication/src/exe.rs