about summary refs log tree commit diff
path: root/pkgs/development/tools/pnpm/fetch-deps/serve.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/tools/pnpm/fetch-deps/serve.nix')
-rw-r--r--pkgs/development/tools/pnpm/fetch-deps/serve.nix30
1 files changed, 30 insertions, 0 deletions
diff --git a/pkgs/development/tools/pnpm/fetch-deps/serve.nix b/pkgs/development/tools/pnpm/fetch-deps/serve.nix
new file mode 100644
index 0000000000000..a44022d841dc5
--- /dev/null
+++ b/pkgs/development/tools/pnpm/fetch-deps/serve.nix
@@ -0,0 +1,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"
+  '';
+}