|
11 | 11 | lib.optionalString (cfg.directory != config.devenv.root) ''"${cfg.directory}/"'' |
12 | 12 | }node_modules"; |
13 | 13 |
|
| 14 | + dirPrefix = lib.optionalString (cfg.directory != config.devenv.root) ''"${cfg.directory}/"''; |
| 15 | + |
14 | 16 | initNpmScript = pkgs.writeShellScript "init-npm.sh" '' |
15 | 17 | function _devenv-npm-install() |
16 | 18 | { |
17 | 19 | # Avoid running "npm install" for every shell. |
18 | 20 | # Only run it when the "package-lock.json" file or nodejs version has changed. |
19 | 21 | # We do this by storing the nodejs version and a hash of "package-lock.json" in node_modules. |
20 | | - local ACTUAL_NPM_CHECKSUM="${cfg.npm.package.version}:$(${pkgs.nix}/bin/nix-hash --type sha256 ${ |
21 | | - lib.optionalString (cfg.directory != config.devenv.root) ''"${cfg.directory}/"'' |
22 | | - }package-lock.json)" |
| 22 | + local ACTUAL_NPM_CHECKSUM="${cfg.npm.package.version}:${config.lib._fileChecksum "${dirPrefix}package-lock.json"}" |
23 | 23 | local NPM_CHECKSUM_FILE="${nodeModulesPath}/package-lock.json.checksum" |
24 | 24 | if [ -f "$NPM_CHECKSUM_FILE" ] |
25 | 25 | then |
|
61 | 61 | # Avoid running "pnpm install" for every shell. |
62 | 62 | # Only run it when the "package-lock.json" file or nodejs version has changed. |
63 | 63 | # We do this by storing the nodejs version and a hash of "package-lock.json" in node_modules. |
64 | | - local ACTUAL_PNPM_CHECKSUM="${cfg.pnpm.package.version}:$(${pkgs.nix}/bin/nix-hash --type sha256 ${ |
65 | | - lib.optionalString (cfg.directory != config.devenv.root) ''"${cfg.directory}/"'' |
66 | | - }pnpm-lock.yaml)" |
| 64 | + local ACTUAL_PNPM_CHECKSUM="${cfg.pnpm.package.version}:${config.lib._fileChecksum "${dirPrefix}pnpm-lock.yaml"}" |
67 | 65 | local PNPM_CHECKSUM_FILE="${nodeModulesPath}/pnpm-lock.yaml.checksum" |
68 | 66 | if [ -f "$PNPM_CHECKSUM_FILE" ] |
69 | 67 | then |
|
105 | 103 | # Avoid running "yarn install" for every shell. |
106 | 104 | # Only run it when the "yarn.lock" file or nodejs version has changed. |
107 | 105 | # We do this by storing the nodejs version and a hash of "yarn.lock" in node_modules. |
108 | | - local ACTUAL_YARN_CHECKSUM="${cfg.yarn.package.version}:$(${pkgs.nix}/bin/nix-hash --type sha256 ${ |
109 | | - lib.optionalString (cfg.directory != config.devenv.root) ''"${cfg.directory}/"'' |
110 | | - }yarn.lock)" |
| 106 | + local ACTUAL_YARN_CHECKSUM="${cfg.yarn.package.version}:${config.lib._fileChecksum "${dirPrefix}yarn.lock"}" |
111 | 107 | local YARN_CHECKSUM_FILE="${nodeModulesPath}/yarn.lock.checksum" |
112 | 108 | if [ -f "$YARN_CHECKSUM_FILE" ] |
113 | 109 | then |
|
150 | 146 | # Avoid running "bun install" for every shell. |
151 | 147 | # Only run it when the "bun.lock" file or nodejs version has changed. |
152 | 148 | # We do this by storing the nodejs version and a hash of "bun.lock" in node_modules. |
153 | | - local ACTUAL_BUN_CHECKSUM="${cfg.bun.package.version}:$(${pkgs.nix}/bin/nix-hash --type sha256 ${ |
154 | | - lib.optionalString (cfg.directory != config.devenv.root) ''"${cfg.directory}/"'' |
155 | | - }bun.lock)" |
| 149 | + local ACTUAL_BUN_CHECKSUM="${cfg.bun.package.version}:${config.lib._fileChecksum "${dirPrefix}bun.lock"}" |
156 | 150 | local BUN_CHECKSUM_FILE="${nodeModulesPath}/bun.lock.checksum" |
157 | 151 | if [ -f "$BUN_CHECKSUM_FILE" ] |
158 | 152 | then |
|
187 | 181 | # Avoid running "bun install --yarn" for every shell. |
188 | 182 | # Only run it when the "yarn.lock" file or nodejs version has changed. |
189 | 183 | # We do this by storing the nodejs version and a hash of "yarn.lock" in node_modules. |
190 | | - local ACTUAL_BUN_CHECKSUM="${cfg.bun.package.version}:$(${pkgs.nix}/bin/nix-hash --type sha256 ${ |
191 | | - lib.optionalString (cfg.directory != config.devenv.root) ''"${cfg.directory}/"'' |
192 | | - }yarn.lock)" |
| 184 | + local ACTUAL_BUN_CHECKSUM="${cfg.bun.package.version}:${config.lib._fileChecksum "${dirPrefix}yarn.lock"}" |
193 | 185 | local BUN_CHECKSUM_FILE="${nodeModulesPath}/yarn.lock.checksum" |
194 | 186 | if [ -f "$BUN_CHECKSUM_FILE" ] |
195 | 187 | then |
|
0 commit comments