Commit Graph

151 Commits

Author SHA1 Message Date
Ivan Petkov
aab6d4f865
vendorMultipleCargoDeps: fix deduplication logic (#289)
* We should ignore the package.dependencies array since it can cause
  problems
2023-04-02 23:46:24 +00:00
Ivan Petkov
f491bee4f9
Add support for building standard library crates (#287)
* vendorCargoRegistries: accept `registries` from the caller if specified
* Add vendorMultipleCargoDeps
2023-04-02 17:57:17 +00:00
Ivan Petkov
6736e8be8e
crateNameFromCargoToml: make warnings more useful (#282)
* The warning now shows a more in-depth explanation on how to silence it
2023-03-29 04:21:28 +00:00
Ivan Petkov
ec69da6973
vendorCargoDeps: skip checking for cargoConfigs if src not set (#278) 2023-03-22 04:57:14 +00:00
Ivan Petkov
6fd78bc66a
Add path as a convenience wrapper around builtins.path (#273) 2023-03-19 20:57:15 -07:00
figsoda
77435dad14
feat: add cargoLockParsed option (#270)
---------

Co-authored-by: Ivan Petkov <ivanppetkov@gmail.com>
2023-03-20 00:33:17 +00:00
figsoda
475de74fa2
feat: add cargoLlvmCov (#267)
* feat: add cargoLlvmCov
* cargoHelperFunctionsHook: prefer `--release` over `--profile release`
Some tools (e.g. cargo-llvm-cov) don't understand `--profile release` as
an alias for `--release`, so `cargoWithProfile` should prefer passing
`--release` when `$CARGO_PROFILE` == "release"

---------

Co-authored-by: Ivan Petkov <ivanppetkov@gmail.com>
2023-03-19 23:44:14 +00:00
Roman Volosatovs
5291dd0aa7
feat: add support for bindeps feature (#258)
Write a `main.rs` to `src/bin/dummy` within the generated dummy source,
rather than `src/main.rs` to account for `illegalBin` test case

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
2023-03-06 17:24:21 -08:00
Ivan Petkov
d777dbc167
mkDummySrc: avoid invalidation if the source name has two hashes (#248) 2023-02-19 22:43:11 +00:00
Ivan Petkov
34633dd0d7
buildDepsOnly: warn if both src and dummySrc are set (#247) 2023-02-19 17:46:57 +00:00
Ivan Petkov
6fb400ec63
crateNameFromCargoToml: warn when values can't be found (#237) 2023-02-12 00:39:43 +00:00
Felix Schröter
2b866abbdd
ignore non-json lines in cargoBuildLog (#234)
Fixes issues with non-json values in cargoBuildLog: rust-lang/cargo#8179
---------

Co-authored-by: Ivan Petkov <ivanppetkov@gmail.com>
2023-02-11 13:27:11 -08:00
Ivan Petkov
00564437f3
Properly handle workspace inheritance in git dependencies (#224)
Crates from git repos are vendored in a flattened directory where each crate shows up at the root of the vendor directory. Since the vendoring step effectively breaks workspace structures, any crates which use workspace inheritance (e.g. package.version.workspace = true will fail to resolve.

To work around this we inspect the crate's workspace manifest (if it exists) and attempt to manually merge the values while copying the contents to the vendor directory.
2023-01-21 16:46:32 -08:00
Ivan Petkov
42e2fab6bc
Make it easier to build workspaces not at source root (#212) 2023-01-05 04:46:43 +00:00
Ivan Petkov
18ef99b1e0
inheritCargoArtifactsHook: preserve executable bit of build scripts (#206)
Using `cp --no-preserve mode` ends up losing the executable bit of
previously compiled build scripts. Instead we should ignore the file
ownership, and subsequently make the files writable (since the store is
read only)
2023-01-04 02:53:38 +00:00
Ivan Petkov
8b66edc016
mkDummySource: fix build invalidation regression (#195)
* When checking the original source for its name, make sure we throw
  away the string context so we don't end up actually depending on the
  original source instead of the cleaned one
2022-12-23 17:06:58 +00:00
Ivan Petkov
70fcce8db0
mkDummySrc: try to use the same output name as original source (#190) 2022-12-20 20:50:22 -08:00
Ivan Petkov
63f80ee278
zstd: use as many threads as we can when compressing (#183) 2022-12-09 00:44:41 +00:00
Ivan Petkov
2b0be4c1c4
mkDummySrc: work with uefi targets by default, and allow downstream customization (#174)
* mkDummySrc: also include `no_std` attrs for target_os = uefi
* buildDepsOnly: only check with `--all-targets` if doCheck enabled
* mkDummySrc: allow customizing dummy Rust file contents
2022-11-28 03:23:35 +00:00
Ivan Petkov
c61d98aaea
mkDummySrc: properly import core (#172) 2022-11-21 01:12:39 +00:00
Ivan Petkov
35fd8fcbb0
Run nixpkgs-fmt 2022-11-20 16:28:49 -08:00
Ivan Petkov
e80de1e74a
Allow passing arbitrary fetchurl args per registry (#168)
Co-authored-by: Amos Wenger <amoswenger@gmail.com>
2022-11-20 16:22:13 -08:00
Ivan Petkov
c3935e06ca
removeReferencesToVendoredSourcesHook: use a single sed invocation (#167)
* Turns out it is much faster to build up one big regex of the
  references to remove and invoking `sed` just once than it is to invoke
  it once per reference
2022-11-17 17:00:25 -08:00
Zhaofeng Li
2e24bc6591
downloadCargoPackageFromGit: Ignore crates with duplicate package IDs (#158)
For example, the Cargo git repo contains multiple "case" Cargo.toml
files in the testsuite. Let's ignore them like what Cargo does [1].

Co-authored-by: Ivan Petkov <ivanppetkov@gmail.com>
2022-11-09 18:12:34 -08:00
Ivan Petkov
ee00efb961
registryFromGitIndex: use shallow git checkouts (#151) 2022-10-29 18:56:41 +00:00
Ivan Petkov
975bda728a
Change default cargo artifact installation to use symlinks where possible (#150)
* Define a new installation mode which symlinks identical artifacts
  against a directory of previously generated ones
* This allows for linear space usage in the Nix store across many
  chained derivations (as opposed to using a zstd compressed tarball
  which uses quadratic space across many chained derivations)
* This new installation mode is the new default for all cargo based
  builds. The previous behavior is still available by setting
  `installCargoArtifactsMode = "use-zstd";` on a derivation
* `buildPackage` will continue to use zstd compressed tarballs while
  building dependencies (unless either of `cargoArtifacts` or
  `installCargoArtifactsMode` is defined, in which case they will be
  honored)
2022-10-29 18:48:29 +00:00
Ivan Petkov
2ce1a3313e
Eliminate dead code (#148) 2022-10-23 23:20:22 +00:00
Ivan Petkov
6b864957e1
checks: add tests for building crates using workspace inheritance (#147) 2022-10-23 22:56:18 +00:00
Roman Volosatovs
097afacc53
mkDummySrc: support freestanding targets (#126)
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Co-authored-by: Ivan Petkov <ivanppetkov@gmail.com>
2022-10-19 02:13:38 +00:00
Ivan Petkov
1bea2b5212
crateNameFromCargoToml: handle workspace inheritance (#144) 2022-10-16 17:12:31 +00:00
Ivan Petkov
d78cb0453b cargoBuild: do not run tests 2022-10-09 12:56:21 -10:00
Ivan Petkov
b84c191b59 buildDepsOnly: accept cargo{Check,Test}ExtraArgs 2022-10-09 12:56:21 -10:00
Ivan Petkov
17f4ff6ad7 buildPackage: use mkCargoDerivation instead of cargoBuild 2022-10-09 12:56:21 -10:00
Ivan Petkov
f27d6dd45d cargoTarpaulin: require that cargoArtifacts are specified 2022-10-09 11:33:57 -10:00
Ivan Petkov
0b71f12fc7
Add cargoTest for running crate tests (#132) 2022-10-09 21:00:17 +00:00
Ivan Petkov
1127ed2587 cargoNextest: use mkCargoDerivation instead of cargoBuild 2022-10-09 09:40:53 -10:00
Ivan Petkov
2b70a82caf cargoClippy: use mkCargoDerivation instead of cargoBuild 2022-10-09 09:40:53 -10:00
Ivan Petkov
0ad37656bc cargoTarpaulin: use mkCargoDerivation instead of cargoBuild 2022-10-09 09:40:53 -10:00
Ivan Petkov
8c97f06448 cargoAudit: use mkCargoDerivation instead of cargoBuild 2022-10-09 09:40:53 -10:00
Ivan Petkov
b61434b0b2 cargoDoc: use mkCargoDerivation instead of cargoBuild 2022-10-09 09:40:53 -10:00
Ivan Petkov
51bbfae3f6 cargoFmt: use mkCargoDerivation instead of cargoBuild 2022-10-09 09:40:53 -10:00
Ivan Petkov
cc7d69f1ed mkCargoDerivation: default to empty checkPhaseCargoCommand 2022-10-09 09:40:53 -10:00
Ivan Petkov
d4a3bee75f mkCargoDerivation: populate pname and version if not specified 2022-10-09 09:40:53 -10:00
Ivan Petkov
d3db2ecf01 mkCargoDerivation: automatically vendor deps if cargoVendorDir not set 2022-10-09 09:40:53 -10:00
Ivan Petkov
0017a8da68
flake: deprecate the packages flake output (#130)
Even though the setup hooks can be thought of as "packages", it makes
things much more simple to access everything from the same place
2022-10-09 10:28:48 -07:00
Ivan Petkov
fc545e6784
hooks: do not use substitutions for needed tools (#128)
* Using substitutions for build hooks is a great way to ensure the
  necessary utility is present without making the caller supply it to
  the builder, except it makes things confusing when applying overrides
* For example, the `installFromCargoBuildLog` hook was inadvertently
  ignoring any `cargo` overrides applied to the entire `lib`
  instantiation
* By removing all explicit substations we also side step the issue of
  trying to select the correct build/host/target version of the tool and
  use whatever is present in the build environment
2022-10-09 02:03:05 +00:00
Ivan Petkov
22f971a126
mkDummySrc: fix handling of build scripts (#122)
* Instead of injecting our own dummy `build.rs` file, we will patch the
  `Cargo.toml` files to specify a build script in the Nix store
* This allow cargo to notice the difference (i.e. changed build script
  path) where it could not before (due to nix enforcing that all sources
  always have the same timestamp)
2022-09-28 02:05:06 +00:00
Ivan Petkov
21e627606c
mkDummySrc: allow running a custom script after dummification is done (#116) 2022-09-27 06:25:09 +00:00
Ivan Petkov
06b1f7bd80
Improve stripping references to vendored sources (#120)
* Also add removeReferencesToVendoredSourcesHook
2022-09-24 23:45:56 +00:00
Ivan Petkov
c12fec0a8b
Add cleanCargoSource and filterCargoSources (#110) 2022-09-21 01:27:47 +00:00