about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/pnpm/fetch-deps/serve.nix
blob: a44022d841dc5b05b0211119985bd17a49251b55 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{ 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"
  '';
}