Commit Graph

558 Commits

Author SHA1 Message Date
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