-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdefault.nix
39 lines (38 loc) · 1.25 KB
/
default.nix
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
{ runCommandNoCC
, electron
, writeShellScriptBin
, callPackage
}:
let
utils = callPackage ./utils.nix {};
drv = runCommandNoCC
utils.node2nixDev.name
{
version = utils.node2nixDev.version;
packageName = utils.node2nixDev.packageName;
}
''
mkdir -p $out/lib/node_modules/${utils.node2nixDev.packageName}
# copy only the dist
cp -r ${utils.node2nixDev}/lib/node_modules/${utils.node2nixDev.packageName}/dist $out/lib/node_modules/${utils.node2nixDev.packageName}/
# copy over the production dependencies
if [ -d "${utils.node2nixProd}/lib/node_modules" ]; then
cp -r ${utils.node2nixProd}/lib/node_modules $out/lib/node_modules/${utils.node2nixDev.packageName}/
fi
# create symlink to the deployed executable folder, if applicable
if [ -d "${utils.node2nixDev}/lib/node_modules/.bin" ]; then
cp -r ${utils.node2nixDev}/lib/node_modules/.bin $out/lib/node_modules/
ln -s $out/lib/node_modules/.bin $out/bin
fi
'';
drvWrapper = (
writeShellScriptBin utils.basename
''
exec ${electron}/bin/electron ${drv}/lib/node_modules/${drv.packageName}/dist "$@"
''
).overrideAttrs(attrs: {
name = "${attrs.name}-${drv.version}";
version = drv.version;
});
in
drvWrapper