Commit Graph

2 Commits

Author SHA1 Message Date
phaer
e2013a5096 importNpmLock: fix check for .bin in linkNodeModulesHook
node_modules/.bin/ is expected to be (symlink to) a directory rather
than a regular file, so we check for that.

This seems to work for pre-existing directories as well as those
we link to the store (managed & unmanaged in the hooks terminology).

I am not entirely sure whether the original check was simply a typo
or intentional for some use-cases.
2025-01-10 12:37:32 +01:00
adisbladis
9c7ff7277c importNpmLock.buildNodeModules: init
`importNpmLock.buildNodeModules` returns a derivation with a pre-built `node_modules` directory, as imported by `importNpmLock`.
This is to be used together with `importNpmLock.hooks.linkNodeModulesHook` to facilitate `nix-shell`/`nix develop` based development workflows:

```nix
pkgs.mkShell {
  packages = [
    importNpmLock.hooks.linkNodeModulesHook
    nodejs
  ];

  npmDeps = importNpmLock.buildNodeModules {
    npmRoot = ./.;
    inherit nodejs;
  };
}
```
will create a development shell where a `node_modules` directory is created & packages symlinked to the Nix store when activated.

This code is adapted from https://github.com/adisbladis/buildNodeModules
2024-08-29 06:12:07 -07:00