staging again
This commit is contained in:
parent
4cea0a966e
commit
ad06ac826e
3 changed files with 41 additions and 1 deletions
38
modules/npm.nix
Normal file
38
modules/npm.nix
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
npmConf = pkgs.writeText "npmrc" ''
|
||||
prefix=${config.environment.variables.NPM_CONFIG_PREFIX}
|
||||
cache=$HOME/.npm
|
||||
init-module=$HOME/.npm-init.js
|
||||
node-linker=hoisted
|
||||
'';
|
||||
in {
|
||||
options.npm = {
|
||||
enable = lib.mkEnableOption "System NPM Environment";
|
||||
};
|
||||
config = lib.mkIf config.npm.enable {
|
||||
environment.systemPackages = with pkgs; [
|
||||
nodejs
|
||||
nodePackages.npm
|
||||
];
|
||||
environment.variables = {
|
||||
NPM_CONFIG_PREFIX = "$HOME/.npm-global";
|
||||
PATH = ["$HOME/.npm-global/bin"];
|
||||
NPM_CONFIG_USERCONFIG = "${npmConf}";
|
||||
};
|
||||
system.userActivationScripts.setupNpm = ''
|
||||
mkdir -p $HOME/.npm-global/bin
|
||||
mkdir -p $HOME/.npm
|
||||
if [ ! -f "$HOME/.npmrc" ]; then
|
||||
cp ${npmConf} $HOME/.npmrc
|
||||
fi
|
||||
if [ -d "$HOME/.npm-global" ]; then
|
||||
chmod -R +rw $HOME/.npm-global
|
||||
fi
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue