More relative path fixes
This commit is contained in:
+36
-21
@@ -45,14 +45,16 @@ export default async (
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sanity checks.
|
// Determine relative paths for Nix path literals.
|
||||||
const yarnPathAbs = configuration.get(`yarnPath`);
|
|
||||||
const nixExprPath = configuration.get(`nixExprPath`);
|
const nixExprPath = configuration.get(`nixExprPath`);
|
||||||
let yarnPath: PortablePath;
|
|
||||||
|
const yarnPathAbs = configuration.get(`yarnPath`);
|
||||||
|
let yarnPathExpr: string;
|
||||||
if (yarnPathAbs.startsWith(cwd)) {
|
if (yarnPathAbs.startsWith(cwd)) {
|
||||||
yarnPath = ppath.relative(ppath.dirname(nixExprPath), yarnPathAbs);
|
yarnPathExpr =
|
||||||
|
"./" + ppath.relative(ppath.dirname(nixExprPath), yarnPathAbs);
|
||||||
} else {
|
} else {
|
||||||
yarnPath = yarnPathAbs;
|
yarnPathExpr = json(yarnPathAbs);
|
||||||
report.reportWarning(
|
report.reportWarning(
|
||||||
0,
|
0,
|
||||||
`The Yarn path ${yarnPathAbs} is outside the project - it may not be reachable by the Nix build`
|
`The Yarn path ${yarnPathAbs} is outside the project - it may not be reachable by the Nix build`
|
||||||
@@ -60,29 +62,42 @@ export default async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const cacheFolderAbs = configuration.get(`cacheFolder`);
|
const cacheFolderAbs = configuration.get(`cacheFolder`);
|
||||||
let cacheFolder = ppath.relative(cwd, cacheFolderAbs);
|
let cacheFolderExpr: string;
|
||||||
if (cacheFolder.startsWith(`../`)) {
|
if (cacheFolderAbs.startsWith(cwd)) {
|
||||||
cacheFolder = cacheFolderAbs;
|
cacheFolderExpr =
|
||||||
|
"./" + ppath.relative(ppath.dirname(nixExprPath), cacheFolderAbs);
|
||||||
|
} else {
|
||||||
|
cacheFolderExpr = json(cacheFolderAbs);
|
||||||
report.reportWarning(
|
report.reportWarning(
|
||||||
0,
|
0,
|
||||||
`The cache folder ${cacheFolderAbs} is outside the project - it may not be reachable by the Nix build`
|
`The cache folder ${cacheFolderAbs} is outside the project - it may not be reachable by the Nix build`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const source of configuration.sources.values()) {
|
const configSources = new Set();
|
||||||
if (!source.startsWith(`<`)) {
|
for (const sourceList of configuration.sources.values()) {
|
||||||
const relativeSource = ppath.relative(cwd, source as PortablePath);
|
for (const source of sourceList.split(", ")) {
|
||||||
if (relativeSource.startsWith(`../`)) {
|
if (!source.startsWith(`<`)) {
|
||||||
report.reportWarning(
|
configSources.add(source);
|
||||||
0,
|
|
||||||
`The config file ${source} is outside the project - it may not be reachable by the Nix build`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (const source of configSources) {
|
||||||
|
const relativeSource = ppath.resolve(cwd, source as PortablePath);
|
||||||
|
if (!relativeSource.startsWith(cwd)) {
|
||||||
|
report.reportWarning(
|
||||||
|
0,
|
||||||
|
`The config file ${source} is outside the project - it may not be reachable by the Nix build`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Determine relative paths for Nix path literals.
|
const lockfileExpr =
|
||||||
const lockfileFilename = configuration.get(`lockfileFilename`);
|
"./" +
|
||||||
|
ppath.relative(
|
||||||
|
ppath.dirname(nixExprPath),
|
||||||
|
ppath.resolve(cwd, configuration.get(`lockfileFilename`))
|
||||||
|
);
|
||||||
|
|
||||||
// Build a list of cache entries so Nix can fetch them.
|
// Build a list of cache entries so Nix can fetch them.
|
||||||
// TODO: See if we can use Nix fetchurl for npm: dependencies.
|
// TODO: See if we can use Nix fetchurl for npm: dependencies.
|
||||||
@@ -278,9 +293,9 @@ export default async (
|
|||||||
const projectName = ident ? structUtils.stringifyIdent(ident) : `workspace`;
|
const projectName = ident ? structUtils.stringifyIdent(ident) : `workspace`;
|
||||||
const projectExpr = renderTmpl(projectExprTmpl, {
|
const projectExpr = renderTmpl(projectExprTmpl, {
|
||||||
PROJECT_NAME: json(projectName),
|
PROJECT_NAME: json(projectName),
|
||||||
YARN_PATH: yarnPath,
|
YARN_PATH: yarnPathExpr,
|
||||||
LOCKFILE: lockfileFilename,
|
LOCKFILE: lockfileExpr,
|
||||||
CACHE_FOLDER: json(cacheFolder),
|
CACHE_FOLDER: cacheFolderExpr,
|
||||||
CACHE_ENTRIES: cacheEntriesCode,
|
CACHE_ENTRIES: cacheEntriesCode,
|
||||||
ISOLATED: isolatedCode.join("\n"),
|
ISOLATED: isolatedCode.join("\n"),
|
||||||
ISOLATED_INTEGRATION: indent(" ", isolatedIntegration.join("\n")),
|
ISOLATED_INTEGRATION: indent(" ", isolatedIntegration.join("\n")),
|
||||||
|
|||||||
@@ -7,9 +7,7 @@
|
|||||||
let
|
let
|
||||||
|
|
||||||
cacheFolder = @@CACHE_FOLDER@@;
|
cacheFolder = @@CACHE_FOLDER@@;
|
||||||
#@@ IF NEED_ISOLATED_BUILD_SUPPRORT
|
lockfile = @@LOCKFILE@@;
|
||||||
lockfile = ./@@LOCKFILE@@;
|
|
||||||
#@@ ENDIF NEED_ISOLATED_BUILD_SUPPRORT
|
|
||||||
|
|
||||||
# Call overrideAttrs on a derivation if a function is provided.
|
# Call overrideAttrs on a derivation if a function is provided.
|
||||||
optionalOverride = fn: drv:
|
optionalOverride = fn: drv:
|
||||||
@@ -17,7 +15,7 @@ let
|
|||||||
|
|
||||||
# Simple stub that provides the global yarn command.
|
# Simple stub that provides the global yarn command.
|
||||||
yarn = writeShellScriptBin "yarn" ''
|
yarn = writeShellScriptBin "yarn" ''
|
||||||
exec '${nodejs}/bin/node' '${./@@YARN_PATH@@}' "$@"
|
exec '${nodejs}/bin/node' '${@@YARN_PATH@@}' "$@"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Common attributes between Yarn derivations.
|
# Common attributes between Yarn derivations.
|
||||||
@@ -164,7 +162,7 @@ let
|
|||||||
mkdir -p "$out/libexec/$name"
|
mkdir -p "$out/libexec/$name"
|
||||||
tar xzvf package.tgz --directory "$out/libexec/$name" --strip-components=1
|
tar xzvf package.tgz --directory "$out/libexec/$name" --strip-components=1
|
||||||
|
|
||||||
cp .yarnrc* '@@LOCKFILE@@' "$out/libexec/$name"
|
cp .yarnrc* ${lockfile} "$out/libexec/$name"
|
||||||
cp --recursive .yarn "$out/libexec/$name"
|
cp --recursive .yarn "$out/libexec/$name"
|
||||||
|
|
||||||
# If the project uses the node-modules linker, then
|
# If the project uses the node-modules linker, then
|
||||||
|
|||||||
Reference in New Issue
Block a user