mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-09-11 14:35:30 +03:00
fix: allow pname and version in crates-io source spec
This commit is contained in:
parent
82693fb714
commit
0d96a7249b
@ -161,7 +161,9 @@
|
|||||||
"then": {
|
"then": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"hash": { "type": "string" },
|
"hash": { "type": "string" },
|
||||||
"type": { "type": "string" }
|
"type": { "type": "string" },
|
||||||
|
"pname": { "type": "string" },
|
||||||
|
"version": { "type": "string" }
|
||||||
},
|
},
|
||||||
"required": ["type"],
|
"required": ["type"],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
@ -119,6 +119,7 @@ in rec {
|
|||||||
version,
|
version,
|
||||||
...
|
...
|
||||||
} @ args: let
|
} @ args: let
|
||||||
|
# constructs source string for dependency
|
||||||
makeSource = sourceSpec: let
|
makeSource = sourceSpec: let
|
||||||
source =
|
source =
|
||||||
if sourceSpec.type == "crates-io"
|
if sourceSpec.type == "crates-io"
|
||||||
@ -138,13 +139,20 @@ in rec {
|
|||||||
else null;
|
else null;
|
||||||
in
|
in
|
||||||
source;
|
source;
|
||||||
|
# constructs source string for dependency entry
|
||||||
makeDepSource = sourceSpec:
|
makeDepSource = sourceSpec:
|
||||||
if sourceSpec.type == "crates-io"
|
if sourceSpec.type == "crates-io"
|
||||||
then makeSource sourceSpec
|
then makeSource sourceSpec
|
||||||
else if sourceSpec.type == "git"
|
else if sourceSpec.type == "git"
|
||||||
then l.concatStringsSep "#" (l.init (l.splitString "#" (makeSource sourceSpec)))
|
then l.concatStringsSep "#" (l.init (l.splitString "#" (makeSource sourceSpec)))
|
||||||
else null;
|
else null;
|
||||||
|
# removes source type information from the version
|
||||||
|
normalizeVersion = version: srcType: l.removeSuffix ("$" + srcType) version;
|
||||||
|
|
||||||
sourceSpec = getSourceSpec name version;
|
sourceSpec = getSourceSpec name version;
|
||||||
|
|
||||||
|
normalizedVersion = normalizeVersion version sourceSpec.type;
|
||||||
|
|
||||||
source = let
|
source = let
|
||||||
src = makeSource sourceSpec;
|
src = makeSource sourceSpec;
|
||||||
in
|
in
|
||||||
@ -157,26 +165,30 @@ in rec {
|
|||||||
dep: let
|
dep: let
|
||||||
depSourceSpec = getSourceSpec dep.name dep.version;
|
depSourceSpec = getSourceSpec dep.name dep.version;
|
||||||
depSource = makeDepSource depSourceSpec;
|
depSource = makeDepSource depSourceSpec;
|
||||||
|
|
||||||
|
normalizedDepVersion = normalizeVersion dep.version depSourceSpec.type;
|
||||||
|
|
||||||
hasMultipleVersions =
|
hasMultipleVersions =
|
||||||
l.length (l.attrValues dreamLock.sources.${dep.name}) > 1;
|
l.length (l.attrValues dreamLock.sources.${dep.name}) > 1;
|
||||||
hasDuplicateVersions =
|
hasDuplicateVersions = dep.version != normalizedDepVersion;
|
||||||
l.hasSuffix ("$" + depSourceSpec.type) dep.version;
|
|
||||||
# only put version if there are different versions of the dep
|
# only put version if there are different versions of the dep
|
||||||
versionString =
|
versionString =
|
||||||
l.optionalString hasMultipleVersions " ${depSourceSpec.version}";
|
l.optionalString hasMultipleVersions " ${normalizedDepVersion}";
|
||||||
# only put source if there are duplicate versions of the dep
|
# only put source if there are duplicate versions of the dep
|
||||||
# cargo vendor does not support this anyway and so builds will fail
|
# cargo vendor does not support this anyway and so builds will fail
|
||||||
# until https://github.com/rust-lang/cargo/issues/10310 is resolved.
|
# until https://github.com/rust-lang/cargo/issues/10310 is resolved.
|
||||||
srcString =
|
srcString =
|
||||||
l.optionalString hasDuplicateVersions " (${depSource})";
|
l.optionalString hasDuplicateVersions " (${depSource})";
|
||||||
in "${depSourceSpec.pname}${versionString}${srcString}"
|
in "${dep.name}${versionString}${srcString}"
|
||||||
)
|
)
|
||||||
args.dependencies;
|
args.dependencies;
|
||||||
|
|
||||||
isMainPackage = isInPackages name version;
|
isMainPackage = isInPackages name version;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
name = sourceSpec.pname;
|
name = sourceSpec.pname or name;
|
||||||
version = sourceSpec.version;
|
version = sourceSpec.version or normalizedVersion;
|
||||||
}
|
}
|
||||||
# put dependencies like how cargo expects them
|
# put dependencies like how cargo expects them
|
||||||
// (
|
// (
|
||||||
|
@ -42,10 +42,10 @@ in rec {
|
|||||||
makeSource = dep: let
|
makeSource = dep: let
|
||||||
path = getSource dep.name dep.version;
|
path = getSource dep.name dep.version;
|
||||||
spec = getSourceSpec dep.name dep.version;
|
spec = getSourceSpec dep.name dep.version;
|
||||||
stripUniqSuffix = version: l.removeSuffix ("$" + spec.type) version;
|
normalizeVersion = version: l.removeSuffix ("$" + spec.type) version;
|
||||||
in {
|
in {
|
||||||
inherit path spec dep;
|
inherit path spec dep;
|
||||||
name = "${dep.name}-${stripUniqSuffix dep.version}";
|
name = "${dep.name}-${normalizeVersion dep.version}";
|
||||||
};
|
};
|
||||||
sources = l.map makeSource deps;
|
sources = l.map makeSource deps;
|
||||||
|
|
||||||
|
@ -429,7 +429,7 @@ in {
|
|||||||
}
|
}
|
||||||
else throw "could not find crate '${dependencyObject.name}-${dependencyObject.version}'";
|
else throw "could not find crate '${dependencyObject.name}-${dependencyObject.version}'";
|
||||||
in
|
in
|
||||||
final // depNameVersion;
|
final;
|
||||||
|
|
||||||
git = dependencyObject: let
|
git = dependencyObject: let
|
||||||
parsed = source.value;
|
parsed = source.value;
|
||||||
@ -441,7 +441,6 @@ in {
|
|||||||
else {};
|
else {};
|
||||||
in
|
in
|
||||||
maybeRef
|
maybeRef
|
||||||
// depNameVersion
|
|
||||||
// {
|
// {
|
||||||
type = "git";
|
type = "git";
|
||||||
url = parsed.url;
|
url = parsed.url;
|
||||||
|
Loading…
Reference in New Issue
Block a user