mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-03 20:33:21 +00:00
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>
(cherry picked from commit 728d48285e
)
This commit is contained in:
parent
3f4a4d0672
commit
b4f5b3fa1a
@ -1,6 +1,7 @@
|
||||
{
|
||||
stdenvNoCC,
|
||||
fetchurl,
|
||||
callPackage,
|
||||
jq,
|
||||
moreutils,
|
||||
cacert,
|
||||
@ -29,7 +30,7 @@
|
||||
outputHashAlgo = "sha256";
|
||||
};
|
||||
in
|
||||
stdenvNoCC.mkDerivation (
|
||||
stdenvNoCC.mkDerivation (finalAttrs: (
|
||||
args'
|
||||
// {
|
||||
name = "${pname}-pnpm-deps";
|
||||
@ -69,12 +70,19 @@
|
||||
runHook postFixup
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
serve = callPackage ./serve.nix {
|
||||
inherit pnpm;
|
||||
pnpmDeps = finalAttrs.finalPackage;
|
||||
};
|
||||
};
|
||||
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
outputHashMode = "recursive";
|
||||
}
|
||||
// hash'
|
||||
);
|
||||
));
|
||||
|
||||
configHook = makeSetupHook {
|
||||
name = "pnpm-config-hook";
|
||||
|
30
pkgs/development/tools/pnpm/fetch-deps/serve.nix
Normal file
30
pkgs/development/tools/pnpm/fetch-deps/serve.nix
Normal file
@ -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"
|
||||
'';
|
||||
}
|
Loading…
Reference in New Issue
Block a user