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