Node.js: Difference between revisions
imported>Pta2002 Update yarn2nix's package name, now it's just yarn2nix. |
imported>Mightyiam Example nix shell for Node.js development |
||
Line 142: | Line 142: | ||
(Inspired by [https://discourse.nixos.org/t/how-to-make-nixos-so-easy-that-people-can-be-productive-up-front-without-having-to-first-learn-the-nix-language/5625 this discussion on discourse.nixos.org]) | (Inspired by [https://discourse.nixos.org/t/how-to-make-nixos-so-easy-that-people-can-be-productive-up-front-without-having-to-first-learn-the-nix-language/5625 this discussion on discourse.nixos.org]) | ||
== Example nix shell for Node.js development == | |||
`shell.nix` example: | |||
<syntaxhighlight lang="nix> | |||
{ pkgs ? import <nixpkgs> {} }: | |||
let | |||
lib = import <nixpkgs/lib>; | |||
buildNodeJs = pkgs.callPackage <nixpkgs/pkgs/development/web/nodejs/nodejs.nix> {}; | |||
nodejsVersion = lib.fileContents ./.nvmrc; | |||
nodejs = buildNodeJs { | |||
enableNpm = false; | |||
version = nodejsVersion; | |||
sha256 = "1a0zj505nhpfcj19qvjy2hvc5a7gadykv51y0rc6032qhzzsgca2"; | |||
}; | |||
NPM_CONFIG_PREFIX = toString ./npm_config_prefix; | |||
in pkgs.mkShell { | |||
packages = with pkgs; [ | |||
nodejs | |||
nodePackages.npm | |||
]; | |||
inherit NPM_CONFIG_PREFIX; | |||
shellHook = '' | |||
export PATH="${NPM_CONFIG_PREFIX}/bin:$PATH" | |||
''; | |||
} | |||
</syntaxhighlight> | |||
== External Links == | == External Links == |