Modularize dev/node.nix

This commit is contained in:
Henrik Lissner 2020-04-06 23:27:35 -04:00
parent b7b7821ce8
commit d9a56ceb87
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 28 additions and 20 deletions

View file

@ -10,7 +10,7 @@
# ./haskell.nix # ./haskell.nix
# ./latex.nix # ./latex.nix
./lua.nix ./lua.nix
# ./node.nix ./node.nix
./python.nix ./python.nix
./rust.nix ./rust.nix
./scala.nix ./scala.nix

View file

@ -3,29 +3,37 @@
# JS is one of those "when it's good, it's alright, when it's bad, it's a # JS is one of those "when it's good, it's alright, when it's bad, it's a
# disaster" languages. # disaster" languages.
{ pkgs, ... }: { config, options, lib, pkgs, ... }:
with lib;
{ {
imports = [ ./. ]; options.modules.dev.node = {
enable = mkOption {
type = types.bool;
default = false;
};
};
my = { config = mkIf config.modules.dev.node.enable {
packages = with pkgs; [ my = {
nodejs packages = with pkgs; [
]; nodejs
];
env.NPM_CONFIG_USERCONFIG = "$XDG_CONFIG_HOME/npm/config"; env.NPM_CONFIG_USERCONFIG = "$XDG_CONFIG_HOME/npm/config";
env.NPM_CONFIG_CACHE = "$XDG_CACHE_HOME/npm"; env.NPM_CONFIG_CACHE = "$XDG_CACHE_HOME/npm";
env.NPM_CONFIG_TMP = "$XDG_RUNTIME_DIR/npm"; env.NPM_CONFIG_TMP = "$XDG_RUNTIME_DIR/npm";
env.NPM_CONFIG_PREFIX = "$XDG_CACHE_HOME/npm"; env.NPM_CONFIG_PREFIX = "$XDG_CACHE_HOME/npm";
env.NODE_REPL_HISTORY = "$XDG_CACHE_HOME/node/repl_history"; env.NODE_REPL_HISTORY = "$XDG_CACHE_HOME/node/repl_history";
env.PATH = [ "$(yarn global bin)" ]; env.PATH = [ "$(yarn global bin)" ];
# Run locally installed bin-script, e.g. n coffee file.coffee # Run locally installed bin-script, e.g. n coffee file.coffee
alias.n = "PATH=\"$(npm bin):$PATH\""; alias.n = "PATH=\"$(npm bin):$PATH\"";
alias.ya = "yarn"; alias.ya = "yarn";
home.xdg.configFile."npm/config".text = '' home.xdg.configFile."npm/config".text = ''
cache=$XDG_CACHE_HOME/npm cache=$XDG_CACHE_HOME/npm
prefix=$XDG_DATA_HOME/npm prefix=$XDG_DATA_HOME/npm
''; '';
};
}; };
} }