forked from eez-open/studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode_modules.nix
57 lines (51 loc) · 1.33 KB
/
node_modules.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{ src
, nodejs
, electron
}:
{ lib
, eudev
, npmlock2nix
, python3
, stdenv
, ...
}:
let
inherit (lib) optionals;
inherit (stdenv) isLinux;
in
npmlock2nix.node_modules {
inherit src nodejs;
ELECTRON_SKIP_BINARY_DOWNLOAD = 1;
npm_config_build_from_source = "true";
npm_config_fund = false;
npm_config_runtime = "electron";
npm_config_tarball = electron.headers;
npm_config_target = electron.version;
nativeBuildInputs = [
python3.out
] ++ optionals isLinux [
eudev.out # libudev.h
];
preInstallLinks = {
"electron" = {
"dist" = "${electron}/lib/electron";
};
};
installCommands = [
"npm ci --ignore-scripts --offline"
''
SCRIPT="$(readlink -f ./node_modules/.hooks/preinstall)"
package_dirs="$(find ./node_modules -type f -name "package.json" | xargs --no-run-if-empty dirname)"
while read package_dir; do
export npm_package_name="$(echo "$package_dir" | awk -F'/' '{ if ($(NF - 1) ~ /^@/) printf "%s/%s\n", $(NF -1), $NF; else print $NF }')"
pushd $package_dir
$SCRIPT
popd
done <<< "$package_dirs"
''
''
packages_with_gyp="$(find ./node_modules -name "*.gyp" | awk -F'/' '{ if ($3 ~ /^@/) printf "%s/%s\n", $3, $4; else print $3 }' | grep -v "npm" | uniq | tr "\n" " ")"
npm rebuild $packages_with_gyp
''
];
}