From c0b506c51d36608e874330ade8244e9d198e4e6c Mon Sep 17 00:00:00 2001 From: DavHau Date: Sat, 30 Jul 2022 17:48:24 +0200 Subject: [PATCH 1/8] feat: nodejs: improve electron override logic - ignore electron versions < 3 - update print-hashes.sh - add hashes for version 17 and 18 --- overrides/nodejs/default.nix | 19 +++++++++++++++++++ overrides/nodejs/electron/print-hashes.sh | 4 ++-- .../nodejs/builders/granular/default.nix | 5 ++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/overrides/nodejs/default.nix b/overrides/nodejs/default.nix index b38d1031e9..7f88c5f95f 100644 --- a/overrides/nodejs/default.nix +++ b/overrides/nodejs/default.nix @@ -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 diff --git a/overrides/nodejs/electron/print-hashes.sh b/overrides/nodejs/electron/print-hashes.sh index 91dd8dc5bf..0a08395c4c 100755 --- a/overrides/nodejs/electron/print-hashes.sh +++ b/overrides/nodejs/electron/print-hashes.sh @@ -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: diff --git a/src/subsystems/nodejs/builders/granular/default.nix b/src/subsystems/nodejs/builders/granular/default.nix index 2fb10bee64..de4a4b21a1 100644 --- a/src/subsystems/nodejs/builders/granular/default.nix +++ b/src/subsystems/nodejs/builders/granular/default.nix @@ -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; From b8991162778777e2f84db9a92d4fbc96376d0e0c Mon Sep 17 00:00:00 2001 From: DavHau Date: Sat, 30 Jul 2022 17:50:00 +0200 Subject: [PATCH 2/8] feat: fetchers: git: improve error message on invalid ref/rev --- src/fetchers/git/default.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/fetchers/git/default.nix b/src/fetchers/git/default.nix index 6bf49818d5..badff057b0 100644 --- a/src/fetchers/git/default.nix +++ b/src/fetchers/git/default.nix @@ -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; From ee4a3e7062cae3144b78024b6dbea96ea1c3efa7 Mon Sep 17 00:00:00 2001 From: DavHau Date: Sat, 30 Jul 2022 17:52:49 +0200 Subject: [PATCH 3/8] feat: nodejs: package-lock: handle bundled dependenceis better - assume bundled dep if type looks like http but resolved field is missing - use path source type to handle bundled deps --- .../translators/package-lock/default.nix | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/subsystems/nodejs/translators/package-lock/default.nix b/src/subsystems/nodejs/translators/package-lock/default.nix index 7a3cac5d8a..61d8325159 100644 --- a/src/subsystems/nodejs/translators/package-lock/default.nix +++ b/src/subsystems/nodejs/translators/package-lock/default.nix @@ -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"; @@ -245,11 +250,25 @@ }; 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 "https://" dependencyObject.version) + && (! dependencyObject ? resolved) + 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: From fb16017634d241f08a84d0f2b0a3a17082fd40dd Mon Sep 17 00:00:00 2001 From: DavHau Date: Sat, 30 Jul 2022 17:53:34 +0200 Subject: [PATCH 4/8] fix: nodejs: package-json: ignore yarn.lock during translation --- src/subsystems/nodejs/translators/package-json/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/subsystems/nodejs/translators/package-json/default.nix b/src/subsystems/nodejs/translators/package-json/default.nix index 2e1cbfa5c2..f068be0db0 100644 --- a/src/subsystems/nodejs/translators/package-json/default.nix +++ b/src/subsystems/nodejs/translators/package-json/default.nix @@ -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 From 5bf294508cd14ab9149176b70dbad2350bd35d89 Mon Sep 17 00:00:00 2001 From: DavHau Date: Sat, 30 Jul 2022 17:54:02 +0200 Subject: [PATCH 5/8] fix: indexers: don't fail on single translation error --- src/apps/translate-index/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/translate-index/default.nix b/src/apps/translate-index/default.nix index 3654efbd77..3229d7bef6 100644 --- a/src/apps/translate-index/default.nix +++ b/src/apps/translate-index/default.nix @@ -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 From 72ad849610316fc85abf739805dd8de8c9da5d8b Mon Sep 17 00:00:00 2001 From: DavHau Date: Sun, 31 Jul 2022 17:59:24 +0200 Subject: [PATCH 6/8] fix: nodejs: bundle dependency mistake in translation to path type --- src/subsystems/nodejs/translators/package-lock/default.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/subsystems/nodejs/translators/package-lock/default.nix b/src/subsystems/nodejs/translators/package-lock/default.nix index 61d8325159..e420f71974 100644 --- a/src/subsystems/nodejs/translators/package-lock/default.nix +++ b/src/subsystems/nodejs/translators/package-lock/default.nix @@ -251,9 +251,7 @@ path = dependencyObject: # in case of an entry with missing resolved field - if - (! lib.hasPrefix "https://" dependencyObject.version) - && (! dependencyObject ? resolved) + if ! lib.hasPrefix "file:" dependencyObject.version then dlib.construct.pathSource { path = let From cb394b8d7eafe18e39768cd126c0a33f16ef5f98 Mon Sep 17 00:00:00 2001 From: DavHau Date: Sun, 31 Jul 2022 17:59:56 +0200 Subject: [PATCH 7/8] refactor: rename nodejs workspace example2 --- examples/{nodejs_workspace-example => nodejs_workspace}/flake.nix | 0 .../{nodejs_workspace-example => nodejs_workspace}/package.json | 0 .../packages/cli/bin/cli.js | 0 .../packages/cli/package.json | 0 .../packages/lib/package.json | 0 .../packages/lib/src/main.js | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename examples/{nodejs_workspace-example => nodejs_workspace}/flake.nix (100%) rename examples/{nodejs_workspace-example => nodejs_workspace}/package.json (100%) rename examples/{nodejs_workspace-example => nodejs_workspace}/packages/cli/bin/cli.js (100%) rename examples/{nodejs_workspace-example => nodejs_workspace}/packages/cli/package.json (100%) rename examples/{nodejs_workspace-example => nodejs_workspace}/packages/lib/package.json (100%) rename examples/{nodejs_workspace-example => nodejs_workspace}/packages/lib/src/main.js (100%) diff --git a/examples/nodejs_workspace-example/flake.nix b/examples/nodejs_workspace/flake.nix similarity index 100% rename from examples/nodejs_workspace-example/flake.nix rename to examples/nodejs_workspace/flake.nix diff --git a/examples/nodejs_workspace-example/package.json b/examples/nodejs_workspace/package.json similarity index 100% rename from examples/nodejs_workspace-example/package.json rename to examples/nodejs_workspace/package.json diff --git a/examples/nodejs_workspace-example/packages/cli/bin/cli.js b/examples/nodejs_workspace/packages/cli/bin/cli.js similarity index 100% rename from examples/nodejs_workspace-example/packages/cli/bin/cli.js rename to examples/nodejs_workspace/packages/cli/bin/cli.js diff --git a/examples/nodejs_workspace-example/packages/cli/package.json b/examples/nodejs_workspace/packages/cli/package.json similarity index 100% rename from examples/nodejs_workspace-example/packages/cli/package.json rename to examples/nodejs_workspace/packages/cli/package.json diff --git a/examples/nodejs_workspace-example/packages/lib/package.json b/examples/nodejs_workspace/packages/lib/package.json similarity index 100% rename from examples/nodejs_workspace-example/packages/lib/package.json rename to examples/nodejs_workspace/packages/lib/package.json diff --git a/examples/nodejs_workspace-example/packages/lib/src/main.js b/examples/nodejs_workspace/packages/lib/src/main.js similarity index 100% rename from examples/nodejs_workspace-example/packages/lib/src/main.js rename to examples/nodejs_workspace/packages/lib/src/main.js From 7564d81e50c871352b69c7097b146339e68c30ea Mon Sep 17 00:00:00 2001 From: DavHau Date: Sun, 31 Jul 2022 18:00:52 +0200 Subject: [PATCH 8/8] rafactor: rename rust example --- .../{rust_no-cargo-lock-example => rust_no-cargo-lock}/flake.nix | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{rust_no-cargo-lock-example => rust_no-cargo-lock}/flake.nix (100%) diff --git a/examples/rust_no-cargo-lock-example/flake.nix b/examples/rust_no-cargo-lock/flake.nix similarity index 100% rename from examples/rust_no-cargo-lock-example/flake.nix rename to examples/rust_no-cargo-lock/flake.nix