Commit Graph

320 Commits

Author SHA1 Message Date
Ivan Petkov
e6a6ad68b1
Change default buildPhase to run cargo build 2021-12-28 18:54:51 -08:00
Ivan Petkov
2730271710
Make copyCargoTargetToOutputHook even more lazy
* Instead of always installing the hook but bailing early based on the
  configuration, we will instead only install the hook if the
  configuration requests it
2021-12-28 18:53:05 -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
46e6e54b3b
Update inheritCargoTargetHook to run after source patching
* This allows us to copy over the cargo artifacts as early as possible
  so that any other phases/hooks (like running clippy) can take
  advantage of the cache
* It also avoids installing the artifacts too soon (and making them
  older than the source) and having cargo invalidate them
2021-12-28 16:15:57 -08:00
Ivan Petkov
7b80c23eb5
Update configureCargoVendoredDepsHook to use $CARGO_HOME/config.toml
* Rather than clobbering the project's .cargo/config.toml file (if it
  exists), the setup hook will update the base configuration used in
  $CARGO_HOME/config.toml
* This potentially allows for projects who know what they are doing to
  more easily replace their own sources, while falling back to our
  configuration
2021-12-28 16:05:20 -08:00
Ivan Petkov
c10fd1c8b1
Set CARGO_HOME in configureCargoCommonVarsHook
* This will define CARGO_HOME to $PWD/.cargo-home to ensure that cargo
  never tries to look for a missing HOME directory as it's default
  location
* The hook is also added to `postPatchHooks` (instead of
  `preConfigureHooks`) to ensure that it runs before all other
  configuration-related hooks
2021-12-28 16:00:50 -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