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.
This commit is contained in:
Sandro Jäckel 2024-01-18 23:53:33 +01:00 committed by Lily Foster
parent b6f3d2497b
commit 6181939cdf
No known key found for this signature in database
GPG Key ID: 49340081E484C893
2 changed files with 36 additions and 15 deletions

View File

@ -13,29 +13,49 @@ in {
name = "prefetch-yarn-deps";
dontUnpack = true;
dontBuild = true;
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ coreutils nix-prefetch-git nodejs-slim nix ];
buildPhase = ''
runHook preBuild
mkdir libexec
tar --strip-components=1 -xf ${yarnpkg-lockfile-tar} package/index.js
mv index.js libexec/yarnpkg-lockfile.js
cp ${./.}/*.js libexec/
patchShebangs libexec
runHook postBuild
'';
buildInputs = [ nodejs-slim ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp -r libexec $out
mkdir -p $out/bin $out/libexec
tar --strip-components=1 -xf ${yarnpkg-lockfile-tar} package/index.js
mv index.js $out/libexec/yarnpkg-lockfile.js
cp ${./.}/common.js ${./.}/index.js $out/libexec/
patchShebangs $out/libexec
makeWrapper $out/libexec/index.js $out/bin/prefetch-yarn-deps \
--prefix PATH : ${lib.makeBinPath [ coreutils nix-prefetch-git nix ]}
runHook postInstall
'';
passthru = { inherit tests; };
};
fixup-yarn-lock = stdenv.mkDerivation {
name = "fixup-yarn-lock";
dontUnpack = true;
dontBuild = true;
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ nodejs-slim ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin $out/libexec
tar --strip-components=1 -xf ${yarnpkg-lockfile-tar} package/index.js
mv index.js $out/libexec/yarnpkg-lockfile.js
cp ${./.}/common.js ${./.}/fixup.js $out/libexec/
patchShebangs $out/libexec
makeWrapper $out/libexec/fixup.js $out/bin/fixup-yarn-lock
runHook postInstall

View File

@ -1022,6 +1022,7 @@ with pkgs;
fetchpijul = callPackage ../build-support/fetchpijul { };
inherit (callPackages ../build-support/node/fetch-yarn-deps { })
fixup-yarn-lock
prefetch-yarn-deps
fetchYarnDeps;