Skip to content

Commit

Permalink
vendorCargoDeps: skip checking for cargoConfigs if src not set (ipetk…
Browse files Browse the repository at this point in the history
  • Loading branch information
ipetkov authored Mar 22, 2023
1 parent 81d95a1 commit ec69da6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Unreleased

### Fixed
* `vendorCargoDeps` correctly accepts arguments which have _not_ set `src`, so
long as one of `cargoLock`, `cargoLockContents`, or `cargoLockParsed` is set

## [0.12.0] - 2023-03-19

### Added
Expand Down
17 changes: 17 additions & 0 deletions checks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,23 @@ in
smokeWorkspace = self.smoke [ "print" ] self.workspace;
smokeWorkspaceRoot = self.smoke [ "print" ] self.workspaceRoot;

vendorCargoDeps =
let
src = ./workspace;
cargoLock = ./workspace/Cargo.lock;
cargoLockContents = builtins.readFile cargoLock;
cargoLockParsed = builtins.fromTOML cargoLockContents;
in
pkgs.linkFarmFromDrvs "vendorCargoDeps-tests" (map
myLib.vendorCargoDeps
[
{ inherit src; }
{ inherit cargoLock; }
{ inherit cargoLockContents; }
{ inherit cargoLockParsed; }
]
);

vendorGitSubset = callPackage ./vendorGitSubset.nix { };

# https://github.com/ipetkov/crane/issues/117
Expand Down
7 changes: 5 additions & 2 deletions lib/vendorCargoDeps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ let
concatMapStrings
escapeShellArg;

cargoConfigs = if args ? src then (findCargoFiles args.src).cargoConfigs else [ ];

src = args.src or (throw ''
unable to find `src` attribute. consider one of the following:
- set `cargoVendorDir = vendorCargoDeps { cargoLock = ./some/path/to/Cargo.lock; }`
Expand Down Expand Up @@ -47,8 +49,9 @@ let
lockPackages = lock.package or (throw "Cargo.lock missing [[package]] definitions");

vendoredRegistries = vendorCargoRegistries {
inherit lockPackages;
cargoConfigs = (findCargoFiles src).cargoConfigs;
inherit
cargoConfigs
lockPackages;
};
vendoredGit = vendorGitDeps {
inherit lockPackages;
Expand Down

0 comments on commit ec69da6

Please sign in to comment.