nixpkgs/pkgs/development/tools/pnpm/fetch-deps/serve.nix
Sefa Eyeoglu 728d48285e
pnpm.fetchDeps: add serve script
This script allows users to reuse the cached dependencies outside of
derivations.

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
2024-06-02 19:56:11 +02:00

31 lines
594 B
Nix

{ writeShellApplication, pnpm, pnpmDeps }:
writeShellApplication {
name = "serve-pnpm-store";
runtimeInputs = [
pnpm
];
text = ''
storePath=$(mktemp -d)
clean() {
echo "Cleaning up temporary store at '$storePath'..."
rm -rf "$storePath"
}
echo "Copying pnpm store '${pnpmDeps}' to temporary store..."
cp -Tr "${pnpmDeps}" "$storePath"
chmod -R +w "$storePath"
echo "Run 'pnpm install --store-dir \"$storePath\"' to install packages from this store."
trap clean EXIT
pnpm server start \
--store-dir "$storePath"
'';
}