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

View file

@ -12,35 +12,40 @@ let cfg = config.modules.dev.python;
in { in {
options.modules.dev.python = { options.modules.dev.python = {
enable = mkBoolOpt false; enable = mkBoolOpt false;
enableGlobally = mkBoolOpt false;
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable (mkMerge [
user.packages = with pkgs; [ (mkIf cfg.enableGlobally {
python37 user.packages = with pkgs; [
python37Packages.pip python37
python37Packages.ipython python37Packages.pip
python37Packages.black python37Packages.ipython
python37Packages.setuptools python37Packages.black
python37Packages.pylint python37Packages.setuptools
python37Packages.poetry python37Packages.pylint
]; python37Packages.poetry
];
env.IPYTHONDIR = "$XDG_CONFIG_HOME/ipython"; environment.shellAliases = {
env.PIP_CONFIG_FILE = "$XDG_CONFIG_HOME/pip/pip.conf"; py = "python";
env.PIP_LOG_FILE = "$XDG_DATA_HOME/pip/log"; py2 = "python2";
env.PYLINTHOME = "$XDG_DATA_HOME/pylint"; py3 = "python3";
env.PYLINTRC = "$XDG_CONFIG_HOME/pylint/pylintrc"; po = "poetry";
env.PYTHONSTARTUP = "$XDG_CONFIG_HOME/python/pythonrc"; ipy = "ipython --no-banner";
env.PYTHON_EGG_CACHE = "$XDG_CACHE_HOME/python-eggs"; ipylab = "ipython --pylab=qt5 --no-banner";
env.JUPYTER_CONFIG_DIR = "$XDG_CONFIG_HOME/jupyter"; };
})
environment.shellAliases = { {
py = "python"; env.IPYTHONDIR = "$XDG_CONFIG_HOME/ipython";
py2 = "python2"; env.PIP_CONFIG_FILE = "$XDG_CONFIG_HOME/pip/pip.conf";
py3 = "python3"; env.PIP_LOG_FILE = "$XDG_DATA_HOME/pip/log";
po = "poetry"; env.PYLINTHOME = "$XDG_DATA_HOME/pylint";
ipy = "ipython --no-banner"; env.PYLINTRC = "$XDG_CONFIG_HOME/pylint/pylintrc";
ipylab = "ipython --pylab=qt5 --no-banner"; 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,21 +15,26 @@ let cfg = config.modules.dev.rust;
in { in {
options.modules.dev.rust = { options.modules.dev.rust = {
enable = mkBoolOpt false; enable = mkBoolOpt false;
enableGlobally = mkBoolOpt false;
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable (mkMerge [
user.packages = with pkgs; [ (mkIf cfg.enableGlobally {
rustup user.packages = [ pkgs.rustup ];
];
env.RUSTUP_HOME = "$XDG_DATA_HOME/rustup"; env.PATH = [ "$(${pkgs.yarn}/bin/yarn global bin)" ];
env.CARGO_HOME = "$XDG_DATA_HOME/cargo"; })
env.PATH = [ "$CARGO_HOME/bin" ];
environment.shellAliases = { {
rs = "rustc"; env.RUSTUP_HOME = "$XDG_DATA_HOME/rustup";
rsp = "rustup"; env.CARGO_HOME = "$XDG_DATA_HOME/cargo";
ca = "cargo"; env.PATH = [ "$CARGO_HOME/bin" ];
};
}; environment.shellAliases = {
rs = "rustc";
rsp = "rustup";
ca = "cargo";
};
}
]);
} }