Commit Graph

623 Commits

Author SHA1 Message Date
zowoq
6085b3b7f7
Merge pull request #215408 from astro/rust-sysroot 2023-03-24 15:44:59 +10:00
Vladimír Čunát
0a88dec4f3
Merge branch 'staging-next' into staging 2023-03-21 12:57:16 +01:00
Louis Blin
e2825fb1b5 rustPlatform.importCargoLock: improved semantics for 'extraRegistries' option
Clearer API following the recommendation on the pull request that
introduced this option a few days ago:
https://github.com/NixOS/nixpkgs/pull/221381#discussion_r1141226293
2023-03-20 14:40:04 -04:00
Winter
5686f0064d rustPlatform.importCargoLock: add support for git dependencies that use workspace inheritance
Rust 1.64.0 added support for workspace inheritance, which allows
for crates to inherit values such as dependency version constraints or
package metadata information from their workspaces [0].

This works by having workspace members specify a value as a table, with
`workspace` set to true. Thus, supporting this in importCargoLock is as
simple as walking the crate's Cargo.toml, replacing inherited values
with their workspace counterpart.

This is also what a forthcoming Cargo release will do for `cargo vendor` [1],
but we can get ahead of it ;)

[0]: https://blog.rust-lang.org/2022/09/22/Rust-1.64.0.html#cargo-improvements-workspace-inheritance-and-multi-target-builds
[1]: https://github.com/rust-lang/cargo/pull/11414
2023-03-18 20:34:59 +01:00
github-actions[bot]
ad9c132f13
Merge staging-next into staging 2023-03-18 06:01:47 +00:00
figsoda
1792c4f8c7
Merge pull request #221104 from figsoda/crate 2023-03-17 21:28:07 -04:00
figsoda
7d23bdd221
Merge pull request #221413 from alyssais/rustc-musl 2023-03-17 17:25:30 -04:00
Louis Blin
48dc4386a4 rustPlatform.importCargoLock: support extra registries
This is useful to teach `importCargoLock` how to download crates from a
registry other than crates.io. Specifically, we publish our own crates
to an internal registry and this feature lets us pull from it seamlessly.
2023-03-16 19:13:33 -04:00
Alyssa Ross
470e6130b3
rust: fix overriding rust flags on musl
If RUSTFLAGS is set in the environment, Cargo will ignore rustflags
settings in its TOML configuration.  So setting RUSTFLAGS=-g (like
separateDebugInfo does) to generate debug info breaks
dynamically-linked Rust packages on musl.  This breakage is visible
for any packages that call into C dynamic libraries.  If the binary is
linked directly to a C dynamic library, it will fail to build, and if
it depends on a Rust library which links a C dynamic library, it will
segfault at runtime when it tries to call a function from the C
library.  I noticed this because pkgsMusl.crosvm is broken for this
reason, since it sets separateDebugInfo = true.

It shouldn't be possible to end up with broken binaries just by using
RUSTFLAGS to do something innocuous like enable debug info, so I think
that, even though we liked the approach of modiyfing .cargo/config
better at the time, it's become clear that it's too brittle, and we
should bite the bullet and patch the compiler instead when targetting
musl.  It does not appear to be necessary to modify the compiler at
all when cross-compiling /from/ dynamically-linked Musl to another
target, so I'm only checking whether the target system is
dynamically-linked Musl when deciding whether to make the modification
to the compiler.

This reverts commit c2eaaae50d
("cargoSetupHook: pass host config flags"), and implements the
compiler patching approach instead.
2023-03-16 02:29:46 +00:00
Martin Weinelt
3b8cf43350
Merge remote-tracking branch 'origin/master' into staging-next
Conflicts:
- pkgs/development/python-modules/imageio/default.nix
- pkgs/development/python-modules/pytest-order/default.nix
2023-03-15 02:01:15 +01:00
figsoda
62327ff6a9 fetchCrate: add unpack option to use fetchurl instead of fetchzip 2023-03-13 22:15:02 -04:00
Alyssa Ross
cd6818baf7
rustPlatform: forward unpack hooks to cargo fetch
Sometimes it's more ergonomic to set up the build environment in
hooks, to add to the default behaviour rather than replacing it.  It's
very surprising that the fetcher works fine with a custom unpackPhase,
but not with custom preUnpack or postUnpack.

Packages that use preUnpack or postUnpack and Cargo FODs seem to be
very rare.  I searched Nixpkgs for files containing one of
"cargoHash", "cargoDeps", and "cargoSha256", and one of "preUnpack" or
"postUnpack", and only found two such packages:
python3.pkgs.tokenizers and rustdesk.  Neither of their Cargo FOD
hashes are affected by this change.  So if that's any indication,
we're unlikely to be breaking many out-of-tree hashes with these
changes either.
2023-03-14 00:26:11 +00:00
Astro
9d1aafcdeb build-support/rust: allow cross-compiling the sysroot 2023-03-12 12:24:23 +01:00
Astro
63c8961f8b build-support/rust/sysroot: let cargo-src crate become no_std 2023-03-12 12:24:23 +01:00
Astro
87837a5fcf build-support/rust/sysroot: update Cargo.lock 2023-03-12 12:24:23 +01:00
Astro
2d2aa463dd build-rust-package: call sysroot/src with the expected lib parameter 2023-03-12 12:24:23 +01:00
Adam Joseph
6406751e1c build-rust-crate: point rustc to the correct linker
I've been having problems with cross-compiled builds of crate2nix'ed
crates failing at the final link step because rustc defaults to `cc`
(from $PATH) as the linker.  This is, of course, the buildPlatform's
linker.  See example below.

Let's tell rustc unambiguously to use the target platform linker.

I've added the flag *before* `baseRustcOpts` because that includes
`extraRustcOpts`.  This ensures that users of the package can
override this with their own `-C linker` choice.

Unfortunately because build-rust-crate (currently) sets
binary-crate-specific flags when building library crates, this
causes a global rebuild of everything that uses buildRustCrate.

```
rust_html2text> Building html2text (src/main.rs)
rust_html2text> Running rustc --crate-name html2text src/main.rs --crate-type bin -C opt-level=3 -C codegen-units=1 --remap-path-prefix=/build=/ --extern argparse=/nix/store/y4m00swv4aka73vfl9rbb2abq7y1vmg6-rust_argparse-0.2.2-aarch64-unknown-linux-gnu-lib/lib/libargparse-5dc9592bf7.rlib --extern html2text=/nix/store/j3p1pgh3iyjdhp8681zab7yjwpzs4kg2-rust_html2text-0.4.4-aarch64-unknown-linux-gnu-lib/lib/libhtml2text-d6e376dd78.rlib --cfg feature="default" --target aarch64-unknown-linux-gnu --edition 2021 --out-dir target/bin -L dependency=target/deps --cap-lints allow --color always
rust_html2text> error: linking with `cc` failed: exit status: 1
rust_html2text>   |
rust_html2text>   = note: "cc" "/build/rustcgg6BNC/symbols.o" "target/bin/html2text.html2text.a6551786-cgu.0.rcgu.o" "target/bin/html2text.82b4749yb02lf9k.rcgu.o" "-Wl,--as-needed" "-L" "target/deps" "-L" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/nix/store/j3p1pgh3iyjdhp8681zab7yjwpzs4kg2-rust_html2text-0.4.4-aarch64-unknown-linux-gnu-lib/lib/libhtml2text-d6e376dd78.rlib" "/nix/store/rbal9imr15fb674mwjjhd75p45ajql25-rust_unicode-width-0.1.10-aarch64-unknown-linux-gnu-lib/lib/libunicode_width-a3b8f6ce6d.rlib" "/nix/store/5j6pf8bbk3920klpn2zlv4q6d0bbjk26-rust_html5ever-0.26.0-aarch64-unknown-linux-gnu-lib/lib/libhtml5ever-7c514c0d78.rlib" "/nix/store/2k5ncqkn1ngq1q7mjccsh3di2r9x7b3m-rust_log-0.4.17-aarch64-unknown-linux-gnu-lib/lib/liblog-bbb1d2abad.rlib" "/nix/store/yklfi1k7iaw4khbay1avvgmrrnb3sw8f-rust_markup5ever-0.11.0-aarch64-unknown-linux-gnu-lib/lib/libmarkup5ever-fa92c5d6d6.rlib" "/nix/store/cp0raar4bvl551n7521rrvk8cka9dkcv-rust_string_cache-0.8.4-aarch64-unknown-linux-gnu-lib/lib/libstring_cache-3ae24c7e2e.rlib" "/nix/store/w45v78l58wcpnwrhf83ysix1nb3177d3-rust_precomputed-hash-0.1.1-aarch64-unknown-linux-gnu-lib/lib/libprecomputed_hash-dc2ae88c2c.rlib" "/nix/store/d5gv2frk6aav6y9hwv0w6a8fw3wd2sh3-rust_serde-1.0.152-aarch64-unknown-linux-gnu-lib/lib/libserde-881972cdc0.rlib" "/nix/store/zapn48k4pfma65s304xfpqakprl0lz0n-rust_parking_lot-0.12.1-aarch64-unknown-linux-gnu-lib/lib/libparking_lot-a8eeb0af3b.rlib" "/nix/store/5jjayhj13mcy52ybdagvmdqvp2i2kfc6-rust_parking_lot_core-0.9.5-aarch64-unknown-linux-gnu-lib/lib/libparking_lot_core-7b731df3c6.rlib" "/nix/store/nka1dv01my0ivfpv14jc3969lala9yj0-rust_libc-0.2.139-aarch64-unknown-linux-gnu-lib/lib/liblibc-7a4e291ec8.rlib" "/nix/store/40i3315py200bzjd9nzds6l73drfs5rq-rust_cfg-if-1.0.0-aarch64-unknown-linux-gnu-lib/lib/libcfg_if-36a232ac81.rlib" "/nix/store/mj38xbiskkz39gdwm6sg4xr73k3wiixh-rust_smallvec-1.10.0-aarch64-unknown-linux-gnu-lib/lib/libsmallvec-e668ae4802.rlib" "/nix/store/j15ldgxp88dz06cgfl6ksvbnhk5kg1l7-rust_lock_api-0.4.9-aarch64-unknown-linux-gnu-lib/lib/liblock_api-bd3f4cafbe.rlib" "/nix/store/w7f8q6idl5pl7hssfq0gn2h7nr33556g-rust_scopeguard-1.1.0-aarch64-unknown-linux-gnu-lib/lib/libscopeguard-2ef121592d.rlib" "/nix/store/4vsr3kifpdb1dkac5j2l9rafjsypcdj6-rust_once_cell-1.17.0-aarch64-unknown-linux-gnu-lib/lib/libonce_cell-8a9caa1812.rlib" "/nix/store/sivn38f9bffq7pwiwhrisbpk16slci51-rust_phf-0.10.1-aarch64-unknown-linux-gnu-lib/lib/libphf-c5c68bbc03.rlib" "/nix/store/dfl1c90pddaf9kqpdpmy546s21vmgy90-rust_phf_shared-0.10.0-aarch64-unknown-linux-gnu-lib/lib/libphf_shared-0da64f265f.rlib" "/nix/store/vcq3zp2l7bjldknvg3894nvmafndl4p3-rust_siphasher-0.3.10-aarch64-unknown-linux-gnu-lib/lib/libsiphasher-57560c9ade.rlib" "/nix/store/ysycp6rj77l0ymdrvcndpdykidyhjapd-rust_tendril-0.4.3-aarch64-unknown-linux-gnu-lib/lib/libtendril-c7a013fefe.rlib" "/nix/store/fgc3j0s0rlpmgi4avy0gvkcwx813v74v-rust_utf-8-0.7.6-aarch64-unknown-linux-gnu-lib/lib/libutf8-a31a1dfa96.rlib" "/nix/store/vkqy90dmg0h4qkmcfr8nfa8l8nv3b0wa-rust_futf-0.1.5-aarch64-unknown-linux-gnu-lib/lib/libfutf-74eb51f206.rlib" "/nix/store/lpy11ncw9hjp8514y6qh5dalz73cammg-rust_new_debug_unreachable-1.0.4-aarch64-unknown-linux-gnu-lib/lib/libdebug_unreachable-798bc09edd.rlib" "/nix/store/972pbraa9nx2w2r9rgw9ihxcnnyjj7pq-rust_mac-0.1.1-aarch64-unknown-linux-gnu-lib/lib/libmac-5f22857ac1.rlib" "/nix/store/y4m00swv4aka73vfl9rbb2abq7y1vmg6-rust_argparse-0.2.2-aarch64-unknown-linux-gnu-lib/lib/libargparse-5dc9592bf7.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libstd-6dfb26da5641245c.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libpanic_unwind-17fe203b55bc0ad4.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libobject-fcd32571c597d1d2.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libmemchr-9bea2c040bb6c3bb.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libaddr2line-50f1168d6595a5a4.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libgimli-ab3cce9cf22eb54e.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_demangle-195cb4e110dfcf64.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libstd_detect-6e60da103a3086ca.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libhashbrown-1967902c6f47ed4d.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libminiz_oxide-e67a9163a25e7f3e.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libadler-3815f9058309549d.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-761ef9e339906fe9.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libunwind-8882f6e2dc28b312.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libcfg_if-50cea0e51cd18705.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/liblibc-da1cdc1aff291994.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/liballoc-7019f3ab0cdf1cfd.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_std_workspace_core-1944b99f47799b69.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libcore-06b1d7727c68137a.rlib" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib/libcompiler_builtins-bc101476bec73dcf.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/nix/store/bhx7z81c5w1d7b1qny9s198mkqzj6a1r-rustc-1.67.0/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-o" "target/bin/html2text" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-Wl,-O1" "-nodefaultlibs"
rust_html2text>   = note: /nix/store/2arn2lz66q49qhiyldkahiphfmzlixdf-binutils-2.40/bin/ld: target/bin/html2text.html2text.a6551786-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
rust_html2text>           /nix/store/2arn2lz66q49qhiyldkahiphfmzlixdf-binutils-2.40/bin/ld: target/bin/html2text.html2text.a6551786-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
rust_html2text>           /nix/store/2arn2lz66q49qhiyldkahiphfmzlixdf-binutils-2.40/bin/ld: target/bin/html2text.html2text.a6551786-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
rust_html2text>           /nix/store/2arn2lz66q49qhiyldkahiphfmzlixdf-binutils-2.40/bin/ld: target/bin/html2text.html2text.a6551786-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
```
2023-03-09 19:45:33 -08:00
github-actions[bot]
c8c1423cd9
Merge master into staging-next 2023-03-09 00:02:23 +00:00
cidkidnix
856936abc8 buildRustCrate: add libiconv to nativeBuildInputs on darwin
Fixes linker errors while building build.rs where it tries to link libiconv but cannot find it.

Rust executable build for Darwin need libiconv, and indeed buildInputs already has this case handled.
So why is another change needed? Suppose we are cross compiling from Darwin (the build platform) to something else, and the package has a build.rs build script.
The build script is built for the build platform (Darwin) and is also a regular Rust executable, needing libiconv, but due to cross compilation (and strict deps) we need an extra nativeBuildInput.
2023-03-08 14:39:25 -06:00
figsoda
eedbf71d0d
Merge pull request #218472 from figsoda/cargo-setup 2023-03-03 19:40:55 -05:00
Martin Weinelt
b44213aac1
Merge pull request #219011 from wegank/rust-cleanup
rust, firefox, spidermonkey: cleanup
2023-03-03 14:23:20 +00:00
oxalica
de408167ed buildRustPackage: don't passthru cargoDeps
`cargoDeps` is already passed as `mkDerivation` arguments, and should
not be `passthru`ed again. This fixes the mismatch of `drv.cargoDeps`
and the actual dependency when the original derivation is overriden.
2023-03-02 10:20:15 +10:00
Weijia Wang
39a2b0b3bf rust: remove aarch64-linux workaround
This commit reverts #209113, since aarch64-linux now uses GCC 12 by default.
2023-03-01 18:42:07 +02:00
figsoda
3e18607be3 rustPlatform.cargoSetupHook: dereference symlinks in cargoDeps
unpackFile doesn't dereference symlinks if cargoDeps is a directory, and
some cargo builds run into permission issues because the files the
symlinks point to are not writable.
2023-02-26 11:55:50 -05:00
github-actions[bot]
399e2c78d4
Merge master into staging-next 2023-02-26 06:01:09 +00:00
figsoda
6fcd1dcb0b rustPlatform.importCargoLock: passthru lockFile
This is to make it possible to implement support for updating
`Cargo.lock`s in nix-update by exposing the path to the `Cargo.lock`
file
2023-02-26 00:46:36 -05:00
Winter
115e3413e1 rustPlatform.importCargoLock: add support for v1 lock files
v1 lock files (generated by default by Cargo versions 1.40 and below)
use a single table, `metadata`, to store the checksums of packages.

The primary motivation for doing this now is that we're considering
vendoring all Cargo lock files in Nixpkgs, some packages still use it
(e.g. cargo-asm), and adding support for it doesn't increase the
complexity of the function. No matter the outcome of the vendoring
discussion, this is a nice thing to have because Cargo still supports v1
lock files.
2023-02-26 00:45:40 -05:00
github-actions[bot]
164a7e44c7
Merge master into staging-next 2023-02-16 18:01:12 +00:00
Jordan Isaacs
66dccd88b8
build-support/rust/lib: Add toTargetVendor
Used in cases where you need to get the vendor of a target. Such as when
you need to perform dependency resolution outside of Cargo (eg in
Kolloch's crate2nix).
2023-02-15 20:37:45 -05:00
github-actions[bot]
58cfebde3e
Merge staging-next into staging 2023-02-15 00:02:50 +00:00
Bob van der Linden
e3a10a12c7 rustPlatform.cargoSetupHook: improve cargoHash instructions
Currently cargo-setup-hook instructs the builder upon cargoSha256 or
cargoHash being out-of-date compared to the Cargo.lock file.

The instructions can be simplified a bit, because nowadays it is fine to
keep a hash empty, instead of filling it with
`0000000000000000000000000000000000000000000000000000`.

Nix nowadays outputs SRI hashes, which should usually be placed in
`cargoHash` instead of `cargoSha256`, but the instructions are still
only referring to `cargoSha256`.

Lastly, the output of Nix doesn't include `got: sha256: ` anymore, as it
now outputs `got: sha256-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=`.
It would be nice to make it clear that the trailing `=` is important as
well, so the full example SRI hash is mentioned.
2023-02-14 16:14:08 -05:00
Felix Buehler
cdb39a86e0 treewide: use optionalString 2023-02-13 21:52:34 +01:00
Artturin
4e3dcf364e treewide: makeSetupHook deps -> propagatedBuildInputs 2023-02-07 21:02:00 +02:00
github-actions[bot]
41e5bd55d5
Merge master into staging-next 2023-02-07 06:01:28 +00:00
Winter
e2b092fc52 Revert "rustPlatform.bindgenHook: use the same clang/libclang as rustc"
This reverts commit 46ee37ca1d, as it breaks
anything that uses libcxx on Darwin, as well as cross-compilation to at
least armv6l.

As there's no clear solution at this time, reverting it is the best
option, as this only reduces build time closure size (something we can
arguably live with).

https://github.com/NixOS/nixpkgs/pull/207352#issuecomment-1418363441
https://github.com/NixOS/nixpkgs/pull/207352#issuecomment-1420124250
2023-02-07 00:04:19 -05:00
github-actions[bot]
ba176ec75c
Merge staging-next into staging 2023-02-01 06:01:40 +00:00
zowoq
c6d203467a buildRustPackage: drop cacert
not needed here, set by fetchCargoTarball
2023-02-01 06:53:43 +10:00
linsui
9bc4f34034 cargo: move cert info to fetch-cargo-tarball
As proposed in https://github.com/NixOS/nixpkgs/pull/82496, we should only set the related env vars for the fetcher instead of breaking the function of cargo itself.
2023-02-01 06:53:43 +10:00
Adam Joseph
eb98fefe24 build-rust-crate: handle ILP32 platforms correctly
This commit corrects the value of `CARGO_CFG_TARGET_POINTER_WIDTH`
for ILP32 machines like the Apple Watch and mips64n32.
2023-01-23 12:10:58 -08:00
Yureka
8647006492
rustPlatform.importCargoLock: pass allRefs to builtins.fetchGit (#211298) 2023-01-18 01:57:36 +01:00
Adam Joseph
f1bce90517 default-crate-overrides.nix: add gtk-sys (gtk3) 2023-01-15 15:43:47 -08:00
Mateusz Kowalczyk
22770e2381 buildRustCrate: fixup integration test mod name
Fixes #204051. I have tried this on the reproducer stated in the ticket.

```
[nix-develop]$ $(nix-build  -I nixpkgs=/home/shana/programming/nixpkgs --no-out-link)/tests/foo

running 1 test
test check_module_name ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
```
2023-01-14 14:18:09 -05:00
github-actions[bot]
49722fd14a
Merge master into staging-next 2023-01-13 18:01:34 +00:00
Adam Joseph
9297b5382f
default-crate-overrides.nix: add graphene-sys 2023-01-13 16:43:39 +00:00
Adam Joseph
e40de94c42 default-crate-overrides: add pkg-config to evdev-sys 2023-01-13 16:31:15 +00:00
Adam Joseph
62d571148a default-crate-overrides: servo-fontconfig-sys needs fontconfig 2023-01-13 16:18:27 +00:00
figsoda
b9259df616 rustPlatform.buildRustPackage: fix cross compiling auditable packages 2023-01-12 12:22:59 -05:00
Martin Weinelt
c1e6c6af69 Merge remote-tracking branch 'origin/master' into staging-next 2023-01-11 03:51:33 +01:00
Artturi
27c1ec2ecf
Merge pull request #209816 from Artturin/deprecate-top-level-platform-aliases 2023-01-09 22:15:50 +02:00
Artturin
2eeb34c273 treewide: {build,host,target}Platform -> stdenv.{build,host,target}Platform 2023-01-09 21:13:22 +02:00
github-actions[bot]
b60b0a223e
Merge master into staging-next 2023-01-08 06:01:06 +00:00
Nick Cao
46ee37ca1d rustPlatform.bindgenHook: use the same clang/libclang as rustc 2023-01-08 15:22:04 +10:00
figsoda
45fc1f185f rustPlatform.fetchCargoTarball: default outputHashAlgo to sha256 2023-01-07 17:53:21 -05:00
Winter
8442601c64 rust: fix on aarch64-linux by using GCC 11 and passing -lgcc
This change switches to using GCC 11 by default on aarch64-linux, as well as passing `-lgcc` to the linker, per #201485.

See #201254 and #208412 for wider context on the issue.
2023-01-04 18:15:20 -05:00
Sergei Trofimovich
092d57c076 Merge remote-tracking branch 'origin/staging-next' into staging
Conflicts:
    pkgs/development/tools/language-servers/ansible-language-server/default.nix
2022-12-28 09:35:37 +00:00
Artturi
f93a244d7c
Merge pull request #190613 from amjoseph-nixpkgs/pr/build-rust-crate/atk 2022-12-27 19:49:40 +02:00
Artturi
c584919520
Merge pull request #190614 from amjoseph-nixpkgs/pr/build-rust-crate/pangocairo 2022-12-27 19:48:23 +02:00
Artturi
3cb4b5cac4
Merge pull request #190603 from amjoseph-nixpkgs/pr/build-rust-crate/g_k4 2022-12-27 19:37:35 +02:00
Adam Joseph
b1a9bf530c
default-crate-overrides.nix: add pango-sys (#190604) 2022-12-27 19:36:30 +02:00
Artturi
88eb7d5d3f
Merge pull request #186761 from amjoseph-nixpkgs/pr/rust/default-crate-overrides/fix 2022-12-27 19:35:06 +02:00
Artturi
c1deac22a5
Merge pull request #190602 from amjoseph-nixpkgs/pr/build-rust-crate/cairo-sys-rs 2022-12-27 19:32:13 +02:00
Atemu
3eec3c8fed buildRustPackage: remove git from nativeBuildInputs
Having git in nativeBuildInputs causes thousands of rebuilds when git is touched
because every derivation that somehow transiently depends on a rust package will
change. See https://github.com/NixOS/nixpkgs/pull/205682 for instance.

AFAICT git is unused. Only the fetcher needs git which it has already.

Fixes https://github.com/NixOS/nixpkgs/issues/205804
2022-12-27 18:37:21 +10:00
figsoda
b6c0e7f563
Merge pull request #205935 from figsoda/cargo-lock
rustPlatform.importCargoLock: add allowBuiltinFetchGit option
2022-12-25 19:38:36 -05:00
figsoda
ca370da6d3
Merge pull request #206270 from figsoda/rustc
rustc: 1.65.0 -> 1.66.0
2022-12-23 18:09:56 -05:00
Winter
b1834a461e Revert "rustc: propagate libiconv on darwin"
This reverts commit b6fc00b8f4.

Rust 1.66.0 contains a fix for libiconv being linked unconditionally on macOS, but this only applies to packages that don't depend on older versions of `libc`.

For now, let's go back to including libiconv in `buildInputs` by default for packages that use `buildRustPackage`. As packages bump their `libc` versions, we can eventually stop including it by default, and manually add it where needed.
2022-12-23 13:55:46 -05:00
github-actions[bot]
dc7ebb0163
Merge staging-next into staging 2022-12-18 18:01:41 +00:00
figsoda
ec8cb34358 treewide: fix typos 2022-12-17 19:39:44 -05:00
Vladimír Čunát
59a68f487d
Merge branch 'staging-next' into staging 2022-12-16 11:20:50 +01:00
Artturin
05a2dfd674 lib.replaceChars: warn about being a deprecated alias
replaceStrings has been in nix since 2015(nix 1.10)

so it is safe to remove the fallback

d6d5885c15
2022-12-15 22:25:51 +02:00
figsoda
cce3dc63a0 rustPlatform.importCargoLock: add allowBuiltinFetchGit option 2022-12-13 11:27:26 -05:00
figsoda
cfc6213879
Merge pull request #204686 from figsoda/auditable
rustPlatform.buildRustPackage: build auditable binaries
2022-12-09 16:46:45 -05:00
figsoda
a6137b73f9 cargo-auditable-cargo-wrapper: init 2022-12-07 00:23:43 -05:00
John Ericson
8890f3b893
Merge pull request #203766 from obsidiansystems/build-rust-crate-link-flags
buildRustCrate: Support `cargo:rustc-link-arg` and some friends from build.rs
2022-12-06 21:48:07 -05:00
figsoda
0e5137f267 rustPlatform.buildRustPackage: make it not auditable by default 2022-12-05 18:46:00 -05:00
figsoda
ff93685724
Merge pull request #199371 from figsoda/fetchCrate
fetchCrate: rewrite in terms of fetchzip
2022-12-05 18:15:33 -05:00
figsoda
8a041c63c0 rustPlatform.buildRustPackage: build auditable binaries 2022-12-05 16:18:17 -05:00
Sandro
4484c12d81
Merge pull request #196449 from natto1784/crate-overrides 2022-12-05 22:00:51 +01:00
John Ericson
fde3b57055 buildRustCrate: Support cargo:rustc-link-arg and some friends from build.rs
See https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-link-argfor details. We are supporting:

 - `cargo:rustc-link-arg`
 - `cargo:rustc-link-arg-bins`
 - `cargo:rustc-link-arg-lib`

at this time.

`cargo:rustc-link-arg-bin` is left as future work because the per-binary
flag keeping is more difficult.
2022-11-30 11:40:50 -05:00
figsoda
d3eb606296 rustPlatform.buildRustPackage: add useNextest option to check with cargo-nextest 2022-11-28 17:00:17 -05:00
figsoda
0643540f97 rustPlatform.cargoNextestHook: init 2022-11-28 16:59:52 -05:00
figsoda
82fe76d1cd carnix,cratesIO: remove 2022-11-22 14:10:25 -05:00
Artturin
341e6fd558 splice.nix: start deprecating nativeDrv and crossDrv 2022-11-19 00:04:54 +02:00
Aaron Andersen
adbe2f532c
Merge pull request #199300 from Fuuzetsu/escape-rust-exports
rustBuildCrate: properly handle cargo env pragmas with spaces
2022-11-16 07:15:25 -05:00
github-actions[bot]
020ea91183
Merge master into staging-next 2022-11-10 00:02:27 +00:00
John Ericson
e94d54dd86 build-support/rust/lib: Add toTargetFamily
Taken from https://github.com/kolloch/crate2nix/pull/255/files, it
belongs in Nixpkgs not crate2nix.

I have been using that P.R. for a few months without incident.
2022-11-09 15:52:01 -05:00
figsoda
9508a4ac68 fetchCrate: rewrite in terms of fetchzip 2022-11-03 12:33:27 -04:00
Mateusz Kowalczyk
233205c464
rustBuildCrate: properly handle cargo env pragmas with spaces
There are two problems: first that we end up splitting on spaces in the
loop. Even when that is fixed, we still would split on spaces in the
`export` inside the loop. We need to guard against both.

Fixes #199298

Confirmed that it fixes the case mentioned in the ticket:

```console
[nix-develop]$ $(nix-build -I nixpkgs=/home/shana/programming/nixpkgs Cargo.nix -A rootCrate.build  --no-out-link)/bin/nix-rustc-env-escape-repro
Expecting three words, got: first second third
```

I think this is going to cause a rebuild of every Rust package even if
they were unaffected, not much we can do here.
2022-11-03 14:49:24 +09:00
Yureka
c2eaaae50d cargoSetupHook: pass host config flags 2022-10-30 18:55:47 +01:00
Amneesh Singh
74de121572
default-crate-overrides: add alsa-lib for alsa-sys crate
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2022-10-18 00:03:14 +05:30
Vladimír Čunát
6565abc264
Merge branch 'master' into staging-next 2022-10-08 10:20:07 +02:00
Alex Martens
bac7ee3208 rustc: fix build for no_std targets 2022-10-07 07:35:29 -07:00
github-actions[bot]
e879e7d54e
Merge master into staging-next 2022-10-02 00:04:43 +00:00
Vladimír Čunát
292756e9ff
Merge #190093: rustc: propagate libiconv on darwin
...into staging
2022-09-28 09:45:11 +02:00
figsoda
dc19b95eff rustPlatform.buildRustPackage: remove unused function 2022-09-26 21:53:37 -04:00
Ivar Scholten
987d32bbac buildRustPackage: dont rely on NIX_BUILD_TOP in cargoSetupPostPatchHook
This breaks the builder when a nix-shell or keepBuildTree is used. The
issue occurs because paths to cargo lockfiles are read with NIX_BUILD_TOP,
which is not reliable.

This breaks a nix-shell because NIX_BUILD_TOP simply is not set, causing
an invalid path to be used. This can be worked around using
NIX_BUILD_TOP=$PWD, but that obviously is not great.

This breaks keepBuildTree because it changes the working directory to a
different path than NIX_BUILD_TOP. Since the lockfiles are copied based
on the working directory, but read based on NIX_BUILD_TOP, this causes
the hook to not be able to find them.

This was solved by both reading these files based on the working directory,
using absolute paths to avoid having to traverse back in the directory tree.

Fixes: #138554
2022-09-25 16:17:36 +02:00
Benjamin Hipple
1066f0ef92
Merge pull request #178964 from linsui/cargo
fetch-cargo-tarball: allow use index mirror
2022-09-17 12:04:27 -04:00
Adam Joseph
31e5930b57 default-crate-overrides.nix: add pangocairo-sys 2022-09-10 02:06:30 -07:00
Adam Joseph
2ab5cfe7ce default-crate-overrides.nix: import pango 2022-09-10 02:06:29 -07:00
Adam Joseph
02de33cacd default-crate-overrides.nix: add atk-sys 2022-09-09 19:51:43 -07:00
Adam Joseph
c804cea71d default-crate-overrides.nix: add {gtk4,gdk4,gsk4}-sys 2022-09-09 18:58:59 -07:00
Adam Joseph
4ceec72751 default-crate-overrides.nix: add cairo-sys-rs 2022-09-09 18:58:21 -07:00
Winter
b6fc00b8f4 rustc: propagate libiconv on darwin
Rust binaries are unconditionally linked to libiconv on Darwin (see https://github.com/rust-lang/libc/issues/2870). We already add it as a dependency in `buildRustPackage`, so let's go a step further and propagate it.
2022-09-06 23:17:56 -04:00
John Ericson
6a0d3815a3
Merge pull request #187975 from marius851000/rustRequiredFeatures
buildRustCrate: Do not compile binaries if all the requiredFeatures aren't enabled.
2022-08-25 17:45:52 -04:00
Bernardo Meurer
fbd067fef0
Merge pull request #187841 from amjoseph-nixpkgs/pr/rust/toTargetArch
build-support/rust: toTargetArch: strip off endianness
2022-08-25 10:22:34 -03:00
marius david
3291bda7b6 buildRustCrate: Do not compile binaries if all the requiredFeatures aren't enabled. 2022-08-23 13:09:33 +02:00
Adam Joseph
8682bd0a81 build-support/rust: toTargetArch: strip off endianness
`toTargetArch` in `pkgs/build-support/rust/lib/default.nix` is used to
set `CARGO_CFG_TARGET_ARCH`.  This environment variable is supposed to
be the `<arch>` portion of an LLVM-style platform name:

```
<arch><sub>-<kernel>-<libc><abi>
```

Note that the pointer-width (the "64" in "x86_64" and "mips64") is
part of `<arch>`, but the endianness (the `_be` in `aarch64_be`) is
*not*.

Unfortunately at the moment nixpkgs' parsed `cpuType` has no way to
query for the three subparts (name, pointer-width, and
subarch/endianness), nor any way to ask for just the first two parts.

For now, this commit simply fixes the problem in the two cases that
matter: `mips64el` and `powerpc64le`, which I believe are the only two
platforms supported by both rust and nixpkgs which have a
"subarchitecture".
2022-08-22 02:27:06 -07:00
linsui
7d8f9ee62e build-rust-package: cargoSha256 and cargoHash must not be null 2022-08-21 17:09:09 +08:00
linsui
51a6ac79d2 fetch-cargo-tarball: fix for packages without dep 2022-08-21 16:28:28 +08:00
linsui
656e3022f4 fetch-cargo-tarball: allow use index mirror 2022-08-21 16:28:28 +08:00
Adam Joseph
6d9a490980 default-crate-overrides.nix: remove unnecessary attrs from previous commit
Sorry, I should have removed these before submitting https://github.com/NixOS/nixpkgs/pull/186748
2022-08-15 01:08:13 -07:00
github-actions[bot]
4e717ab958
Merge staging-next into staging 2022-08-15 06:01:47 +00:00
Adam Joseph
58e5bd56d6 default-crate-overrides.nix: add libevdev for evdev-rs 2022-08-14 21:20:55 -07:00
Yureka
51c62063e3 cargoSetupHook: set crt-static
Tell rust if we want our binaries linked statically or dynamically.
Otherwise the compiler will always produce statically linked binaries for musl
targets, as this is the default.
2022-08-13 15:25:41 +02:00
Yureka
66ac47bdf6 cargoSetupHook: remove unneeded rustflags for aarch64+static cross
The linked issue was resolved upstream and the `-lgcc` is no longer required
since https://github.com/rust-lang/compiler-builtins/pull/377 was merged.
2022-08-13 15:24:14 +02:00
John Ericson
cc29693a09 buildRustCrate: Add support for standard library deps
We are replicating one mechanism behind `-Z build-std`.

There isn't yet crate2nix support for this, but one can (and I do) add
the missing stdlib deps (for this feature to pick up) with overrides.
2022-08-01 15:34:49 -04:00
Martin Weinelt
b4988e25b5 maturin: 0.12.9 -> 0.13.0 2022-07-21 22:35:32 +02:00
John Ericson
39811b1da9 build-support/rust/lib: make arch and os functions respect target JSON 2022-07-18 22:54:19 -04:00
Ben Wolsieffer
882741f632 tests.buildRustCrate: add rcgen test
rcgen depends on ring, and therefore exercises support for static libraries
2022-06-14 20:09:33 -04:00
Ben Wolsieffer
a6bbe3f794 buildRustCrate: pass link flags when building libraries
With Rust 1.61, it is necessary to link to external static/dynamic libaries
when building the rlib that uses them, rather than when linking the final
binary. In fact, it is no longer necessary to specify the libraries to link
when building the final binary, but the library search path flags must still
be included.
2022-06-14 20:09:33 -04:00
Artturin
9ca1379bdf fetchCargoTarball: allow adding nativeBuildInputs 2022-05-28 21:55:39 +03:00
Artturin
36ad5b9b96 buildRustPackage: add missing attr to remove
cargoUpdateHook is used in cargoDeps
2022-05-28 21:06:27 +03:00
sternenseemann
357da6c296 buildRustPackage: make cargoDeps logic easier to follow
The old logic flow had the structure

  if ( … ) {
    if ( … ) {
      …
    } else {
      …
    }
  } else {
    …
  }

which is quite hard to follow in Nix. Instead we ensure that no if
expression is inside a then branch.

This change is zero rebuild, as no logic was changed.
2022-05-13 08:18:39 +10:00
ilkecan
d6bd313f07 buildRustCrate: set meta.mainProgram to crateName 2022-05-05 14:25:27 +00:00
David Scherer
13a9006ec3 Fix determinism by defaulting codegenUnits to 1, not NIX_BUILD_CORES 2022-05-01 11:48:32 -04:00
Mateusz Kowalczyk
f6897d23f4 buildRustCrate: make codegen-units configurable
This parameter is being set to `$NIX_BUILD_CORES` by default. This is a
standard practice but there's a suspicion that this can produce broken
builds. For some details see
https://github.com/cargo2nix/cargo2nix/issues/184 . As a
work-around/test, it'd be good if codegen-units can be set to something
constant, such as `1`. This PR allows it.

Note that the default of `$NIX_BUILD_CORES` is preserved so this MR
causes no change in default behaviour and no rebuilds.
2022-05-01 11:48:32 -04:00
Yusuf Bera Ertan
e2a3a3c690
default-crate-overrides: only add Security to propagatedBuildInputs on darwin for security-framework-sys 2022-04-28 21:24:46 +03:00
Faye Duxovni
bc5e8ae506 buildRustCrate: don't try to set CARGO_FEATURE_ variables for dep: features
These features are internal-only, have special characters that bash
doesn't support in variable names, and aren't normally given
environment variables by cargo as far as I can tell.
2022-04-16 06:53:45 -04:00
sohalt
3619ffaeb6 rust: fix importCargoLock for repositories without toplevel Cargo.toml
Some crates do not have a Cargo.toml at the top-level, but only in
nested directories. Before this change importCargoLock used to fail with:

error: manifest path `/nix/store/some-store-path/Cargo.toml` does not exist
2022-03-17 00:15:56 -04:00
Guillaume Girol
bedabfbcef rustPlatform.bindgenHook: init 2022-02-22 19:37:07 +01:00
github-actions[bot]
b74b591fbe
Merge master into staging-next 2022-01-20 00:01:46 +00:00
Andreas Rammhold
31e5b8dc21
Remove myself from maintainers
I don't have time and energy to deal with all of this anymore.
2022-01-20 00:24:52 +01:00
K900
deb7e771aa rust/hooks: ensure the build output ends up in the right place
Otherwise cargoInstallHook can fail to find and actually install it.
2021-12-26 11:04:07 +03:00
John Ericson
f721e0f849
Merge pull request #145107 from Ericson2314/buildRustCrate-sysroot
build-support/rust: Fix sysroot for cross
2021-11-24 18:44:13 -05:00
Andreas Rammhold
48de1b8ed8
Merge pull request #142699 from steveeJ-forks/fix-import-cargo-lock
rust: find nested packages in git repositories
2021-11-17 13:31:57 +01:00
John Ericson
05efb8ed91 build-support/rust/sysroot/src: Use dont* instead of phase list
Making this separate commit because the original was moved out just the
way it was done before.
2021-11-08 21:38:58 +00:00
John Ericson
c9c3de0131 Update script as rust-src layout has changed
Use stub lib so `core` and `alloc` are handled symmetrically.
2021-11-08 20:38:59 +00:00
John Ericson
cbd00bab80 build-support/rust: Split out sysroot src derivation
Hoping to make it usable for `buildRustCrate` too.
2021-11-08 20:38:59 +00:00
John Ericson
4f81865aa1 Merge remote-tracking branch 'upstream/master' into staging-next 2021-11-07 20:51:04 +00:00
John Ericson
18ed048c7b build-support/rust: Organize
- `toRustTarget` and friends pulled out from rust tools into rust
   library. Since they don't depend on any packages they can be more
   widely useable.

 - `build-rust-package` gets its own directory

 - `fetch-cargo-tarball` gets its own directory
2021-11-07 14:16:49 -05:00
Alyssa Ross
3f01b576af
Merge remote-tracking branch 'nixpkgs/staging-next' into staging
Conflicts:
	nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
	nixos/doc/manual/release-notes/rl-2111.section.md
2021-10-28 16:07:38 +00:00
github-actions[bot]
a1e570b43e
Merge master into staging-next 2021-10-28 00:01:36 +00:00
Kerstin Humm
5df2d4d345
default-crate-overrides: remove two crates that are probably irrelevant 2021-10-27 22:29:10 +02:00
Kerstin Humm
f1bacf5b07 default-crate-overrides: expat-sys, glib-sys, libudev-sys, sdl2-sys, servo-fontconfig, skia-bindings 2021-10-28 03:07:33 +09:00
figsoda
5a08a28803 rustPlatform: add support for features 2021-10-27 08:08:03 -04:00
Stefan Junker
445510ed69 rust/import-cargo-lock: hopefully make nested crate test work on macos 2021-10-25 01:11:45 +02:00
Stefan Junker
f9a340a916 rust/import-cargo-lock: add test git-dependency-rev-non-workspace-nested-crate 2021-10-24 20:27:42 +02:00
Stefan Junker
b2aa19efe7 rust: find nested packages in git repositories
this mimics the heuristic cargo uses for finding crates in their git
repositories ([cargo-issue-1462]).

[cargo-issue-1462]: https://github.com/rust-lang/cargo/issues/1462
2021-10-24 01:52:44 +02:00
github-actions[bot]
2d8f645c79
Merge master into staging-next 2021-10-20 06:01:15 +00:00
figsoda
f441e6b7f4 buildRustPackage,fetchCargoTarball: accept empty hashes 2021-10-19 20:56:46 -04:00
figsoda
836e6d3e02 buildRustPackage: remove unused arguments, minor styling changes 2021-10-19 20:11:28 -04:00
figsoda
d81f8fa0a4
Merge pull request #138822 from figsoda/fix-cargo-check-type
[staging] rustPlatform.cargoCheckHook: respect cargoCheckType
2021-10-11 15:54:00 -04:00
John Ericson
811f849961 buildRustCrate: Don't override the linker during cross
lld is sometimes need. The caller can do that instead.
2021-10-06 16:59:53 -04:00
John Ericson
4430761186 buildRustCrate: Add extraRustcOptsForBuild
`extraRustcOpts` should not be used for build.rs, lest it contain
host-platform-specific options during cross builds.
2021-10-06 16:59:52 -04:00
John Ericson
0ee5640d78 buildRustCrate: Fix extra cross args
Do proper list separation, use ld not cc because rustc doesn't `-Wl,`.
2021-10-06 16:59:19 -04:00
figsoda
22efdc986c rustPlatform.cargoCheckHook: respect cargoCheckType 2021-09-21 13:00:25 -04:00
Bruno Bigras
c426b46aee defaultCrateOverrides: add rdkafka-sys 2021-09-21 12:07:25 -04:00
Daniël de Kok
24b5074348
Merge pull request #137395 from dermetfan/cargo-lock-restricted
importCargoLock: introduce alternative parameter `lockFileContents`
2021-09-20 18:05:08 +02:00
Robin Stumm
d3018c4522 importCargoLock: introduce alternative parameter lockFileContents
In restricted mode (and therefore with flakes) `builtins.readFile` may not be the result of `builtins.toFile`,
making it impossible to use a generated lockFile (with or without IFD),
and thereby causing evaluation to fail if `system != builtins.currentSystem` on Hydra
so the jobs are not delegated to eligible build machines that support that system.

This is done in a way that avoids rebuilds.
2021-09-20 14:54:40 +02:00
Daniël de Kok
6f2ce2a65e treewide: remove danieldk as maintainer from a set of packages
I currently do not have much time to work on nixpkgs. Remove
myself as a maintainer from a bunch of packages to avoid that
people are waiting on me for a review.
2021-09-12 14:42:12 +00:00
Sandro
bcced5deff
Merge pull request #137204 from SuperSandro2000/fetchCargoTarball
rust.fetchCargoTarball: remove phases
2021-09-11 19:31:03 +02:00
Jörg Thalheim
f21712edaa importCargoLock: add docs how to run these tests 2021-09-11 11:14:58 +02:00
Yureka
34cc1821db
importCargoLock: add tests for branch and tag 2021-09-11 09:19:18 +02:00
Yureka
00b1ac5b23 importCargoLock: git deps with rev, branch or tag
Previously importCargoLog only recognized git dependencies with `rev =`.
This adds support for git dependencies with `branch =` or `tag =`.
2021-09-10 23:00:46 +02:00
Sandro Jäckel
012685943f
rust.fetchCargoTarball: remove phases 2021-09-09 19:17:48 +02:00
happysalada
c9f0c6f115 build-rust-crate: add global libiconv darwin buildInputs 2021-09-04 12:03:36 +09:00
happysalada
0585c981f1 build-rust-crate: nixpkgs-fmt 2021-09-04 12:03:36 +09:00
happysalada
0e8d59e3cb default-crate-overrides: nixpkgs-fmt 2021-09-04 12:03:36 +09:00
Robin Stumm
3bdfca4491 buildRustPackage: remove unused parameter 2021-08-20 12:46:05 +02:00
Robert Hensing
a13aa64bd3 build-support/rust: remove unused runCommandNoCC 2021-08-15 17:36:41 +02:00
tekeri
2419ea4aff rust: fix build of pam-sys package 2021-08-15 15:55:20 +09:00
Romanos Skiadas
23dd37dd5e rustPlatform.importCargoLock: add an assert for old Cargo.locks
near the end of 2019, the default Cargo.lock format was changed to
[[package]]
checksum = ...

This is what importCargoLock assumes. If the crate had not been `cargo
update`'d with a more recent toolchain than the one with the new
format as default, importCargoLock would fail when trying to access
pkg.checksum.

I ran into such a case (shamefully, in my own crate) and it took me a
while to figure out what was going on, so here is an assert with a
more user friendly message and a hint.
2021-07-18 18:19:50 +03:00
pandaman64
c39040195f build-rust-crate: disable incremental builds
According to rustc implementation[1], `-C incremental=no` enables
incremental builds with directory name `no`. This patch removes the
`-C incremental` argument to disable incremental builds.

[1]: ee86f96ba1/compiler/rustc_session/src/options.rs (L918-L919)
2021-07-09 22:55:38 +09:00
Daniël de Kok
1da0b1dbc9
Merge pull request #122158 from danieldk/import-cargo-lock
rustPlatform.buildRustPackage: support direct use of Cargo.lock
2021-05-28 12:07:25 +02:00
Daniël de Kok
d3769e43c3 rustPlatform.importCargoLock: add test cases for importCargoLock 2021-05-28 08:01:28 +02:00
Daniël de Kok
b3969f3ad7 rustPlatform.buildRustPackage: support direct use of Cargo.lock
This change introduces the cargoLock argument to buildRustPackage,
which can be used in place of cargo{Sha256,Hash} or cargoVendorDir. It
uses the importCargoLock function to build the vendor
directory. Differences compared to cargo{Sha256,Hash}:

- Requires a Cargo.lock file.
- Does not require a Cargo hash.
- Retrieves all dependencies as fixed-output derivations.

This makes buildRustPackage much easier to use as part of a Rust
project, since it does not require updating cargo{Sha256,Hash} for
every change to the lock file.
2021-05-28 08:01:28 +02:00
Daniël de Kok
2f46d77e28 rustPlatform.importCargoLock: init
This function can be used to create an output path that is a cargo
vendor directory. In contrast to e.g. fetchCargoTarball all the
dependent crates are fetched using fixed-output derivations. The
hashes for the fixed-output derivations are gathered from the
Cargo.lock file.

Usage is very simple, e.g.:

importCargoLock {
  lockFile = ./Cargo.lock;
}

would use the lockfile from the current directory.

The implementation of this function is based on Eelco Dolstra's
import-cargo:

https://github.com/edolstra/import-cargo/blob/master/flake.nix

Compared to upstream:

- We use fetchgit in place of builtins.fetchGit.
- Sync to current cargo vendoring.
2021-05-28 08:01:25 +02:00
Daniël de Kok
7eddab91f5
Merge pull request #123867 from danieldk/maturin-0.10.5
maturin: 0.10.4 -> 0.10.6
2021-05-25 16:01:47 +02:00
Daniël de Kok
11307c1d47 maturinBuildHook: add rustc to deps
maturin 0.10.5 uses rustc -vV to find the host:

e886c85f5a

We now need to make rustc visible to the hook for maturin to work
properly.
2021-05-21 07:51:27 +02:00
Pavol Rusnak
252bf94a74 rust: 1.51.0 -> 1.52.0 2021-05-08 11:42:10 -07:00
Andrew Childs
7869d16545 llvmPackages: Multuple outputs for everythting
Also begin to start work on cross compilation, though that will have to
be finished later.

The patches are based on the first version of
https://reviews.llvm.org/D99484. It's very annoying to do the
back-porting but the review has uncovered nothing super major so I'm
fine sticking with what I've got.

Beyond making the outputs work, I also strove to re-sync the packages,
as they have been drifting pointlessly apart for some time.

----

Other misc notes, highly incomplete

- lvm-config-native and llvm-config are put in `dev` because they are
  tools just for build time.

- Clang no longer has an lld dep. That was introduced in
  db29857eb3, but if clang needs help
  finding lld when it is used we should just pass it flags / put in the
  resource dir. Providing it at build time increases critical path
  length for no good reason.

----

A note on `nativeCC`:

`stdenv` takes tools from the previous stage, so:

1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.stdenv.cc`: `(?0, ?1, x)`

while:

1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.targetPackages`: `(x, x, ?2)`
3. `pkgsBuildBuild.targetPackages.stdenv.cc`: `(?1, x, x)`
2021-04-30 05:41:00 +00:00
zseri
ff5ff66ef3 build-rust-crate: disable incremental builds 2021-04-08 10:45:56 +02:00
Jonathan Ringer
042adf08d1 cargo/hooks: allow hooks to be disabled 2021-03-08 19:17:03 +01:00
Ana Hobden
a84cb88c47 rustPlatform.buildRustPackage: support debug builds
Signed-off-by: Ana Hobden <operator@hoverbear.org>
2021-03-04 07:16:29 -08:00
Max Hausch
ebe3ae4d4d
buildRustPackage: Add cargoTestFlags
This makes it possible to pass flags to `cargo test`, which is needed if
a crate is compiled with custom feature flags.
2021-03-02 09:45:26 +01:00
Daniël de Kok
c50a347cb5 buildRustPackage: use checkType argument
The `checkType` argument of buildRustPackage was not used anymore
since the refactoring of `buildRustPackage` into hooks. This was
an oversight that is fixed by this change.

The check type can also be passed directly to cargoCheckHook using the
`cargoCheckType` environment variable.
2021-02-26 11:57:27 +01:00
Frederik Rietdijk
c456a2512f Merge master into staging-next 2021-02-26 10:25:13 +01:00
Daniël de Kok
1df80d2bad diesel-cli: use comma-separated features, use buildAndTestSubdir 2021-02-16 08:09:17 +01:00
Daniël de Kok
087ab3db9c buildRustPackage: handle cargoBuildFlags in cargoBuildHook 2021-02-16 08:09:17 +01:00
Daniël de Kok
05e40e79a8 buildRustPackage: factor out check phase to cargoCheckHook
API change:

`cargoParallelTestThreads` suggests that this attribute sets the
number of threads used during tests, while it is actually a boolean
option (use 1 thread or NIX_BUILD_CORES threads). In the hook, this
is replaced by a more canonical name `dontUseCargoParallelTests`.
2021-02-16 08:09:15 +01:00
Daniël de Kok
9757c7101a buildRustPackage: factor out install phase to cargoInstallHook 2021-02-15 12:17:18 +01:00
Daniël de Kok
d92396039d buildRustPackage: add cargoDepsName attribute
The directory in the tarball of vendored dependencies contains `name`,
which is by default set to `${pname}-${version}`. This adds an
additional attribute to permit setting the name to something of the
user's choosing.

Since `cargoSha256`/`cargoHash` depend on the name of the directory of
vendored dependencies, `cargoDepsName` can be used to e.g. make the
hash invariant to the package version by setting `cargoDepsName =
pname`.
2021-02-15 07:06:31 +01:00
Daniël de Kok
160cf87086 rustPlatform.maturinBuildHook: init
This build hook can be used to build Python packages using maturin.
2021-02-12 08:40:43 +01:00
Daniël de Kok
7876d1c252 fetchCargoTarball: set default sourceRoot to the empty string
This avoids that non-buildRustPackage derivations need to specify
sourceRoot when the fetcher performs root stripping.
2021-02-11 20:00:13 +01:00
Daniël de Kok
a8efb2053f buildRustPackage: factor out build phase to cargoBuildHook
- API change: remove the `target` argument of `buildRustPackage`, the
  target should always be in sync with the C/C++ compiler that is used.

- Gathering of binaries has moved from `buildPhase` to `installPhase`,
  this simplifies the hook and orders this functionality logically
  with the installation logic.
2021-02-11 20:00:12 +01:00
Daniël de Kok
d083f412fa buildRustPackage: factor out setting up .cargo/config to cargoSetupHook
This makes it possible to reuse this functionality as a hook in
derivations that do not use buildRustPackage.
2021-02-10 07:01:24 +01:00
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