Skip to content

Commit

Permalink
Merge pull request #218 from nix-community/nodejs
Browse files Browse the repository at this point in the history
Nodejs + fetcher improvments
  • Loading branch information
DavHau authored Jul 31, 2022
2 parents 26dce97 + 7564d81 commit 2fcfba9
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 13 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions overrides/nodejs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,28 @@ in
aarch64-darwin = "65b9b3235efdb681e3a4db85068dc9fe6dfbcb7fbb146053c0a534e4b44a2f7a";
headers = "1xnbzskvf8p5a07bha41qqnw1hb68f019qrda3z2jn96m3qnj46r";
};
"17.4.10" = {
armv7l-linux = "b3e4e44ef4014cd34f8fa1c06fe714d600e0e42e95a152255fa48d7246a47bf8";
aarch64-linux = "3186b7ac800f421286157c0550a923e5dfc8b0209c0d1ed037a7cd837136113c";
x86_64-linux = "065fdd554993d9b1e52ad8093e6341d001c219f49d81f32f3dd457f544375380";
i686-linux = "4b3c6a82a53499a2fecf683d1aa225ba39cebec19f8d65fccf53a53c53ad7d9c";
x86_64-darwin = "54a773193c479a48f4094e8295dea48f2bc38759d19ce58466f3584797c504d7";
aarch64-darwin = "f8fbb8f2247e349bdd4b6e991443074c8342da4ca61dcad38c236c6ab52b6055";
headers = "1308wd86cfnnmj4idw3y96brsjix9pb8hw7y8wrxfh7ml6w1g9x7";
};
"18.3.6" = {
armv7l-linux = "78c95b7405c5d49de99c85f39a940e2d2409fa5f0a1c5c6e1fc908188f1180d8";
aarch64-linux = "359a1682f8d2f083215a8ff6ae3aab0889de4b78a44a8e8ce3095044820b78f1";
x86_64-linux = "81a04cf093980c36d99df2369d95ab7ed64b496a22125620478ac5d2b2989a28";
i686-linux = "902e89e40a32c7e6c49d3004a8ddf5e4c4015d0499bfba4827bdfa21280ef7c3";
x86_64-darwin = "db330f23f1e75c568c0e44e2fc07faa3a4f9fc6a7d3bf29feeb7f624608cb29c";
aarch64-darwin = "5a62d46c3c45b6e416bf77affccc94e26b7a21ff8bced466036fbe74ff59799a";
headers = "0wdw9xaxyn7zk6b4x4ldzallggxlxs293fwp6af4fa5a1c295gkn";
};
};
in {
add-binary = {
_condition = pkg: (l.toInt (l.versions.major pkg.version)) > 2;
overrideAttrs = old: {
postPatch =
if pkgs.stdenv.isLinux
Expand Down
4 changes: 2 additions & 2 deletions overrides/nodejs/electron/print-hashes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ SYSTEMS=(
[aarch64-darwin]=darwin-arm64
)

hashfile="$(nix-prefetch-url --print-path "https://github.com/electron/electron/releases/download/v${VERSION}/SHASUMS256.txt" 2>/dev/null | tail -n1)"
headers="$(nix-prefetch-url "https://atom.io/download/electron/v${VERSION}/node-v${VERSION}-headers.tar.gz")"
hashfile="$(nix-prefetch-url --print-path "https://github.com/electron/electron/releases/download/v${VERSION}/SHASUMS256.txt" | tail -n1)"
headers="$(nix-prefetch-url "https://artifacts.electronjs.org/headers/dist/v${VERSION}/node-v${VERSION}-headers.tar.gz")"

# Entry similar to the following goes in default.nix:

Expand Down
2 changes: 1 addition & 1 deletion src/apps/translate-index/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
...
}: let
script = writeScript "run-translate" ''
${translate}/bin/translate $1 $targetDir
${translate}/bin/translate $1 $targetDir || echo "Failed to translate $1"
'';
in
utils.writePureShellScriptBin
Expand Down
12 changes: 10 additions & 2 deletions src/fetchers/git/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@ in {
hasGitRef = inp.ref or null != null;
in
if isRevGitRef == null && isGitRev rev == null
then throw ''rev must either be a sha1 revision or "refs/heads/branch-name" or "refs/tags/tag-name"''
then
throw ''
invalid git rev: ${rev}
rev must either be a sha1 revision or "refs/heads/branch-name" or "refs/tags/tag-name"
''
else if hasGitRef && isGitRef inp.ref == null
then throw ''ref must be in either "refs/heads/branch-name" or "refs/tags/tag-name" format''
then
throw ''
invalid git ref: ${inp.ref or null}
ref must be in either "refs/heads/branch-name" or "refs/tags/tag-name" format
''
else let
b = builtins;

Expand Down
5 changes: 4 additions & 1 deletion src/subsystems/nodejs/builders/granular/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@
lib.versions.major electronDep.version;

electronHeaders =
if electronDep == null
if
(electronDep == null)
# hashes seem unavailable for electron < 4
|| ((l.toInt electronVersionMajor) <= 2)
then null
else pkgs."electron_${electronVersionMajor}".headers;

Expand Down
2 changes: 1 addition & 1 deletion src/subsystems/nodejs/translators/package-json/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
newSource=$(pwd)
cd ./$relPath
rm -rf package-lock.json
rm -rf package-lock.json yarn.lock
hasInstallScript=false
if [ "$(jq 'has("scripts")' -c -r package.json)" == "false" ]; then
Expand Down
29 changes: 23 additions & 6 deletions src/subsystems/nodejs/translators/package-lock/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,12 @@
getSourceType = dependencyObject:
if identifyGitSource dependencyObject
then "git"
else if lib.hasPrefix "file:" dependencyObject.version
else if
(lib.hasPrefix "file:" dependencyObject.version)
|| (
(! lib.hasPrefix "https://" dependencyObject.version)
&& (! dependencyObject ? resolved)
)
then "path"
else "http";

Expand Down Expand Up @@ -245,11 +250,23 @@
};

path = dependencyObject:
dlib.construct.pathSource {
path = getPath dependencyObject;
rootName = project.name;
rootVersion = packageVersion;
};
# in case of an entry with missing resolved field
if ! lib.hasPrefix "file:" dependencyObject.version
then
dlib.construct.pathSource {
path = let
module = l.elemAt (l.splitString "/" dependencyObject.pname) 0;
in "node_modules/${module}";
rootName = project.name;
rootVersion = packageVersion;
}
# in case of a "file:" entry
else
dlib.construct.pathSource {
path = getPath dependencyObject;
rootName = project.name;
rootVersion = packageVersion;
};
};

getDependencies = dependencyObject:
Expand Down

0 comments on commit 2fcfba9

Please sign in to comment.