Skip to content

Commit aa9f6e9

Browse files
jtszalaycody-dot-js
authored andcommitted
nix pnpm corepack
1 parent 1d71bef commit aa9f6e9

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

.envrc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# if using nixos, run `use flake`
22
if has nix; then
33
use flake
4-
else
4+
else
55
# Check if nvm is installed, install if not
66
if [ ! -d "$NVM_DIR" ] || [ ! -s "$NVM_DIR/nvm.sh" ]; then
77
echo "nvm is not installed. Installing nvm..."
8-
8+
99
# Install nvm
1010
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
1111
fi
@@ -19,13 +19,13 @@ else
1919

2020
# install node version from .nvmrc
2121
nvm install
22-
fi
2322

24-
# enable pnpm in corepack
25-
corepack enable pnpm
23+
# enable pnpm in corepack
24+
corepack enable pnpm
2625

27-
# install package manager with corepack (from package.json#packageManager)
28-
corepack install
26+
# install package manager with corepack (from package.json#packageManager)
27+
corepack install
28+
fi
2929

3030
# install dependencies
3131
pnpm install

flake.nix

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@
1616
pkgs = import nixpkgs {
1717
inherit system;
1818
};
19-
node-toolchain = with pkgs; [
20-
nodejs
21-
nodePackages.pnpm
22-
];
19+
pnpm-shim = pkgs.writeShellScriptBin "pnpm" ''
20+
#!${pkgs.bash}/bin/bash
21+
exec ${pkgs.lib.getBin pkgs.nodejs_20}/bin/node ${pkgs.lib.getBin pkgs.nodejs_20}/bin/corepack pnpm "$@"
22+
'';
2323
in
2424
{
2525
devShell = pkgs.mkShell {
2626
shellHook = ''
2727
export PATH="$PATH:$(git rev-parse --show-toplevel)/node_modules/.bin"
2828
'';
2929
buildInputs = with pkgs; [
30-
node-toolchain
30+
nodejs_20
31+
corepack_20
32+
pnpm-shim
3133
];
3234
};
3335
});

0 commit comments

Comments
 (0)