41 lines
1.2 KiB
Nix
41 lines
1.2 KiB
Nix
{
|
|
pkgs,
|
|
src,
|
|
nodejs ? pkgs.nodejs_24,
|
|
}:
|
|
let
|
|
project = (pkgs.callPackage (src + "/yarn-project.nix") { inherit nodejs; }) {
|
|
inherit src;
|
|
overrideAttrs = _: {
|
|
buildPhase = "runHook preBuild; runHook postBuild";
|
|
installPhase = ''
|
|
set -o pipefail
|
|
runHook preInstall
|
|
test -d node_modules
|
|
test ! -L node_modules
|
|
mkdir -p "$out"
|
|
# Installation is finished: retire its disposable archive cache, then
|
|
# stream dependencies across the build/store mount boundary without
|
|
# retaining a second complete tree. This is the same installation
|
|
# policy used by Central's dependency derivations.
|
|
rm -rf .yarn/cache
|
|
${pkgs.gnutar}/bin/tar --create --file=- --remove-files node_modules \
|
|
| ${pkgs.gnutar}/bin/tar --extract --file=- --strip-components=1 --directory="$out"
|
|
# Node resolves installed packages directly. This generated index is for
|
|
# Yarn's linker, not a runtime input; do not export build-session state.
|
|
rm -f "$out/.yarn-state.yml"
|
|
runHook postInstall
|
|
'';
|
|
};
|
|
};
|
|
in
|
|
project
|
|
// {
|
|
devShell = pkgs.mkShell {
|
|
packages = [
|
|
nodejs
|
|
project.yarn-freestanding
|
|
];
|
|
};
|
|
}
|