fetchYarnDeps: support passing src attribute (#193047)

authored by Yureka and committed by GitHub aa3dc644 77049230

+12 -7
+12 -7
pkgs/build-support/node/fetch-yarn-deps/default.nix
··· 42 fetchYarnDeps = let 43 f = { 44 name ? "offline", 45 - yarnLock, 46 hash ? "", 47 sha256 ? "", 48 - }: let 49 hash_ = 50 if hash != "" then { outputHashAlgo = null; outputHash = hash; } 51 else if sha256 != "" then { outputHashAlgo = "sha256"; outputHash = sha256; } 52 else { outputHashAlgo = "sha256"; outputHash = lib.fakeSha256; }; 53 - in stdenv.mkDerivation { 54 inherit name; 55 56 - dontUnpack = true; 57 dontInstall = true; 58 59 nativeBuildInputs = [ prefetch-yarn-deps ]; 60 GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; 61 62 buildPhase = '' 63 mkdir -p $out 64 - (cd $out; prefetch-yarn-deps --verbose --builder ${yarnLock}) 65 ''; 66 67 outputHashMode = "recursive"; 68 - inherit (hash_) outputHashAlgo outputHash; 69 - }; 70 71 in lib.setFunctionArgs f (lib.functionArgs f) // { 72 tests = callPackage ./tests {};
··· 42 fetchYarnDeps = let 43 f = { 44 name ? "offline", 45 + src ? null, 46 hash ? "", 47 sha256 ? "", 48 + ... 49 + }@args: let 50 hash_ = 51 if hash != "" then { outputHashAlgo = null; outputHash = hash; } 52 else if sha256 != "" then { outputHashAlgo = "sha256"; outputHash = sha256; } 53 else { outputHashAlgo = "sha256"; outputHash = lib.fakeSha256; }; 54 + in stdenv.mkDerivation ({ 55 inherit name; 56 57 + dontUnpack = src == null; 58 dontInstall = true; 59 60 nativeBuildInputs = [ prefetch-yarn-deps ]; 61 GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; 62 63 buildPhase = '' 64 + runHook preBuild 65 + 66 + yarnLock=''${yarnLock:=$PWD/yarn.lock} 67 mkdir -p $out 68 + (cd $out; prefetch-yarn-deps --verbose --builder $yarnLock) 69 + 70 + runHook postBuild 71 ''; 72 73 outputHashMode = "recursive"; 74 + } // hash_ // (removeAttrs args ["src" "name" "hash" "sha256"])); 75 76 in lib.setFunctionArgs f (lib.functionArgs f) // { 77 tests = callPackage ./tests {};