feat(dev): add enableGlobally opt

I only need the envvars set. All my development environments are in
shell.nix's and global installations are usually unneeded.
This commit is contained in:
Henrik Lissner 2021-08-06 01:30:07 -04:00
parent 233297ae71
commit 3afaee991c
3 changed files with 78 additions and 61 deletions

View file

@ -8,33 +8,40 @@
with lib;
with lib.my;
let cfg = config.modules.dev.node;
node = pkgs.nodejs_latest;
in {
options.modules.dev.node = {
enable = mkBoolOpt false;
enableGlobally = mkBoolOpt false;
};
config = mkIf cfg.enable {
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.enableGlobally {
user.packages = with pkgs; [
nodejs
node
yarn
];
# Run locally installed bin-script, e.g. n coffee file.coffee
environment.shellAliases = {
n = "PATH=\"$(${node}/bin/npm bin):$PATH\"";
ya = "yarn";
};
env.PATH = [ "$(${pkgs.yarn}/bin/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 = [ "$(${pkgs.yarn}/bin/yarn global bin)" ];
# Run locally installed bin-script, e.g. n coffee file.coffee
environment.shellAliases = {
n = "PATH=\"$(${pkgs.nodejs}/bin/npm bin):$PATH\"";
ya = "yarn";
};
home.configFile."npm/config".text = ''
cache=$XDG_CACHE_HOME/npm
prefix=$XDG_DATA_HOME/npm
'';
};
}
]);
}

View file

@ -12,9 +12,11 @@ let cfg = config.modules.dev.python;
in {
options.modules.dev.python = {
enable = mkBoolOpt false;
enableGlobally = mkBoolOpt false;
};
config = mkIf cfg.enable {
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.enableGlobally {
user.packages = with pkgs; [
python37
python37Packages.pip
@ -25,15 +27,6 @@ in {
python37Packages.poetry
];
env.IPYTHONDIR = "$XDG_CONFIG_HOME/ipython";
env.PIP_CONFIG_FILE = "$XDG_CONFIG_HOME/pip/pip.conf";
env.PIP_LOG_FILE = "$XDG_DATA_HOME/pip/log";
env.PYLINTHOME = "$XDG_DATA_HOME/pylint";
env.PYLINTRC = "$XDG_CONFIG_HOME/pylint/pylintrc";
env.PYTHONSTARTUP = "$XDG_CONFIG_HOME/python/pythonrc";
env.PYTHON_EGG_CACHE = "$XDG_CACHE_HOME/python-eggs";
env.JUPYTER_CONFIG_DIR = "$XDG_CONFIG_HOME/jupyter";
environment.shellAliases = {
py = "python";
py2 = "python2";
@ -42,5 +35,17 @@ in {
ipy = "ipython --no-banner";
ipylab = "ipython --pylab=qt5 --no-banner";
};
};
})
{
env.IPYTHONDIR = "$XDG_CONFIG_HOME/ipython";
env.PIP_CONFIG_FILE = "$XDG_CONFIG_HOME/pip/pip.conf";
env.PIP_LOG_FILE = "$XDG_DATA_HOME/pip/log";
env.PYLINTHOME = "$XDG_DATA_HOME/pylint";
env.PYLINTRC = "$XDG_CONFIG_HOME/pylint/pylintrc";
env.PYTHONSTARTUP = "$XDG_CONFIG_HOME/python/pythonrc";
env.PYTHON_EGG_CACHE = "$XDG_CACHE_HOME/python-eggs";
env.JUPYTER_CONFIG_DIR = "$XDG_CONFIG_HOME/jupyter";
}
]);
}

View file

@ -15,13 +15,17 @@ let cfg = config.modules.dev.rust;
in {
options.modules.dev.rust = {
enable = mkBoolOpt false;
enableGlobally = mkBoolOpt false;
};
config = mkIf cfg.enable {
user.packages = with pkgs; [
rustup
];
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.enableGlobally {
user.packages = [ pkgs.rustup ];
env.PATH = [ "$(${pkgs.yarn}/bin/yarn global bin)" ];
})
{
env.RUSTUP_HOME = "$XDG_DATA_HOME/rustup";
env.CARGO_HOME = "$XDG_DATA_HOME/cargo";
env.PATH = [ "$CARGO_HOME/bin" ];
@ -31,5 +35,6 @@ in {
rsp = "rustup";
ca = "cargo";
};
};
}
]);
}