0

CAVEAT: If you would like to use Serverless Framework with Nix/NixOS, this is not the way to do it: the package you end up with is outdated, and (as stated below) it probably won't work anyway. See thread on NixOS Discourse.

Wanted to try out Serverless via nix-shell so I looked it up, ran the command

nix-shell -v -p nodePackages.serverless

a̶n̶d̶ i̶t̶ w̶o̶r̶k̶s̶ f̶l̶a̶w̶l̶e̶s̶s̶l̶y̶.1

What makes this possible without requiring me to install Node manually to be able to run npm install -g serverless? (E.g., Is the node_modules folder somewhere in the Nix store? What happens if I nix-shell another Node package - will they share that same directory?)


[1]: It does not... See this Reddit thread; probable setuid issue. Still interested in the behind the scene stuff though.

This question is more like a todo because I really would like to figure it out myself but don't have the time for it right now...

toraritte
  • 6,300
  • 3
  • 46
  • 67

1 Answers1

1

This is possible because it was packaged with node2nix. This tool generates expressions that fetch the various packages and put them in a node_modules directory. Indeed it's not perfect and some package need some extra fixing up to make them work well. The node2nix tooling could 'learn' from the cabal2nix integration in Nixpkgs to improve the quality of packaging and the Nixpkgs developer experience.

Robert Hensing
  • 6,708
  • 18
  • 23
  • Yes, I read everywhere about the superiority of how the Haskell community is using Nix, and the difficulties of dealing with languages that have their own package managers (probably the most relevant thread about this on the NixOS Discourse is [Status of lang2nix approaches](https://discourse.nixos.org/t/status-of-lang2nix-approaches/14477)). – toraritte Oct 15 '21 at 10:56
  • There's nothing inherently superior about it; I feel like it's just the most fully developed integration. It's also subjective. For instance Go packaging also works really well, but is very different from Haskell or JS packaging. – Robert Hensing Oct 15 '21 at 19:09