Commit Graph

278 Commits

Author SHA1 Message Date
Pavol Rusnak
90f7338112
treewide: stdenv.lib -> lib 2021-01-24 01:49:49 +01:00
Justin Humm
9038cc62fd
defaultCrateOverrides: override crates necessary for building sequoia
See https://git.sr.ht/~erictapen/sequoia for a flake using these
overrides.
2021-01-08 17:27:43 +01:00
Justin Humm
9df8a98fac
defaultCrateOverrides: pkgconfig -> pkg-config 2021-01-08 17:26:05 +01:00
Daniël de Kok
67a10c88bb buildRustPackage: add cargoHash for SRI hashes of vendored deps
`buildRustPackage` currently accepts `cargoSha256` as a hash for
vendored dependencies. This change adds `cargoHash` which accepts SRI
hashes, setting `outputHashAlgo` to `null`.

The hash mismatch message still uses `cargoSha256` as an example,
which it probably should until we completely switch to SRI hashes.
2020-12-31 11:18:11 +01:00
John Ericson
ddeef0d322 tests.buildRustCrate: Fix after hashing method change
As @lopsided98 points out in #105305, since the hashes are now target
sensative, and until we find reason to actually care to test what they
are exactly, we are best just normalizing them away in the tests.
2020-12-19 19:05:07 +00:00
Daniël de Kok
e87d457564 buildRustCrate: set NUM_JOBS to NIX_BUILD_CORES
Bofore this change, NUM_JOBS was set to 1. Some crates for building
C/C++ code (e.g. the cc and cmake crates), rely on this variable to
set the number of jobs. As a consequence, we were compiling embedded
libraries serially. Change this to NIX_BUILD_CORES to permit parallel
builds.

Prior discussion:

https://github.com/NixOS/nixpkgs/pull/50452#issuecomment-439407547
2020-12-03 12:44:12 +01:00
John Ericson
77816426b6
Merge pull request #105305 from lopsided98/build-rust-crate-platform-hash
buildRustCrate: add host platform to rlib hash suffix
2020-11-29 10:50:25 -05:00
Ben Wolsieffer
8c479059b9 buildRustCrate: add host platform to rlib hash suffix 2020-11-28 22:25:11 -05:00
Aaron Janse
512458c68a add sysroot lockfile update script then run it 2020-10-17 01:34:51 -07:00
Aaron Janse
d884b2d877 NEEDS REVIEW: enable sysroot differently 2020-10-17 00:48:38 -07:00
Aaron Janse
7c92361028 enforce noCheck when useSysroot 2020-10-17 00:47:14 -07:00
Aaron Janse
dec97eb3e9 minor clean up 2020-10-17 00:45:27 -07:00
Aaron Janse
e745f9333e fix whitespace 2020-10-15 19:03:10 -07:00
Aaron Janse
d906fda8d2 parameterize rustcSrc 2020-10-15 17:27:51 -07:00
Aaron Janse
a153be896f use rustcSrc 2020-10-14 22:54:04 -07:00
John Ericson
c0df12de5d rust: Add support for managing target JSON in Nix 2020-10-14 04:20:23 +00:00
John Ericson
6866f26c89 Merge remote-tracking branch 'upstream/master' into aj-rust-custom-target 2020-10-14 02:54:31 +00:00
Aaron Janse
3f3491d64d fix some whitespace 2020-10-12 18:41:13 -07:00
Aaron Janse
0fca6ba580 fix compile error 2020-10-12 14:48:07 -07:00
Aaron Janse
f8ea4e0c3d makeRustPlatform: support custom targets 2020-10-08 14:32:49 -07:00
Ben Wolsieffer
91bc6128b9 buildRustCrateTests: support cross-compilation 2020-09-29 14:33:49 -04:00
Ben Wolsieffer
f0fdecfbb4 buildRustCrate: fix target config environment variables on 32-bit ARM 2020-09-29 01:40:06 -04:00
John Ericson
cffc0eaa98
Merge pull request #99050 from lopsided98/buildrustcrate-cross
buildRustCrate: support cross compilation
2020-09-29 00:13:26 -04:00
Ben Wolsieffer
a0e7613509 defaultCrateOverrides: move pkgconfig to nativeBuildInputs
This fixes cross-compiling.
2020-09-28 19:47:52 -04:00
Ben Wolsieffer
295a6690f9 buildRustCrate: support cross compilation 2020-09-28 19:46:04 -04:00
zowoq
e4c71e6c6c buildRustPackage: support setting test-threads 2020-09-24 07:19:58 +10:00
Shea Levy
b694eb6e6a
firmware-manager: Init at 0.1.1 2020-09-23 06:01:05 -04:00
Evan Stoll
19cb34b04b
buildSupport.rust: fix typo in verifyCargoDeps message (#97058) 2020-09-05 17:04:32 -04:00
Daniël de Kok
923c9f62c4 fetchCrate: accept pname besides crateName
This enables short argument attrsets similar to fetchPypi:

src = fetchCrate {
  inherit pname version;
  sha256 = "02h8pikmk19ziqw9jgxxf7kjhnb3792vz9is446p1xfvlh4mzmyx";
};
2020-08-28 08:34:22 +02:00
Mario Rodas
b52808f1ad
buildRustPackage: add support for parallel build 2020-08-16 10:00:00 -05:00
zowoq
1439eaf07b buildRustCrate: editorconfig fixes 2020-08-09 17:47:12 +10:00
Maximilian Bosch
d2694d936e
rustPlatform: don't install artifacts modified by checkPhase
While the artifacts from `buildPhase` should be used for testing as
well, it should be avoided that those are modified during `checkPhase`.

This can happen if a package is built e.g. with special
`cargoBuildFlags` that don't apply to the `checkPhase`. In that case, a
binary would be installed into `$out` without those flags since
`checkPhase` overrides the binary in the `target`-directory.

This patch copies the state of `target/release` into a temporary
location at the end of the `buildPhase` and installs the results from
that temporary directory into `$out` while `checkPhase` can continue
using the configured build-dir.

cc #91689
Closes #93119
Closes #91191
2020-07-15 20:08:30 +02:00
Maximilian Bosch
7713fba8f8
Revert "buildRustPackage: fix cargoBuildFlags"
This reverts commit deb78151a9.

Mixing up two distinct phases of a derivation's build is not a good idea. See
also https://github.com/NixOS/nixpkgs/pull/91689#issuecomment-657813954.
2020-07-14 17:39:09 +02:00
Flakebi
deb78151a9 buildRustPackage: fix cargoBuildFlags
When features were supplied in cargoBuildFlags, the binaries were built
with these features enabled. Unless checking was disabled, `cargo test`
was executed without these build flags, meaning the binaries were
rebuilt and overwritten without the specified features.

Fix this bug by running tests after the installation phase.
2020-07-03 08:53:57 +10:00
Andreas Rammhold
d282a7e07f
Merge pull request #90193 from danieldk/build-rs-feature-env
buildRustCrate: set CARGO_FEATURE_* when running the build script
2020-06-16 14:19:56 +02:00
Daniël de Kok
fe50bab788 buildRustCrate: set CARGO_FEATURE_* when running the build script
Cargo sets `CARGO_FEATURE_*` for all features when running a build
script:

https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts

Some crates have build scripts (e.g. openblas-src) that rely on the
feature variables being properly set.

Since we now need several representations of features, this change
also updates `createFeatures` to be a list of features, rather than
`rustc` feature arguments. `configureCrate` and `buildCrate` then
build the required representations as-needed.

Fixes #68978
2020-06-13 14:09:06 +02:00
Frederik Rietdijk
8576d24b2a Merge staging-next into staging 2020-06-08 12:08:51 +02:00
hyperfekt
0a8fb89fca rustPlatform: fix cross-compiling by using native diff 2020-06-08 10:05:00 +05:30
Frederik Rietdijk
1c68570ab2 Merge staging-next into staging 2020-06-05 19:42:16 +02:00
Jörg Thalheim
f0396574ab
buildRustPackage: add documentation on how to create cargo.lock patches 2020-06-05 10:41:46 +01:00
Vladimír Čunát
677e3960b5
Merge #82342: rustPlatform: increase build-speed of checkPhase
...for rust-packages (into staging)
2020-06-05 09:12:30 +02:00
Michael Howell
c21cbf22d0
buildRustCrate: Replace hyphen with underscore in env variables (#88054)
* Add test case for include dir
* buildRustCrate: replace hyphen with underscore in env

This fixes a bug that prevents encoding_c from building.
2020-05-26 20:52:18 +02:00
Maximilian Bosch
6b23cfe689
rustPlatform: add buildAndTestSubdir-argument
There are several tarballs (such as the `rust-lang/rust`-source) with a
`Cargo.toml` at root and several sub-packages (with their own Cargo.toml)
without using workspaces[1].

In such a case it's needed to move into a subdir to only build the
specified sub-package (e.g. `rustfmt` or `rsl`), however the artifacts
are at `/target` in the root-dir of the build environment. This breaks
the build since `buildRustPackage` searches for executables in `target`
(which is at the build-env's root) at the end of the `buildPhase`.

With the optional `buildAndTestSubdir`-argument, the builder moves into
the specified subdir using `pushd`/`popd` during `buildPhase` and
`checkPhase`.

Also moved the logic to find executables and libs to the end of the `buildPhase`
from a custom `postBuild`-hook to fix packages with custom `build`/`install`-procedures
such as `uutils-coreutils`.

[1] https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html
2020-05-13 01:47:17 +02:00
Maximilian Bosch
736462d995
rustPlatform: make it possible to override the profile for cargo test 2020-05-13 01:39:44 +02:00
Vladimír Čunát
5eaabaf089
Merge branch 'staging-next' into PR 82342
Hydra nixpkgs: ?compare=1586582
2020-05-11 08:22:59 +02:00
Maximilian Bosch
f236714d65
rustPlatform: fix log 2020-05-08 22:59:50 +02:00
Maximilian Bosch
e32c005772
rustPlatform: don't install test executables
This is done by gathering all binaries to install before running the
checkPhase.
2020-05-08 22:59:50 +02:00
Benjamin Hipple
7f845578af rustPlatform: fix bug with ambiguous diff tool
If a user provides `nativeBuildInputs = [ llvmPackages.bintools ]` or any other
package containing a `${prefix}/bin/diff`, the builder could use it instead
of the standard unix `diff`, causing a build failure.

This updates the call to specify an abspath to `diff` and avoid reliance on `PATH`.

Resolves #87081
2020-05-06 21:03:41 -04:00
Maximilian Bosch
04248f606f
rustPlatform: increase build-speed of checkPhase for rust-packages
When running `cargo test --release`, the artifacts from `buildPhase`
will be reused here. Previously, most of the stuff had to be recompiled
without optimizations.
2020-05-06 23:47:31 +02:00
Andreas Rammhold
84b91899c3
Merge pull request #85172 from andir/buildRustCrate-proc-macro
buildRustCrate: support proc-macro in default prelude
2020-04-13 23:35:19 +02:00