mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-20 13:01:44 +03:00
fixup resolveAllProjects
This commit is contained in:
parent
8fbd1d51a9
commit
b1872eb866
@ -419,7 +419,7 @@ let
|
|||||||
resolveAllProjects=
|
resolveAllProjects=
|
||||||
{
|
{
|
||||||
source ? null,
|
source ? null,
|
||||||
tree ? dlib.prepareSourceTree source,
|
tree ? dlib.prepareSourceTree { inherit source; },
|
||||||
pname,
|
pname,
|
||||||
}@args:
|
}@args:
|
||||||
|
|
||||||
@ -430,52 +430,79 @@ let
|
|||||||
getTranslator = subsystem: translatorName:
|
getTranslator = subsystem: translatorName:
|
||||||
translators.translators."${subsystem}".all."${translatorName}";
|
translators.translators."${subsystem}".all."${translatorName}";
|
||||||
|
|
||||||
isImpure = project:
|
isImpure = project: translatorName:
|
||||||
(getTranslator project.subsystem project.translator).type == "impure";
|
(getTranslator project.subsystem translatorName).type == "impure";
|
||||||
|
|
||||||
getDreamLockPath = project:
|
getDreamLockPath = project:
|
||||||
"${config.projectsDir}/${pname}/${project.relPath}/dream-lock.json";
|
config.projectRoot +
|
||||||
|
(dlib.sanitizeRelativePath
|
||||||
|
"${config.packagesDir}/${pname}/${project.relPath}/dream-lock.json");
|
||||||
|
|
||||||
projects =
|
getProjectKey = project:
|
||||||
|
"${project.name}_|_${project.subsystem}_|_${project.relPath}";
|
||||||
|
|
||||||
|
# list of projects extended with some information requried for processing
|
||||||
|
projectsList =
|
||||||
l.map
|
l.map
|
||||||
(project: project // rec {
|
(project: project // rec {
|
||||||
dreamLockPath = getDreamLockPath project;
|
dreamLockPath = getDreamLockPath project;
|
||||||
dreamLock = dlib.readDreamLock dreamLockPath;
|
dreamLock = dlib.readDreamLock dreamLockPath;
|
||||||
|
impure = isImpure project translator;
|
||||||
|
key = getProjectKey project;
|
||||||
resolved = l.pathExists dreamLockPath;
|
resolved = l.pathExists dreamLockPath;
|
||||||
impure = isImpure project;
|
translator = l.head project.translators;
|
||||||
})
|
})
|
||||||
discoveredProjects;
|
discoveredProjects;
|
||||||
|
|
||||||
# unresolved dimpure projects cannot be resolved on the fly
|
# attrset of projects by key
|
||||||
projectsImpureUnresolved =
|
projects =
|
||||||
l.filter (project: project.impure && ! project.resolved) projects;
|
l.listToAttrs
|
||||||
|
(l.map
|
||||||
|
(proj: l.nameValuePair proj.key proj)
|
||||||
|
projectsList);
|
||||||
|
|
||||||
|
# unresolved impure projects cannot be resolved on the fly
|
||||||
|
projectsImpureUnresolved =
|
||||||
|
l.filter (project: project.impure && ! project.resolved) projectsList;
|
||||||
|
|
||||||
|
# for printing the paths inside the error message
|
||||||
projectsImpureUnresolvedPaths =
|
projectsImpureUnresolvedPaths =
|
||||||
l.map (project: project.relPath) projectsImpureUnresolved;
|
l.map (project: project.relPath) projectsImpureUnresolved;
|
||||||
|
|
||||||
# projects without existing valid dream-lock.json
|
# projects without existing valid dream-lock.json
|
||||||
projectsUnresolved = l.filter (project: ! project.resolved) projects;
|
projectsUnresolved = l.filter (project: ! project.resolved) projectsList;
|
||||||
|
|
||||||
# pure projects keyed by '{subsystem}_{translator_name}'
|
# pure projects grouped by translator
|
||||||
projectsByTranslator =
|
projectsByTranslator =
|
||||||
l.groupBy
|
l.groupBy
|
||||||
(proj: "${proj.subsystem}_${l.head proj.translators}")
|
(proj: "${proj.subsystem}_${l.head proj.translators}")
|
||||||
projectsUnresolved;
|
projectsUnresolved;
|
||||||
|
|
||||||
# list of pure projects extended with 'dreamLock' attribute
|
# list of pure projects extended with 'dreamLock' attribute
|
||||||
translatedProjects =
|
resolvedProjectsList =
|
||||||
l.mapAttrsToList
|
l.flatten
|
||||||
(translatorName: projects:
|
(l.mapAttrsToList
|
||||||
let
|
(translatorName: projects:
|
||||||
translator = getTranslator projects.subsystem translatorName;
|
let
|
||||||
in
|
p = l.head projects;
|
||||||
# transaltor will attach dreamLock to project
|
translator = getTranslator p.subsystem p.translator;
|
||||||
translator.translate {
|
in
|
||||||
inherit projects source tree;
|
# transaltor will attach dreamLock to project
|
||||||
})
|
translator.translate {
|
||||||
projectsByTranslator;
|
inherit projects source tree;
|
||||||
|
})
|
||||||
|
projectsByTranslator);
|
||||||
|
|
||||||
projectsResolved = projects // translatedProjects;
|
# attrset of projects by key which are now resolved
|
||||||
|
resolvedProjectsKeyed =
|
||||||
|
l.listToAttrs
|
||||||
|
(l.map
|
||||||
|
(proj: l.nameValuePair proj.key proj)
|
||||||
|
resolvedProjectsList);
|
||||||
|
|
||||||
|
# replace all unresolved projects with resolved ones
|
||||||
|
projectsFinal =
|
||||||
|
l.attrValues (projects // resolvedProjectsKeyed);
|
||||||
|
|
||||||
in
|
in
|
||||||
if projectsImpureUnresolved != [] then
|
if projectsImpureUnresolved != [] then
|
||||||
@ -484,7 +511,7 @@ let
|
|||||||
${l.concatStringsSep "\n " projectsImpureUnresolvedPaths}
|
${l.concatStringsSep "\n " projectsImpureUnresolvedPaths}
|
||||||
''
|
''
|
||||||
else
|
else
|
||||||
projectsResolved;
|
projectsFinal;
|
||||||
|
|
||||||
# produce outputs for a dream-lock or a source
|
# produce outputs for a dream-lock or a source
|
||||||
makeOutputs =
|
makeOutputs =
|
||||||
@ -554,6 +581,7 @@ in
|
|||||||
fetchers
|
fetchers
|
||||||
fetchSources
|
fetchSources
|
||||||
makeOutputs
|
makeOutputs
|
||||||
|
resolveAllProjects
|
||||||
riseAndShine
|
riseAndShine
|
||||||
translators
|
translators
|
||||||
updaters
|
updaters
|
||||||
|
@ -21,7 +21,7 @@ let
|
|||||||
let
|
let
|
||||||
nodes = l.readDir path;
|
nodes = l.readDir path;
|
||||||
in
|
in
|
||||||
l.optionals (nodes ? "package-lock.json") [ "package-lock" ]
|
l.optionals (nodes ? "package-lock.json") [ "package-lock2" ]
|
||||||
++ l.optionals (nodes ? "yarn.lock") [ "yarn-lock" ]
|
++ l.optionals (nodes ? "yarn.lock") [ "yarn-lock" ]
|
||||||
++ [ "package-json" ];
|
++ [ "package-json" ];
|
||||||
|
|
||||||
|
@ -253,6 +253,8 @@ rec {
|
|||||||
|
|
||||||
version = 2;
|
version = 2;
|
||||||
|
|
||||||
|
inherit translate;
|
||||||
|
|
||||||
|
|
||||||
projectName =
|
projectName =
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@ let
|
|||||||
defaults = {
|
defaults = {
|
||||||
overridesDirs = [];
|
overridesDirs = [];
|
||||||
packagesDir = "./packages";
|
packagesDir = "./packages";
|
||||||
projectRoot = "./.";
|
projectRoot = /project/root/not/set;
|
||||||
repoName = null;
|
repoName = null;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
Loading…
Reference in New Issue
Block a user