diff options
author | Martin Weinelt <hexa@darmstadt.ccc.de> | 2021-10-28 19:51:45 +0200 |
---|---|---|
committer | Martin Weinelt <hexa@darmstadt.ccc.de> | 2021-10-28 19:51:45 +0200 |
commit | da1f24822928ad74741d41526a2914231500b21d (patch) | |
tree | c954b8e5a8763735c482759dd181b33537601911 /pkgs/build-support | |
parent | 3f4420fc2ba9b16d34f2d6515b70a7812cc6c87b (diff) | |
parent | 842a0d94cbb0a385854e15d4f6fde57714981abd (diff) |
Merge remote-tracking branch 'origin/master' into staging-next
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/node/fetch-yarn-deps/default.nix | 2 | ||||
-rwxr-xr-x | pkgs/build-support/node/fetch-yarn-deps/index.js | 25 |
2 files changed, 20 insertions, 7 deletions
diff --git a/pkgs/build-support/node/fetch-yarn-deps/default.nix b/pkgs/build-support/node/fetch-yarn-deps/default.nix index 91aae055f6ada..6d67b87915ac2 100644 --- a/pkgs/build-support/node/fetch-yarn-deps/default.nix +++ b/pkgs/build-support/node/fetch-yarn-deps/default.nix @@ -49,7 +49,7 @@ in { hash_ = if hash != "" then { outputHashAlgo = null; outputHash = hash; } else if sha256 != "" then { outputHashAlgo = "sha256"; outputHash = sha256; } - else throw "fetchYarnDeps requires a hash"; + else { outputHashAlgo = "sha256"; outputHash = lib.fakeSha256; }; in stdenv.mkDerivation { inherit name; diff --git a/pkgs/build-support/node/fetch-yarn-deps/index.js b/pkgs/build-support/node/fetch-yarn-deps/index.js index a9c5ab29cce56..e728ad89e1c4f 100755 --- a/pkgs/build-support/node/fetch-yarn-deps/index.js +++ b/pkgs/build-support/node/fetch-yarn-deps/index.js @@ -18,6 +18,20 @@ const exec = async (...args) => { return res } +// This has to match the logic in pkgs/development/tools/yarn2nix-moretea/yarn2nix/lib/urlToName.js +// so that fixup_yarn_lock produces the same paths +const urlToName = url => { + const isCodeloadGitTarballUrl = url.startsWith('https://codeload.github.com/') && url.includes('/tar.gz/') + + if (url.startsWith('git+') || isCodeloadGitTarballUrl) { + return path.basename(url) + } else { + return url + .replace(/https:\/\/(.)*(.com)\//g, '') // prevents having long directory names + .replace(/[@/%:-]/g, '_') // replace @ and : and - and % characters with underscore + } +} + const downloadFileHttps = (fileName, url, expectedHash) => { return new Promise((resolve, reject) => { https.get(url, (res) => { @@ -61,19 +75,18 @@ const downloadGit = async (fileName, url, rev) => { const downloadPkg = (pkg, verbose) => { const [ url, hash ] = pkg.resolved.split('#') if (verbose) console.log('downloading ' + url) + const fileName = urlToName(url) if (url.startsWith('https://codeload.github.com/') && url.includes('/tar.gz/')) { - const fileName = path.basename(url) const s = url.split('/') downloadGit(fileName, `https://github.com/${s[3]}/${s[4]}.git`, s[6]) } else if (url.startsWith('https://')) { - const fileName = url - .replace(/https:\/\/(.)*(.com)\//g, '') // prevents having long directory names - .replace(/[@/%:-]/g, '_') // replace @ and : and - and % characters with underscore - return downloadFileHttps(fileName, url, hash) + } else if (url.startsWith('git:')) { + return downloadGit(fileName, url.replace(/^git\+/, ''), hash) } else if (url.startsWith('git+')) { - const fileName = path.basename(url) return downloadGit(fileName, url.replace(/^git\+/, ''), hash) + } else if (url.startsWith('file:')) { + console.warn(`ignoring unsupported file:path url "${url}"`) } else { throw new Error('don\'t know how to download "' + url + '"') } |