fix: make cargo-lock translator handle discovered project path deps seperately, handle store path source paths correctly

This commit is contained in:
Yusuf Bera Ertan 2022-04-12 06:29:49 +03:00
parent 1cca528ec6
commit 07c7d7d2dc
No known key found for this signature in database
GPG Key ID: 1D8F8FAF2294D6EA
2 changed files with 20 additions and 11 deletions

View File

@ -12,18 +12,18 @@
sources,
...
}: let
b = builtins;
l = lib // builtins;
fetchedSources =
lib.mapAttrs
l.mapAttrs
(name: versions:
lib.mapAttrs
l.mapAttrs
(version: source:
if source.type == "unknown"
then "unknown"
else if source.type == "path"
then
if lib.isStorePath source.path
if l.isStorePath (l.concatStringsSep "/" (l.take 4 (l.splitString "/" source.path)))
then source.path
else if name == source.rootName && version == source.rootVersion
then throw "source for ${name}@${version} is referencing itself"
@ -43,7 +43,7 @@
sources;
overriddenSources =
lib.recursiveUpdateUntil
l.recursiveUpdateUntil
(path: l: r: lib.isDerivation l)
fetchedSources
(sourceOverrides fetchedSources);

View File

@ -239,12 +239,12 @@ in {
# source definition containing url, hash, etc.
sourceConstructors = {
path = dependencyObject: let
toml = (
findToml =
l.findFirst
(toml: toml.value.package.name == dependencyObject.name)
(throw "could not find crate ${dependencyObject.name}")
(cargoPackages ++ discoveredCargoPackages)
);
null;
toml = findToml cargoPackages;
discoveredToml = findToml discoveredCargoPackages;
relDir = lib.removePrefix "${inputDir}/" (l.dirOf toml.path);
in
if
@ -257,12 +257,21 @@ in {
rootName = null;
rootVersion = null;
}
else
else if discoveredToml != null
then
dlib.construct.pathSource {
path = l.dirOf discoveredToml.path;
rootName = null;
rootVersion = null;
}
else if toml != null
then
dlib.construct.pathSource {
path = relDir;
rootName = package.name;
rootVersion = package.version;
};
}
else throw "could not find crate ${dependencyObject.name}";
git = dependencyObject: let
parsed = parseGitSource dependencyObject.source;