1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.programs.npm;
7in
8
9{
10 ###### interface
11
12 options = {
13 programs.npm = {
14 enable = mkEnableOption "<command>npm</command> global config";
15
16 npmrc = lib.mkOption {
17 type = lib.types.lines;
18 description = ''
19 The system-wide npm configuration.
20 See <link xlink:href="https://docs.npmjs.com/misc/config"/>.
21 '';
22 default = ''
23 prefix = ''${HOME}/.npm
24 '';
25 example = ''
26 prefix = ''${HOME}/.npm
27 https-proxy=proxy.example.com
28 init-license=MIT
29 init-author-url=http://npmjs.org
30 color=true
31 '';
32 };
33 };
34 };
35
36 ###### implementation
37
38 config = lib.mkIf cfg.enable {
39 environment.etc."npmrc".text = cfg.npmrc;
40
41 environment.variables.NPM_CONFIG_GLOBALCONFIG = "/etc/npmrc";
42
43 environment.systemPackages = [ pkgs.nodePackages.npm ];
44 };
45
46}