From bc3c3820b063ceff184e2a46527a5cad581084c7 Mon Sep 17 00:00:00 2001 From: DavHau Date: Sat, 5 Mar 2022 23:55:42 +0700 Subject: [PATCH] fix fallback on existing dream-lock.json --- src/default.nix | 50 +++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/src/default.nix b/src/default.nix index 89b7a010..46831464 100644 --- a/src/default.nix +++ b/src/default.nix @@ -504,22 +504,24 @@ let isImpure = project: translatorName: (getTranslator project.subsystem translatorName).type == "impure"; + getInvalidationHash = project: + dlib.calcInvalidationHash { + inherit source; + # TODO: add translatorArgs + translatorArgs = {}; + translator = project.translator; + }; + isResolved = project: let - dreamLockExists = l.pathExists "${config.projectRoot}/${project.dreamLockPath}"; - - invalidationHash = dlib.calcInvalidationHash { - inherit source; - # TODO: add translatorArgs - translatorArgs = {}; - translator = project.translator; - }; + dreamLockExists = + l.pathExists "${config.projectRoot}/${project.dreamLockPath}"; dreamLockValid = project.dreamLock.lock._generic.invalidationHash or "" - == invalidationHash; - in - dreamLockExists && dreamLockValid; + == project.invalidationHash; + in + dreamLockExists && dreamLockValid; getProjectKey = project: "${project.name}_|_${project.subsystem}_|_${project.relPath}"; @@ -527,11 +529,14 @@ let # list of projects extended with some information requried for processing projectsList = l.map - (project: project // (let self = rec { - dreamLock = dlib.readDreamLock "${config.projectRoot}/${project.dreamLockPath}"; + (project: (let self = project // rec { + dreamLock = utils.readDreamLock { + dreamLock = "${config.projectRoot}/${project.dreamLockPath}"; + }; impure = isImpure project translator; + invalidationHash = getInvalidationHash project; key = getProjectKey project; - resolved = isResolved project; + resolved = isResolved self; translator = project.translator or (l.head project.translators); }; in self)) discoveredProjects; @@ -571,13 +576,18 @@ let (proj: let translator = getTranslator proj.subsystem proj.translator; - in - proj - // { - dreamLock = translator.translate { - inherit source tree; - project = proj; + dreamLock' = translator.translate { + inherit source tree; + project = proj; + }; + dreamLock = dreamLock' // { + _generic = dreamLock'._generic // { + invalidationHash = proj.invalidationHash; }; + }; + in + proj // { + inherit dreamLock; }); resolvedProjects = projectsResolved ++ projectsResolvedOnTheFly;