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; inherit pname;
meta = { meta = let
licenses = l.map (name: l.licenses.${name}) subsystemAttrs.licenses; meta = subsystemAttrs.meta;
}; in
meta
// {
licenses = l.map (name: l.licenses.${name}) meta.licenses;
};
passthru.dependencies = passthruDeps; passthru.dependencies = passthruDeps;

View File

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

View File

@ -1,6 +1,17 @@
{lib}: let {
lib,
dlib,
}: let
l = lib // builtins; l = lib // builtins;
in rec { 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: getPackageJsonDeps = packageJson: noDev:
(packageJson.dependencies or {}) (packageJson.dependencies or {})
// (lib.optionalAttrs (! noDev) (packageJson.devDependencies or {})); // (lib.optionalAttrs (! noDev) (packageJson.devDependencies or {}));

View File

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

View File

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

View File

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

View File

@ -13,6 +13,14 @@
}: let }: let
l = lib // builtins; l = lib // builtins;
in rec { 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 # Gets the root source for a package
getRootSource = pname: version: let getRootSource = pname: version: let
root = getRoot pname version; root = getRoot pname version;

View File

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