feat: extract homepage and description metadata in nodejs and rust

This commit is contained in:
Yusuf Bera Ertan 2022-09-13 21:45:56 +03:00
parent 2ec675e394
commit c621ddff9e
No known key found for this signature in database
GPG Key ID: 1D8F8FAF2294D6EA
8 changed files with 44 additions and 24 deletions

View File

@ -216,9 +216,13 @@
inherit pname;
meta = {
licenses = l.map (name: l.licenses.${name}) subsystemAttrs.licenses;
};
meta = let
meta = subsystemAttrs.meta;
in
meta
// {
licenses = l.map (name: l.licenses.${name}) meta.licenses;
};
passthru.dependencies = passthruDeps;

View File

@ -5,7 +5,7 @@
}: let
b = builtins;
l = lib // builtins;
nodejsUtils = import ../utils.nix {inherit lib;};
nodejsUtils = import ../utils.nix {inherit dlib lib;};
getPackageLock = tree: project:
nodejsUtils.getWorkspaceLockFile tree project "package-lock.json";
@ -172,7 +172,7 @@
subsystemAttrs = {
nodejsVersion = b.toString args.nodejs;
licenses = dlib.parseSpdxId (packageJson.license or "");
meta = nodejsUtils.getMetaFromPackageJson packageJson;
};
# functions

View File

@ -1,6 +1,17 @@
{lib}: let
{
lib,
dlib,
}: let
l = lib // builtins;
in rec {
getMetaFromPackageJson = packageJson:
{licenses = dlib.parseSpdxId (packageJson.license or "");}
// (
l.filterAttrs
(n: v: l.any (on: n == on) ["description" "homepage"])
packageJson
);
getPackageJsonDeps = packageJson: noDev:
(packageJson.dependencies or {})
// (lib.optionalAttrs (! noDev) (packageJson.devDependencies or {}));

View File

@ -4,7 +4,7 @@
...
}: let
l = lib // builtins;
nodejsUtils = import ../utils.nix {inherit lib;};
nodejsUtils = import ../utils.nix {inherit dlib lib;};
parser = import ./parser.nix {inherit lib;};
getYarnLock = tree: project:
@ -142,7 +142,7 @@
subsystemAttrs = {
nodejsVersion = b.toString args.nodejs;
licenses = dlib.parseSpdxId (packageJson.license or "");
meta = nodejsUtils.getMetaFromPackageJson packageJson;
};
keys = {

View File

@ -42,6 +42,8 @@
produceDerivation pname (buildWithToolchain defaultToolchain {
inherit pname version src;
meta = utils.getMeta pname version;
cargoBuildFlags = cargoBuildFlags;
cargoTestFlags = cargoBuildFlags;
@ -61,13 +63,6 @@
${replacePaths}
${utils.writeCargoLock}
'';
meta = {
licenses =
l.map
(name: l.licenses.${name})
subsystemAttrs.licenses.${pname}.${version};
};
});
mkShellForPkg = pkg:

View File

@ -99,6 +99,7 @@
buildArgs =
common
// {
meta = utils.getMeta pname version;
cargoArtifacts = deps;
# link the vendor dir we used earlier to the correct place
preUnpack = ''
@ -112,12 +113,6 @@
${utils.writeCargoLock}
'';
passthru = {dependencies = deps;};
meta = {
licenses =
l.map
(name: l.licenses.${name})
subsystemAttrs.licenses.${pname}.${version};
};
};
in
produceDerivation

View File

@ -13,6 +13,14 @@
}: let
l = lib // builtins;
in rec {
getMeta = pname: version: let
meta = subsystemAttrs.meta.${pname}.${version};
in
meta
// {
licenses = l.map (name: l.licenses.${name}) meta.licenses;
};
# Gets the root source for a package
getRootSource = pname: version: let
root = getRoot pname version;

View File

@ -251,13 +251,20 @@ in {
gitDeps = l.filter (dep: (getSourceTypeFrom dep) == "git") parsedDeps;
in
l.unique (l.map (dep: parseGitSource dep) gitDeps);
licenses = l.foldl' l.recursiveUpdate {} (
meta = l.foldl' l.recursiveUpdate {} (
l.map
(
package: let
pkg = package.value.package;
licenses = dlib.parseSpdxId (pkg.license or "");
in {${pkg.name}.${pkg.version} = licenses;}
in {
${pkg.name}.${pkg.version} =
{licenses = dlib.parseSpdxId (pkg.license or "");}
// (
l.filterAttrs
(n: v: l.any (on: n == on) ["description" "homepage"])
pkg
);
}
)
cargoPackages
);