-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkYarnRun.nix
More file actions
39 lines (34 loc) · 979 Bytes
/
Copy pathmkYarnRun.nix
File metadata and controls
39 lines (34 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
_: {
packages.mkYarnRun = {writeShellApplication}: {
cache,
unplugged,
yarn,
preRun,
...
} @ opts: let
setNodeOptions =
if (builtins.hasAttr "nodeOptions" opts)
then "export NODE_OPTIONS=\"${opts.nodeOptions}\""
else "";
in
writeShellApplication {
name = "yarn-run";
runtimeInputs = [yarn];
text = ''
# Check and symlink cache directory
CACHE_PATH=$(yarn config get cacheFolder)
if [ ! -e "$CACHE_PATH" ]; then
cp --reflink=auto --recursive ${cache} "$CACHE_PATH"
fi
# Check and symlink unplugged directory
UNPLUGGED_PATH=$(yarn config get pnpUnpluggedFolder)
if [ ! -e "$UNPLUGGED_PATH" ]; then
cp --reflink=auto --recursive ${unplugged} "$UNPLUGGED_PATH"
fi
WORKSPACE_ROOT="$(dirname "$(dirname "$UNPLUGGED_PATH")")"
${setNodeOptions}
${preRun}
${yarn}/bin/yarn "$@"
'';
};
}