2022-02-07 04:16:49 +03:00
|
|
|
{ findCargoFiles
|
2022-01-31 01:30:15 +03:00
|
|
|
, lib
|
2023-04-02 20:57:17 +03:00
|
|
|
, vendorMultipleCargoDeps
|
2021-12-27 01:05:23 +03:00
|
|
|
}:
|
|
|
|
|
2022-01-09 04:52:10 +03:00
|
|
|
args:
|
2021-12-27 01:05:23 +03:00
|
|
|
let
|
2022-01-31 01:30:15 +03:00
|
|
|
inherit (builtins)
|
|
|
|
pathExists
|
2022-02-07 04:16:49 +03:00
|
|
|
readFile;
|
2022-01-31 01:30:15 +03:00
|
|
|
|
2023-04-02 20:57:17 +03:00
|
|
|
inherit (lib.attrsets) optionalAttrs;
|
2022-01-31 01:30:15 +03:00
|
|
|
|
2023-03-22 07:57:14 +03:00
|
|
|
cargoConfigs = if args ? src then (findCargoFiles args.src).cargoConfigs else [ ];
|
|
|
|
|
2022-01-09 04:52:10 +03:00
|
|
|
src = args.src or (throw ''
|
|
|
|
unable to find `src` attribute. consider one of the following:
|
|
|
|
- set `cargoVendorDir = vendorCargoDeps { cargoLock = ./some/path/to/Cargo.lock; }`
|
|
|
|
- set `cargoVendorDir = vendorCargoDeps { src = ./src/containing/cargo/lock/file; }`
|
|
|
|
- set `cargoVendorDir = null` to skip vendoring altogether
|
|
|
|
'');
|
|
|
|
|
2022-05-09 16:38:16 +03:00
|
|
|
cargoLock = args.cargoLock or (src + "/Cargo.lock");
|
2022-01-09 04:52:10 +03:00
|
|
|
cargoLockContents = args.cargoLockContents or (
|
2022-01-31 01:30:15 +03:00
|
|
|
if pathExists cargoLock
|
|
|
|
then readFile cargoLock
|
2022-01-09 04:52:10 +03:00
|
|
|
else
|
|
|
|
throw ''
|
|
|
|
unable to find Cargo.lock at ${src}. please ensure one of the following:
|
|
|
|
- a Cargo.lock exists at the root of the source directory of the derivation
|
|
|
|
- set `cargoVendorDir = vendorCargoDeps { cargoLock = ./some/path/to/Cargo.lock; }`
|
|
|
|
- set `cargoVendorDir = vendorCargoDeps { src = ./src/containing/cargo/lock/file; }`
|
|
|
|
- set `cargoVendorDir = null` to skip vendoring altogether
|
|
|
|
''
|
|
|
|
);
|
|
|
|
|
2023-03-20 03:33:17 +03:00
|
|
|
lock = args.cargoLockParsed or (builtins.fromTOML cargoLockContents);
|
2021-12-27 01:05:23 +03:00
|
|
|
in
|
2023-04-02 20:57:17 +03:00
|
|
|
vendorMultipleCargoDeps ({
|
|
|
|
inherit cargoConfigs;
|
|
|
|
cargoLockParsedList = [ lock ];
|
|
|
|
} // optionalAttrs (args ? registries) { inherit (args) registries; })
|