helm/modules/dev/node.nix

41 lines
1.1 KiB
Nix
Raw Normal View History

# modules/dev/node.nix --- https://nodejs.org/en/
#
# JS is one of those "when it's good, it's alright, when it's bad, it's a
# disaster" languages.
2019-08-06 10:56:54 -07:00
2020-04-06 20:27:35 -07:00
{ config, options, lib, pkgs, ... }:
with lib;
2019-08-06 10:56:54 -07:00
{
2020-04-06 20:27:35 -07:00
options.modules.dev.node = {
enable = mkOption {
type = types.bool;
default = false;
};
};
2019-08-06 10:56:54 -07:00
2020-04-06 20:27:35 -07:00
config = mkIf config.modules.dev.node.enable {
my = {
packages = with pkgs; [
nodejs
2020-06-06 00:21:49 -07:00
yarn
2020-04-06 20:27:35 -07:00
];
2020-04-06 20:27:35 -07:00
env.NPM_CONFIG_USERCONFIG = "$XDG_CONFIG_HOME/npm/config";
env.NPM_CONFIG_CACHE = "$XDG_CACHE_HOME/npm";
env.NPM_CONFIG_TMP = "$XDG_RUNTIME_DIR/npm";
env.NPM_CONFIG_PREFIX = "$XDG_CACHE_HOME/npm";
env.NODE_REPL_HISTORY = "$XDG_CACHE_HOME/node/repl_history";
env.PATH = [ "$(yarn global bin)" ];
2020-04-06 20:27:35 -07:00
# Run locally installed bin-script, e.g. n coffee file.coffee
alias.n = "PATH=\"$(npm bin):$PATH\"";
alias.ya = "yarn";
2020-01-14 03:56:02 -08:00
2020-04-06 20:27:35 -07:00
home.xdg.configFile."npm/config".text = ''
cache=$XDG_CACHE_HOME/npm
prefix=$XDG_DATA_HOME/npm
'';
};
2019-08-06 10:56:54 -07:00
};
}