fixup-yarn-lock: split out from prefetch-yarn-deps, cleanup installing

To reduce dependencies (mainly nix-prefetch-git and through that git,
git-lfs) when we just need to fixup a lock file, eg when building electron.
This also tries to avoid needless rebuilds when eg. golang is updated.

Also this cleans up and combined the build/installPhase of both tools to
be a lot simpler.

authored by Sandro Jäckel and committed by Lily Foster 6181939c b6f3d249

+33 -12
+32 -12
pkgs/build-support/node/fetch-yarn-deps/default.nix
··· 13 13 name = "prefetch-yarn-deps"; 14 14 15 15 dontUnpack = true; 16 + dontBuild = true; 16 17 17 18 nativeBuildInputs = [ makeWrapper ]; 18 - buildInputs = [ coreutils nix-prefetch-git nodejs-slim nix ]; 19 + buildInputs = [ nodejs-slim ]; 20 + 21 + installPhase = '' 22 + runHook preInstall 19 23 20 - buildPhase = '' 21 - runHook preBuild 24 + mkdir -p $out/bin $out/libexec 22 25 23 - mkdir libexec 24 26 tar --strip-components=1 -xf ${yarnpkg-lockfile-tar} package/index.js 25 - mv index.js libexec/yarnpkg-lockfile.js 26 - cp ${./.}/*.js libexec/ 27 - patchShebangs libexec 27 + mv index.js $out/libexec/yarnpkg-lockfile.js 28 + cp ${./.}/common.js ${./.}/index.js $out/libexec/ 29 + 30 + patchShebangs $out/libexec 31 + makeWrapper $out/libexec/index.js $out/bin/prefetch-yarn-deps \ 32 + --prefix PATH : ${lib.makeBinPath [ coreutils nix-prefetch-git nix ]} 28 33 29 - runHook postBuild 34 + runHook postInstall 30 35 ''; 31 36 37 + passthru = { inherit tests; }; 38 + }; 39 + 40 + fixup-yarn-lock = stdenv.mkDerivation { 41 + name = "fixup-yarn-lock"; 42 + 43 + dontUnpack = true; 44 + dontBuild = true; 45 + 46 + nativeBuildInputs = [ makeWrapper ]; 47 + buildInputs = [ nodejs-slim ]; 48 + 32 49 installPhase = '' 33 50 runHook preInstall 34 51 35 - mkdir -p $out/bin 36 - cp -r libexec $out 37 - makeWrapper $out/libexec/index.js $out/bin/prefetch-yarn-deps \ 38 - --prefix PATH : ${lib.makeBinPath [ coreutils nix-prefetch-git nix ]} 52 + mkdir -p $out/bin $out/libexec 53 + 54 + tar --strip-components=1 -xf ${yarnpkg-lockfile-tar} package/index.js 55 + mv index.js $out/libexec/yarnpkg-lockfile.js 56 + cp ${./.}/common.js ${./.}/fixup.js $out/libexec/ 57 + 58 + patchShebangs $out/libexec 39 59 makeWrapper $out/libexec/fixup.js $out/bin/fixup-yarn-lock 40 60 41 61 runHook postInstall
+1
pkgs/top-level/all-packages.nix
··· 1022 1022 fetchpijul = callPackage ../build-support/fetchpijul { }; 1023 1023 1024 1024 inherit (callPackages ../build-support/node/fetch-yarn-deps { }) 1025 + fixup-yarn-lock 1025 1026 prefetch-yarn-deps 1026 1027 fetchYarnDeps; 1027 1028