fetchYarnDeps: support passing src attribute (#193047)

This commit is contained in:
Yureka 2022-10-02 22:41:31 +02:00 committed by GitHub
parent 770492307c
commit aa3dc6440e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -42,31 +42,36 @@ in {
fetchYarnDeps = let
f = {
name ? "offline",
yarnLock,
src ? null,
hash ? "",
sha256 ? "",
}: let
...
}@args: let
hash_ =
if hash != "" then { outputHashAlgo = null; outputHash = hash; }
else if sha256 != "" then { outputHashAlgo = "sha256"; outputHash = sha256; }
else { outputHashAlgo = "sha256"; outputHash = lib.fakeSha256; };
in stdenv.mkDerivation {
in stdenv.mkDerivation ({
inherit name;
dontUnpack = true;
dontUnpack = src == null;
dontInstall = true;
nativeBuildInputs = [ prefetch-yarn-deps ];
GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
buildPhase = ''
runHook preBuild
yarnLock=''${yarnLock:=$PWD/yarn.lock}
mkdir -p $out
(cd $out; prefetch-yarn-deps --verbose --builder ${yarnLock})
(cd $out; prefetch-yarn-deps --verbose --builder $yarnLock)
runHook postBuild
'';
outputHashMode = "recursive";
inherit (hash_) outputHashAlgo outputHash;
};
} // hash_ // (removeAttrs args ["src" "name" "hash" "sha256"]));
in lib.setFunctionArgs f (lib.functionArgs f) // {
tests = callPackage ./tests {};