Commit Graph

182 Commits

Author SHA1 Message Date
Andreas Rammhold
5ad83267ed
buildRustCrate: reflow the way extraRustcOpts is constructed
This should make it more obvious that we have three parts to it and not
just one long gibberish string that makes up all of it.
2019-12-11 23:27:58 +01:00
Andreas Rammhold
d37f001164
buildRustCrate: rename makeDeps function to mkRustcDepArgs
This should carry the function better then `makeDeps` as it isn't
producing deps but the rustc arguments required to link against those.
2019-12-11 23:23:55 +01:00
Andreas Rammhold
f4aeabd04a
buildRustCrate: document and cleanup the symbol seeding
That code had been in the derivation for a while but no explanation was
given why that is needed. It might be helpful to our future selfs to
document why things are done the way they are.
2019-12-11 23:23:55 +01:00
Andreas Rammhold
db55d1f89d
buildRustCrate: use tr instead of sed (it reads a bit nicer)
I already have a few changes in here that will trigger rebuilds so I
might as well do that substitution now.
2019-12-11 22:40:19 +01:00
Andreas Rammhold
50b2ef28f7
buildRustCrate: move the color loggign & remove some runtime checks
The expression is already long and confusing enough without the color
stuff sprinkled in. Moving it to a dedicated file makes sense.

I switched a bit of the color support code to pure Nix since there
wasn't much point in doing that in bash while we can just do it in Nix.
2019-12-11 22:35:44 +01:00
Andreas Rammhold
0aac0e8d2c
buildRustCrate: builtins -> lib where possible
We can just use `lib` instead of `builtins` in all cases but the
`hashString` case. Also changed a few lines to make use of some optional
helpers from lib.
2019-12-11 22:01:36 +01:00
Jörg Thalheim
435c3ecde7
rust: add support for armv6l-linux and armv7l-linux (#73472)
rust: add support for armv6l-linux and armv7l-linux
2019-11-29 12:47:15 +00:00
Andreas Rammhold
1b748554d5
buildRustCrate: add lib output
This cuts down the dependency tree on some rust builds where a crate not
just exposes a binary but also a library. `$out/lib` contained a bunch
of extra support files that among other information carry linker flags
(including the full path to link-time dependencies). Worst case this led
to some binary outputs depending on the full build closure of rust
crates.

Moving all the `$out/lib` files to `$lib/lib` solves this nicely.

`lib` might be a bit weird here as they are most of the time just rlib
files (rust libraries). Those are essential only required during
compilation but they can also be shared objects (like with traditional
C-style packages). Which is why I went with `lib` for the new output.

One of the caveats we are running into here is that we do not (always)
know ahead of time of a crate produces just a library or just a binary.
Cargo allows for some ambiguity regarding whether or not a crate
provides one, two, … binaries and libraries as it's outputs. Ideally we
would be able to rely on the `crateType` entirely but so far that isn't
the case. More work on that area might show how difficult that actually
is.
2019-11-26 15:05:01 +01:00
Ben Wolsieffer
83ac9c07e4 rust: add support for armv6l-linux and armv7l-linux 2019-11-23 19:19:31 -05:00
Jörg Thalheim
56240d7f20
Merge pull request #71899 from decentriq/aslemmer/build-rust-package-add-target
build-support/rust: Add target option
2019-11-01 15:46:47 +00:00
exfalso
a588b1dfbc build-support/rust: Add target option 2019-10-24 11:39:08 +01:00
Andreas Rammhold
d13022417f buildRustPackage: support checkFlags and checkFlagsArray 2019-10-20 02:31:13 +02:00
zimbatm
f8d67ec135
buildRustPackage: add verifyCargoDeps option
One issue with cargoSha256 is that it's hard to detect when it needs to
be updated or not. It's possible to upgrade a package and forget to
update cargoSha256 and run with old versions of the program or
libraries.

This commit introduces `verifyCargoDeps` which, when enabled, will check
that the Cargo.lock is not out of date in the cargoDeps by comparing it
with the package source.
2019-09-30 17:09:52 +00:00
Joachim F
ad773d31e2
Merge pull request #69345 from joachifm/feat/split-version
Replace uses of splitString for splitting version strings
2019-09-27 06:19:18 +00:00
Joachim Fasting
bad07dfac5
tree-wide: replace uses of splitString "." with lib.versions
Quoting from the splitString docstring:

   NOTE: this function is not performant and should never be used.

This replaces trivial uses of splitString for splitting version
strings with the (potentially builtin) splitVersion.
2019-09-26 17:42:49 +02:00
Mario Rodas
aed74e8284
cargo-vendor: drop
Cargo 1.37 imported `cargo-vendor` as built-in command [1]

[1] https://github.com/rust-lang/cargo/pull/6869
2019-09-22 20:20:20 -05:00
Yegor Timoshenko
17a6ae03cb
Merge pull request #66617 from transumption-unstable/201908/rust-aarch64-linux-musl
buildRustPackage: fix cross-compilation to aarch64-unknown-linux-musl
2019-09-19 01:21:55 +00:00
Yegor Timoshenko
08b73c1d58
buildRustPackage: fix cross-compilation to aarch64-unknown-linux-musl 2019-09-12 09:00:17 +00:00
Andreas Rammhold
a69a6c1117
Merge pull request #68296 from danieldk/crateRenames
buildRustCrate: add support for renaming crates
2019-09-10 10:57:54 +02:00
Daniël de Kok
85c6d72011 buildRustCrate: add support for renaming crates
Before this change, buildRustCrate always called rustc with

--extern libName=[...]libName[...]

However, Cargo permits using a different name under which a dependency
is known to a crate. For example, rand 0.7.0 uses:

[dependencies]
getrandom_package = { version = "0.1.1", package = "getrandom", optional = true }

Which introduces the getrandom dependency such that it is known as
getrandom_package to the rand crate. In this case, the correct extern
flag is of the form

--extern getrandom_package=[...]getrandom[...]

which is currently not supported. In order to support such cases, this
change introduces a crateRenames argument to buildRustCrate. This
argument is an attribute set of dependencies that should be renamed. In
this case, crateRenames would be:

{
  "getrandom" = "getrandom_package";
}

The extern options are then built such that if the libName occurs as
an attribute in this set, it value will be used as the local
name. Otherwise libName will be used as before.
2019-09-08 19:17:52 +02:00
volth
08f68313a4 treewide: remove redundant rec 2019-08-28 11:07:32 +00:00
volth
35d68ef143 treewide: remove redundant quotes 2019-08-26 21:40:19 +00:00
Frederik Rietdijk
c68f58d95c Merge master into staging-next 2019-08-17 09:30:16 +02:00
Yegor Timoshenko
da3da08cdf
buildRustPackage: link against pthreads-w32 on x86_64-pc-mingw32 2019-08-15 08:44:54 +00:00
Yegor Timoshenko
0fcffe88db
buildRustPackage: support cross-compilation to x86_64-pc-mingw32 2019-08-15 08:44:54 +00:00
Frederik Rietdijk
4ca8e53e1d Merge staging-next into staging 2019-08-01 09:44:06 +02:00
Frederik Rietdijk
55e4555b77 Merge master into staging-next 2019-08-01 09:42:54 +02:00
Adelbert Chang
4403d44763 buildRustPackage: fix cargo flag for release/debug build (#61521)
Previous behavior did not actually allow for "debug" build as it would
try to pass --debug to cargo, which is not a valid flag.
2019-07-31 13:19:01 +01:00
Atkins
fb961d1cdb
buildRustPackage: Remove unneeded cat 2019-07-30 12:27:16 +01:00
Atkins
626ccd7121
buildRustPackage: Avoid altering .cargo/config in source 2019-07-30 12:26:27 +01:00
worldofpeace
b1bc0645ea gdk-pixbuf: rename from gdk_pixbuf 2019-07-22 18:50:57 -04:00
Mario Rodas
da492d230b
buildRustPackage: by default use Rust's platforms 2019-07-21 00:00:00 -05:00
worldofpeace
3f4a353737 treewide: use dontUnpack 2019-07-01 04:23:51 -04:00
volth
f3282c8d1e treewide: remove unused variables (#63177)
* treewide: remove unused variables

* making ofborg happy
2019-06-16 19:59:05 +00:00
Peter Kolloch
61ac550082 Fix #60125 - buildRustCrate: Always set CARGO_PKG_VERSION_PRE and CARGO_PKG_HOMEPAGE
(as cargo does)
2019-04-23 23:41:57 +02:00
Andreas Rammhold
1bb989ca70 cargo-vendor: fix build on Darwin
This is supposedly fixing the build of the cargo crate on Drawin [1].

[1] https://github.com/NixOS/nixpkgs/pull/57017#pullrequestreview-228868016
2019-04-21 12:11:54 +02:00
Andreas Rammhold
2e2f7cba90 cargo: fix build on Darwin
This is supposedly fixing the build of the cargo crate on Drawin [1].

[1] https://github.com/NixOS/nixpkgs/pull/57017#pullrequestreview-228868016
2019-04-21 12:11:54 +02:00
Alexander Krupenkin
a4902a33bf cargo-vendor: 0.1.13 -> 0.1.23 2019-04-21 12:11:54 +02:00
Frederik Rietdijk
d108b49168 Merge master into staging-next 2019-04-09 16:38:35 +02:00
Andreas Rammhold
1462ef27bb
Merge pull request #58394 from P-E-Meunier/carnix-0.10
Carnix: 0.9 -> 0.10
2019-04-08 20:46:14 +00:00
Jan Tojnar
cb1a20499a
Merge branch 'master' into staging 2019-04-05 11:37:15 +02:00
Michael Eden
f93470d7a3 rust: set PKG_CONFIG_ALLOW_CROSS conditionally in buildRustPackage 2019-03-29 11:11:00 -04:00
Michael Eden
bdd3c3fdcb rust: allow building in debug or release modes 2019-03-29 11:11:00 -04:00
Michael Eden
60761e65ba rust: move releaseDir to target/release in the buildPhase 2019-03-29 11:11:00 -04:00
Jörg Thalheim
912dca193a rust: fix cross-compilation 2019-03-29 11:11:00 -04:00
Andreas Rammhold
e0b4356c0d
Merge pull request #57936 from andir/build-rust-crate-nix-build-cores
buildRustCrate: use $NIX_BUILD_CORES for each of the crates
2019-03-29 12:29:43 +01:00
Pierre-Étienne Meunier
81d9ddab1a Carnix: 0.9 -> 0.10 2019-03-26 18:54:28 +00:00
Teo Klestrup Röijezon
5eec83eb83 buildRustCrate: Fix include filter
buildRustCrate has a handy `include` helper, that only imports those whitelisted
files and folders to the store.

However, the function's matching logic is broken and includes all files,
regardless of whether or not they're whitelisted, as long as the whitelist
contains at least one name (regardless of whether that name exists). This is
because it doesn't take into account that
`lib.strings.removePrefix "foo" "bar" == "bar"` (that is, paths that don't match
the prefix are passed straight through).
2019-03-25 15:24:42 +01:00
Andreas Rammhold
4c89619152
buildRustCrate: use $NIX_BUILD_CORES for each of the crates 2019-03-20 02:19:50 +01:00
Jörg Thalheim
cd498f7c80
Merge pull request #56634 from marsam/buildrustcreate-pname-attribute
buildRustPackage: Allow pname attribute
2019-03-11 10:08:00 +00:00