Commit Graph

605 Commits

Author SHA1 Message Date
Ilan Joselevich
82bd98c069
buildRustCrate: Fix rust-overlay usage (#339298) 2024-09-07 19:19:40 +03:00
éclairevoyant
3207bc2237
rustPlatform.fetchCargoTarball: support pname, version 2024-09-07 01:10:00 -04:00
éclairevoyant
1f0f59d5a1
rustPlatform.fetchCargoTarball: nixfmt 2024-09-07 01:09:59 -04:00
Ilan Joselevich
8d2ba0feae
buildRustCrate: Fix rust-overlay usage
I broke the usage of buildRustCrate with a toolchain from rust-overlay
when I added support for wasm32-unknown-unknown, this change adds
additional conditionals to restore the usage.

The toolchain can now be overriden either through
```
buildRustCrate {
  rust = toolchain;
  cargo = toolchain
}
```
or
```
buildRustCrate.override {
  rustc = toolchain;
  cargo = toolchain;
}
```
They should now be consistent with each other.
2024-09-06 16:47:29 +03:00
K900
105933cf4f pkgs/build-support/rust: fix warning-related eval issue 2024-09-03 17:04:55 +03:00
Alyssa Ross
459e958661 rust.lib: enable planned deprecation warnings 2024-09-02 21:48:21 +02:00
Alyssa Ross
2ade30b7af rustPlatform.buildRustPackage: merge custom platforms
We should constrain the set of supported platforms to the platforms
supported by the compiler.  Otherwise we run into the unfortunate
situation where setting meta.platforms in a Rust package to
platforms.unix or platforms.linux will reintroduce CPU architectures
unsupported by the compiler.
2024-09-02 08:58:07 +02:00
Adam Joseph
bbb42450c5 default-crate-overrides: proc-macro-crate assumes env::var("CARGO")
Since version 2.0.0, proc-macro-crate has assumed it can exec()
`env::var("CARGO")` in order to run `cargo locate-project`.

This commit adds a crate override to proc-macro-crate which simply writes the
path to buildPlatform.cargo into the proc-macro-crate sources.

This way we don't need to set `env.CARGO` for every build that depends on
proc-macro-crate -- if we do that, the $CARGO environment variable would be
visible to the entire build.  This could potentially lead to incredibly
hard-to-troubleshoot heisenbugs if there is some other crate that expects
`env::var("CARGO")` to exist -- that other crate would mysteriously work only
in projects that use proc-macro-crate but not anywhere else!
2024-08-23 09:36:47 +03:00
Aleksana
85bcad4a96
Merge pull request #304583 from rayanpiro/sparse-protocol
rustPlatform.importCargoLock: Adding sparse protocol
2024-08-03 21:23:13 +08:00
Vladimír Čunát
2c053848df
Merge branch 'master' into staging 2024-07-11 22:05:05 +02:00
Florian Klink
9e3825de8d defaultCrateOverrides: add extraLinkFlags to zlib
These libraries need zlib, and otherwise cause a linker error when
linking the final crate of a tauri/wry project.
2024-07-09 18:12:38 +03:00
github-actions[bot]
1f5f0905f8
Merge staging-next into staging 2024-07-06 12:01:49 +00:00
Ilan Joselevich
7220592b15
Merge pull request #324880 from flokli/defaultCreateOverridesFixes
defaultCrateOverrides: fix some gtk dependencies
2024-07-06 13:05:14 +03:00
Martin Weinelt
e7b1ee45cf
Merge remote-tracking branch 'origin/staging-next' into staging
Conflicts:
- pkgs/tools/misc/watchlog/default.nix
2024-07-06 01:52:35 +02:00
Martin Weinelt
d9610a9f2e
Merge remote-tracking branch 'origin/master' into staging-next 2024-07-06 01:51:14 +02:00
Florian Klink
0c00ad14ac defaultCrateOverrides: fix some gtk dependencies
- gobject-sys and gio-sys need pkg-config
 - add gtkx11-sys
 - add javascriptcore-rs-sys
 - add soup3-sys
 - add webkit2gtk-sys
2024-07-06 00:05:43 +03:00
Florian Klink
cbe5cf5d81 buildRustCrate: don't swallow build.rs output
This is executed curing the build, and usually quite helpful in telling
you how the build failed, if it failed.

For example, when linking against system libraries, it shows which
system lib could not be discovered, the pkg-config path used etc.

Not showing it simply removes all this, and trying to parse out the
"important" bits and only show these is probably also brittle.

The output generally isn't that spammy normally, so let's just `tee` it.
2024-07-05 21:39:08 +03:00
aleksana
07fddc62e4 buildRustPackage: deprecate cargoSha256 in favor of cargoHash 2024-07-03 21:54:26 +08:00
aleksana
a9709c299b treewide: change cargoSha256 with SRI hash to cargoHash 2024-07-03 21:53:11 +08:00
K900
665f1d6183 Merge remote-tracking branch 'origin/master' into staging-next 2024-07-02 08:32:46 +03:00
Ilan Joselevich
b870209e42
Merge pull request #323110 from thehabbos007/cargo-cdylib
buildRustCrate: add support for `cargo::rustc-cdylib-link-arg`
2024-07-01 21:09:25 +03:00
Ahmad Sattar
1cf6e5eaa1 buildRustCrate: add support for cargo::rustc-cdylib-link-arg 2024-07-01 09:29:46 +02:00
Martin Weinelt
9b79a05ae1
Merge remote-tracking branch 'origin/master' into staging-next
Conflicts:
- pkgs/development/python-modules/flexcache/default.nix
- pkgs/development/python-modules/flexparser/default.nix
- pkgs/development/python-modules/odp-amsterdam/default.nix
- pkgs/development/python-modules/pint/default.nix
- pkgs/development/python-modules/uncertainties/default.nix
- pkgs/top-level/python-packages.nix
2024-07-01 01:07:21 +02:00
Florian Klink
641b2f29b6
Merge pull request #319153 from Kranzes/buildRustCrate-wasm
buildRustCrate: add support for compiling to wasm32-unknown-unknown
2024-06-30 14:05:33 +03:00
Ilan Joselevich
cc379b60f0
tests.buildRustCrate: add crateLibOutputsWasm32
Added a cross compilation test for wasm32-unknown-unknown. This also
required using crate.metadata instead of using the regex to get rid of
the hash in the library filename. It also required adding a mkCrate
argument to assertOutputs so we can override the buildRustCrate used.
2024-06-24 21:13:50 +03:00
Ilan Joselevich
cf5e2c2c9a
buildRustCrate: support cross compiling to wasm32-unknown-unknown
With this change you will finally be able to use
buildRustCrate/crate2nix to build your wasm32-unknown-unknown
rust projects.

Simply import nixpkgs like so:
```
lib = <nixpkgs/lib>;
pkgsForWasm32 = import <nixpkgs> {
  crossSystem = lib.examples.wasm32-unknown-none;
}
```
or use pkgsCross directly with
```
pkgsCross.wasm32-unknown-none.callPackage ./. { };
```
2024-06-24 19:28:33 +03:00
Winter
2de1fd60fc
Revert "rust: Write config.toml not config" 2024-06-23 12:32:29 -04:00
Pol Dellaiera
a2b5266973
Merge pull request #321095 from mmlb/rust-write-config.toml-not-config
rust: Write config.toml not config
2024-06-21 22:32:49 +02:00
github-actions[bot]
fb94da4e9e
Merge staging-next into staging 2024-06-21 18:01:30 +00:00
Ilan Joselevich
b561a29e4d
defaultCrateOverrides: add missing protobuf to crates 2024-06-21 18:21:39 +03:00
github-actions[bot]
c6707a9686
Merge staging-next into staging 2024-06-21 12:01:53 +00:00
Ilan Joselevich
d9e5089751
Merge pull request #321220 from thehabbos007/cargo-colon
buildRustCrate: support new cargo invocation syntax for build script outputs
2024-06-21 14:21:47 +03:00
Ahmad Sattar
95bb410817 buildRustCrate: support cargo:: invocation syntax for build script outputs
In order to allow for the new `cargo::` prefix for build script outputs
we have to adjust the configure-crate bash scripts in buildRustCrate to
properly parse the new additional syntax.

These changes don't affect existing build scripts configured with the
old `cargo:` prefix.

For more information, see https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script
2024-06-21 08:29:24 +02:00
Ahmad Sattar
fb927d5019
BuildRustCrate: proc macros must be built for build's platform
When cross compiling proc macros, the proc macro needs to be built for the
build platform's architecture.

Without this change cross compiling from Darwin to Linux would simply
fail because it tries to link to a library with a file extension that
doesn't exist on the builder's platform.
2024-06-20 14:35:49 +03:00
Manuel Mendez
3f7663c1d7 rust: Write to .cargo/config.toml instead of .cargo/config
Seeing the following new warnings pop up on stderr when cargo was bumped
to 1.78:

```
warning: `/build/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
```

which happens to break commitmsgfmt builds in nix (#320294).

closes #320294
2024-06-19 14:56:51 -04:00
Martin Weinelt
f822b2ba5c Merge remote-tracking branch 'origin/staging-next' into staging
Conflicts:
- pkgs/development/python-modules/langsmith/default.nix
- pkgs/development/python-modules/rich-pixels/default.nix
- pkgs/servers/teleport/generic.nix
2024-06-18 20:16:19 +02:00
Ahmad Sattar
c730e033ca build-rust-crate: quote build script output env var 2024-06-14 10:23:28 +02:00
Dmitry Kalinkin
fbd21c5067
rustPlatform.maturinBuildHook: specify the output directory (#291025) 2024-06-13 19:21:52 -04:00
github-actions[bot]
14aa6e8765
Merge master into staging-next 2024-06-11 12:01:16 +00:00
Ilan Joselevich
de9a49c390 buildRustCrate: extensions.sharedLibrary -> extensions.library
Switched to a common attribute for library file extensions:
de70971c90

This makes buildRustCrate evaluate successfully when using
pkgsCross/pkgsStatic.
2024-06-11 11:27:17 +01:00
Alyssa Ross
4816a73bb5 rustPlatform: --frozen -> --offline
--frozen is stricter than we need in Nixpkgs.  If a Cargo.lock is
slightly wrong, or (in my use case) if building a subproject that is
not a member of the top-level workspace, but the correct Cargo.lock
can be entirely resolved from the existing top-level Cargo.lock, it
should be deterministic, and shouldn't cause any problems, to let
cargo generate the new Cargo.lock.  This should result in less need to
bother upstreams about fixing their Cargo.lock files in cases where
they could have been automatically fixed.
2024-05-18 11:18:59 +02:00
K900
f80228a805 build-support/rust: rewrite workspace dependency inheritance
This fixes at least one bug with default-features, and also
just aligns us more with what Cargo actually does.

Also some Python style fixes and a bit less mutating state.
2024-05-10 20:55:39 +03:00
Alyssa Ross
6d4a14504e
buildRustPackage: add new supported platforms
The new NetBSD platforms have appeared since last time I updated this
list, but it looks like I just missed the MIPS linux ones last time.
2024-05-10 10:18:20 +02:00
Ruben Sanchez Diez
e6dc0fb1a1 rustPlatform.importCargoLock: Adding sparse protocol
When added the new sparse protocol the derivation is not handling properly Cargo.lock with sparse+ registries
2024-04-17 15:42:49 +02:00
lassulus
55205ec1a1
Merge pull request #302926 from helsinki-systems/fix/buildrustpackage-structuredattrs
cargoBuildHook: Fix features with __structuredAttrs
2024-04-16 23:10:26 +02:00
Olivia Crain
1348195416
tests.importCargoLock: fix self-inclusive src listings in .nix files
Replace `src = ./.` instances with more explicit source listings.
Otherwise, derivations will be rebuilt on any change to the files
defining them (e.g. formatting via nixfmt-rfc-style).
2024-04-10 10:27:12 -05:00
Janne Heß
6486868c28
cargoBuildHook: Fix features with __structuredAttrs 2024-04-10 09:24:17 +02:00
Alyssa Ross
6f8fa05acf
wrapRustc: wrap rustdoc
We need to set -crt-static on musl for rustdoc as well, so let's unify
the wrappers.  Ideally, rather than wrapping rustdoc, we'd have
rustdoc use the wrapped rustc, but that's currently only possible with
an unstable option (--test-builder).

The options set by the wrapper, -C target-feature and --sysroot, are
supported by both rustdoc and rustc, but other flags maybe not be
supported by both, so I've introduced different environment
variables (the existing NIX_RUSTFLAGS and a new NIX_RUSTDOCFLAGS) to
allow those to be set independently.

This fixes cargo-auditable in pkgsMusl., which broke because its
doctests stopped working when -crt-static was moved to the wrapper.

Fixes: 79156bf13a ("rustc: move crt-static default override to wrapper (#291829)")
2024-03-02 13:09:07 +01:00
Alyssa Ross
79156bf13a
rustc: move crt-static default override to wrapper (#291829)
Previously, when cross compiling from non-musl to musl, the crt-static
default override wouldn't be applied, because the compiler wouldn't
have been built with it due to fastCross.  Moving it to the wrapper
fixes this without having to introduce extra compiler rebuilds.  And
because the wrapper is applied even to the bootstrap rustc, we no
longer need special handling of crt-static in the Cargo expression.

Unlike --sysroot, rustc allows -C target-feature= to be passed
multiple times, with later instances taking precedence over earlier
ones.  This means that it's very easy to set the default in the
wrapper, just by our overridden default before any other arguments.

This fixes pkgsCross.aarch64-multiplatform-musl.mesa from x86_64-linux.
2024-02-28 23:10:07 +01:00
github-actions[bot]
6a27b0be74
Merge staging-next into staging 2024-01-29 18:01:37 +00:00