diff --git a/src/default.nix b/src/default.nix index 7aa5b273..8f0f1434 100644 --- a/src/default.nix +++ b/src/default.nix @@ -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 + ; } diff --git a/src/discoverers/default.nix b/src/discoverers/default.nix index 817ddace..e9c7e1ff 100644 --- a/src/discoverers/default.nix +++ b/src/discoverers/default.nix @@ -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