Commit Graph

125 Commits

Author SHA1 Message Date
Ivan Petkov
64914fbc98
Remove doCompressTarget option
* Reducing the parameter surface area for good measure, zstd compression
  works pretty well and it seems redundant to support multiple ways of
  copying the target directory around
2021-12-30 20:25:33 -08:00
Ivan Petkov
2a14c2d53b
Update crateNameFromCargoToml with better fallback error messages
* If a derivation is created without a name *and* we cannot infer a name
  from a Cargo.toml file, we'll throw a descriptive error message which
  hints towards the remediation
* Otherwise nix can throw a pretty obtuse "derivation has no name" error
  with no error trace
2021-12-30 15:08:45 -08:00
Ivan Petkov
0aadea3b08
Rename buildWithDummySrc to buildDepsOnly 2021-12-30 14:49:52 -08:00
Ivan Petkov
2339d7959f
Add buildWithDummySrc
* This also implements automatically building dependencies in a separate
  derivation if `buildWithCargo` is invoked without `cargoArtifacts`
2021-12-30 14:46:35 -08:00
Ivan Petkov
3223e4860e
Add mkDummySrc 2021-12-30 13:22:05 -08:00
Ivan Petkov
4a515f43ca
cleanCargoToml: do not replace path attributes
* Keep the paths as specified in the Cargo.toml while cleaning, leaving
  it up to the caller to replace them if necessary
2021-12-30 10:04:12 -08:00
Ivan Petkov
234257c239
cleanCargoToml: do not strip edition fields
* The edition entries can affect cargo behavior, not just rustc
  behavior, so we should keep them in for consistency with what the
  project expects
2021-12-30 09:44:50 -08:00
Ivan Petkov
cf1c6eb0e8
Add checks for cleanCargoToml 2021-12-29 19:26:55 -08:00
Ivan Petkov
a286fe1ff5
Add cleanCargoToml 2021-12-29 16:03:39 -08:00
Ivan Petkov
e6a6ad68b1
Change default buildPhase to run cargo build 2021-12-28 18:54:51 -08:00
Ivan Petkov
ade4ea7137
Add some documentation around the buildWithCargo parameters 2021-12-28 18:51:44 -08:00
Ivan Petkov
6cc3ea3199
Add remapSourcePathPrefixHook 2021-12-28 18:51:06 -08:00
Ivan Petkov
bf17616560
Add installFromCargoArtifactsHook 2021-12-28 17:51:51 -08:00
Ivan Petkov
dd3fa0123b
Rename inheritCargoTargetHook to inheritCargoArtifactsHook
* Hopefully the updated name should be more clear that we are inhering
  some existing cargo artifacts and NOT inheriting something like
  CARGO_BUILD_TARGET which refers to the host target being built
2021-12-28 16:48:12 -08:00
Ivan Petkov
fab2fa93cc
Explicitly define more defaults for buildWithCargo
* This should make it a bit easier to tell at a glance what inputs are
  significant for the derivation without having to look at the entire
  source (and corresponding hooks)
2021-12-28 15:27:49 -08:00
Ivan Petkov
65b984b4aa
Rename doCopyTarget to doCopyTargetToOutput
* The intention is to make it more clear that this flag controls copying
  the target directory so that *other* derivations can use it, and DOES
  NOT control whether we use an *existing* target directory from another
  derivation
2021-12-28 15:19:10 -08:00
Ivan Petkov
b8d083cd7e
Implement automatically setting up a vendor dir from source
* If the source root contains a Cargo.lock file it will be used to
  create a vendor directory
* Otherwise a (descriptive) error will be thrown describing how to
  remediate
* The caller can, of course, manually specify their own `cargoVendorDir`
  which will skip the default vendoring
2021-12-28 15:15:10 -08:00
Ivan Petkov
5abd4f6054
Implement compressing cargo target directory 2021-12-26 20:25:36 -08:00
Ivan Petkov
edcb983805
Change doCopyTarget to always imply a separate output
* We can simplify the configuration by removing the
  `doCopyTargetToSeparateOutput` parameter
* If a caller wants to copy target artifacts into any other output, it
  is pretty trivial for them to add their own logic for it
2021-12-26 20:11:22 -08:00
Ivan Petkov
2d9788eb8b
Add copyCargoTargetToOutputHook 2021-12-26 18:06:19 -08:00
Ivan Petkov
c2d7d083d5
Add configureCargoCommonVarsHook 2021-12-26 17:17:39 -08:00
Ivan Petkov
e1b7cea23c
Add buildWithCargo as a thin wrapper around mkDerivation 2021-12-26 16:27:09 -08:00
Ivan Petkov
83632355d2
Add configureCargoVendoredDepsHook 2021-12-26 16:21:08 -08:00
Ivan Petkov
3af378cfd7
Implement vendoring cargo dependencies 2021-12-26 14:05:23 -08:00
Ivan Petkov
2cec871d53
Initial commit 2021-12-26 11:47:59 -08:00