Fix incomplete render when --mode is used

This commit is contained in:
Stéphan Kochen
2022-10-23 08:58:56 +02:00
parent 2f198930a4
commit c02b964a4c
2 changed files with 36 additions and 25 deletions
+12 -1
View File
@@ -10,6 +10,7 @@ import {
Cache, Cache,
execUtils, execUtils,
hashUtils, hashUtils,
InstallMode,
LocatorHash, LocatorHash,
Package, Package,
Project, Project,
@@ -22,8 +23,12 @@ import projectExprTmpl from "./tmpl/yarn-project.nix.in";
import { tmpdir } from "os"; import { tmpdir } from "os";
// Generator function that runs after `yarn install`. // Generator function that runs after `yarn install`.
export default async (project: Project, cache: Cache, report: Report) => { export default async (
project: Project,
opts: { cache: Cache; report: Report; mode?: InstallMode }
) => {
const { configuration, cwd } = project; const { configuration, cwd } = project;
const { cache, report } = opts;
// This case happens with `yarn dlx`, for example, and may cause errors if // This case happens with `yarn dlx`, for example, and may cause errors if
// special settings don't apply to those installations. (Like a `nixExprPath` // special settings don't apply to those installations. (Like a `nixExprPath`
@@ -267,6 +272,11 @@ export default async (project: Project, cache: Cache, report: Report) => {
} }
// Render the Nix expression. // Render the Nix expression.
//
// If isolated builds are used, we rely on the build state, so don't render
// if a special `--mode` was specified. This is because skipping builds may
// give us an incomplete build state.
if (opts.mode == null || isolatedBuilds.length === 0) {
const ident = project.topLevelWorkspace.manifest.name; const ident = project.topLevelWorkspace.manifest.name;
const projectName = ident ? structUtils.stringifyIdent(ident) : `workspace`; const projectName = ident ? structUtils.stringifyIdent(ident) : `workspace`;
const projectExpr = renderTmpl(projectExprTmpl, { const projectExpr = renderTmpl(projectExprTmpl, {
@@ -293,6 +303,7 @@ export default async (project: Project, cache: Cache, report: Report) => {
); );
} }
} }
}
// Preload the cache entries into the Nix store. // Preload the cache entries into the Nix store.
if ( if (
+1 -1
View File
@@ -25,7 +25,7 @@ const plugin: Plugin<Hooks> = {
opts.persistProject !== false && opts.persistProject !== false &&
project.configuration.get(`enableNixify`) project.configuration.get(`enableNixify`)
) { ) {
await generate(project, opts.cache, opts.report); await generate(project, opts);
} }
}, },
}, },