Commit Graph

12 Commits

Author SHA1 Message Date
Ivan Petkov
78359792ae
Form paths by concatenating a string suffix not a path
* Seems like Nix can get unhappy if a path fragment is evaluated too
  eagerly, giving errors like
  `error: access to absolute path '/Cargo.toml' is forbidden in pure eval mode (use '--impure' to override)`
* Changing to using string manipulation seems to resolve the issue
2022-02-13 12:50:43 -08:00
Ivan Petkov
8f6b608ca1
Inline Cargo.{toml,lock} checks in buildDepsOnly 2022-01-16 18:24:13 -08:00
Ivan Petkov
92d185d877
Fix some formatting 2022-01-15 19:56:46 -08:00
Ivan Petkov
3f82111135
Merge vendorCargoDepsFromArgs into vendorCargoDeps 2022-01-08 17:52:10 -08:00
Ivan Petkov
49ef407216
Rename doCopyTargetToOutput to doInstallCargoArtifacts
* Similarly rename `installCargoTargetDirHook` to
  `installCargoArtifactsHook`
* The intention is to highlight that "install" implies "copy to output"
  and not anywhere else
* Also avoids the potential confusion of "cargo target dir" (location of
  cargo's artifacts) with "cargo target" (which is the target
  architecture/platform we want cargo to build for)
2022-01-08 17:14:05 -08:00
Ivan Petkov
263fe7c78f
Fix operator precedence typo
* In Nix the `or` operator has higher precedence than function
  application, therefore `x or y z` parses as `(x or y) z`
2022-01-08 16:57:45 -08:00
Ivan Petkov
7ec94f9653
Remove internally used parameters from derivations where possible
* By default we pass everything through to the actual derivation itself,
  but some internal parameters don't show up as environment variables
  directly (or rather do not need to)
* In an effort to keep the build environment as lean as possible, we can
  do some clean up (e.g. to avoid invalidating builds if some parameter
  changes but is completely ignored/overridden elsewhere)
2022-01-04 17:45:31 -08:00
Ivan Petkov
3da8e2e195
Enable doCheck on derivations by default 2022-01-04 14:40:24 -08:00
Ivan Petkov
dc553e3853
Remove installFromCargoArtifactsHook
* This hook was never a great implementation to begin with since it
  would simply search the cargo artifacts directory for binaries and
  libraries to install
* This isn't really great since if we have multiple builds (say one with
  debug artifacts, one with release artifacts) it isn't exactly clear
  which artifacts would get installed (or which will get clobbered).
* Now that we have installFromCargoBuildLogHook we can simplify the
  options a bit and only have one main installation method. The caller
  can always provide their own if they wish
2022-01-03 14:42:59 -08:00
Ivan Petkov
47316bfe5b
Add vendorCargoDepsFromArgs
* This abstracts the path checking and message raised on errors into a
  reusable function
2022-01-03 10:28:56 -08:00
Ivan Petkov
4c1711399d
Split out buildWithCargo into a lower level mkCargoDerivation
* The intention here is to split up different "responsibilities" into
  smaller parts which can be composed as a DAG rather than mutually
  recursive functions. Specifically:
* `mkCargoDerivation` represents a lower-level thin wrapper around
  `stdenv.mkDerivation` which will
  - set up hooks
  - require the caller to define the variables needed by the hooks (like
    vendor dir, or artifacts to inherit)
  - ensure that build/check/install phases can be configured by the
    caller without having them remember to call pre/post hooks
* This allows `buildDepsOnly` to only focus on setting some default
  values (like good default commands to build all artifacts, setting the
  derivation name, etc.) and delegating the rest to `mkCargoDerivation`
* Lastly, the responsibility of `buildWithCargo` ends up ensuring that
  `cargoArtifacts` and `cargoVendorDir` are defined if the caller does
  not pass them in
2022-01-02 14:48:32 -08:00
Ivan Petkov
0aadea3b08
Rename buildWithDummySrc to buildDepsOnly 2021-12-30 14:49:52 -08:00