Unverified Commit 6181939c authored by Sandro Jäckel's avatar Sandro Jäckel Committed by Lily Foster
Browse files

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.
parent b6f3d249
Loading
Loading
Loading
Loading
+32 −12
Original line number Diff line number Diff line
@@ -13,29 +13,49 @@ in {
    name = "prefetch-yarn-deps";

    dontUnpack = true;
    dontBuild = true;

    nativeBuildInputs = [ makeWrapper ];
    buildInputs = [ coreutils nix-prefetch-git nodejs-slim nix ];
    buildInputs = [ nodejs-slim ];

    buildPhase = ''
      runHook preBuild
    installPhase = ''
      runHook preInstall

      mkdir -p $out/bin $out/libexec

      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
      mv index.js $out/libexec/yarnpkg-lockfile.js
      cp ${./.}/common.js ${./.}/index.js $out/libexec/

      runHook postBuild
      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
      cp -r libexec $out
      makeWrapper $out/libexec/index.js $out/bin/prefetch-yarn-deps \
        --prefix PATH : ${lib.makeBinPath [ coreutils nix-prefetch-git nix ]}
      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
+1 −0
Original line number Diff line number Diff line
@@ -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;