From d9a56ceb8787a9f53613e92fdd1fa1426ee61ce4 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 6 Apr 2020 23:27:35 -0400 Subject: [PATCH] Modularize dev/node.nix --- modules/dev/default.nix | 2 +- modules/dev/node.nix | 46 ++++++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/modules/dev/default.nix b/modules/dev/default.nix index 26d32437..87575daf 100644 --- a/modules/dev/default.nix +++ b/modules/dev/default.nix @@ -10,7 +10,7 @@ # ./haskell.nix # ./latex.nix ./lua.nix - # ./node.nix + ./node.nix ./python.nix ./rust.nix ./scala.nix diff --git a/modules/dev/node.nix b/modules/dev/node.nix index 6bfb7faa..8af3c73c 100644 --- a/modules/dev/node.nix +++ b/modules/dev/node.nix @@ -3,29 +3,37 @@ # JS is one of those "when it's good, it's alright, when it's bad, it's a # disaster" languages. -{ pkgs, ... }: +{ config, options, lib, pkgs, ... }: +with lib; { - imports = [ ./. ]; + options.modules.dev.node = { + enable = mkOption { + type = types.bool; + default = false; + }; + }; - my = { - packages = with pkgs; [ - nodejs - ]; + config = mkIf config.modules.dev.node.enable { + my = { + packages = with pkgs; [ + nodejs + ]; - 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)" ]; + 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)" ]; - # Run locally installed bin-script, e.g. n coffee file.coffee - alias.n = "PATH=\"$(npm bin):$PATH\""; - alias.ya = "yarn"; + # Run locally installed bin-script, e.g. n coffee file.coffee + alias.n = "PATH=\"$(npm bin):$PATH\""; + alias.ya = "yarn"; - home.xdg.configFile."npm/config".text = '' - cache=$XDG_CACHE_HOME/npm - prefix=$XDG_DATA_HOME/npm - ''; + home.xdg.configFile."npm/config".text = '' + cache=$XDG_CACHE_HOME/npm + prefix=$XDG_DATA_HOME/npm + ''; + }; }; }