automatically add dreamLockPath to discovered projects

This commit is contained in:
DavHau 2022-03-04 21:24:47 +07:00
parent 017b2e0144
commit b1b80111d2
2 changed files with 30 additions and 17 deletions

View File

@ -521,19 +521,6 @@ let
in
dreamLockExists && dreamLockValid;
getDreamLockPath = project:
let
root =
if config.projectRoot == null then
"/projectRoot_not_set_in_dream2nix_config"
else
config.projectRoot;
in
"${root}/"
+
(dlib.sanitizeRelativePath
"${config.packagesDir}/${pname}/${project.relPath}/dream-lock.json");
getProjectKey = project:
"${project.name}_|_${project.subsystem}_|_${project.relPath}";
@ -541,8 +528,7 @@ let
projectsList =
l.map
(project: project // (let self = rec {
dreamLockPath = getDreamLockPath project;
dreamLock = dlib.readDreamLock dreamLockPath;
dreamLock = dlib.readDreamLock project.dreamLockPath;
impure = isImpure project translator;
key = getProjectKey project;
resolved = isResolved self;
@ -752,4 +738,8 @@ in
updaters
utils
;
inherit (dlib)
discoverers
;
}

View File

@ -1,4 +1,5 @@
{
config,
dlib,
lib,
}:
@ -19,13 +20,35 @@ let
tree ? dlib.prepareSourceTree { inherit source; },
settings ? [],
}: let
discovered =
discoveredProjects =
l.flatten
(l.map
(discoverer: discoverer.discover { inherit tree; })
allDiscoverers);
rootProjectName = l.head discoveredProjects;
projectsExtended = l.forEach discoveredProjects
(proj: proj
// {
translator = l.head proj.translators;
dreamLockPath = getDreamLockPath proj rootProjectName;
});
in
applyProjectSettings discovered settings;
applyProjectSettings projectsExtended settings;
getDreamLockPath = project: rootProject:
let
root =
if config.projectRoot == null then
"."
else
config.projectRoot;
in
"${root}/"
+
(dlib.sanitizeRelativePath
"${config.packagesDir}/${rootProject.name}/${project.relPath}/dream-lock.json");
applyProjectSettings = projects: settingsList:
let