nixos-config/home/use-xdg.nix

48 lines
1.5 KiB
Nix
Raw Normal View History

2024-03-02 03:13:17 +00:00
{ config, ... }:
{
home.sessionVariables = {
ANDROID_USER_HOME = "${config.xdg.dataHome}/android";
CARGO_HOME = "${config.xdg.dataHome}/cargo";
DOTNET_CLI_HOME = "${config.xdg.dataHome}/dotnet";
DVDCSS_CACHE = "${config.xdg.dataHome}/dvdcss";
GRADLE_USER_HOME = "${config.xdg.dataHome}/gradle";
IPYTHONDIR = "${config.xdg.configHome}/ipython";
JUPYTER_CONFIG_DIR = "${config.xdg.configHome}/jupyter";
LESSHISTFILE = "${config.xdg.stateHome}/less/history";
2024-02-10 05:50:24 +00:00
NPM_CONFIG_USERCONFIG = "${config.xdg.configHome}/npm/npmrc";
NUGET_PACKAGES = "${config.xdg.cacheHome}/nuget/packages";
PARALLEL_HOME = "${config.xdg.configHome}/parallel";
PLATFORMIO_CORE_DIR = "${config.xdg.dataHome}/platformio";
2024-02-10 05:50:24 +00:00
PYTHONSTARTUP = "${config.xdg.configHome}/python/pythonrc";
RUSTUP_HOME = "${config.xdg.dataHome}/rustup";
};
2024-02-10 05:50:24 +00:00
xdg.configFile = {
"npm/npmrc".text = ''
prefix=${config.xdg.dataHome}/npm
cache=${config.xdg.cacheHome}/npm
'';
"python/pythonrc".text = ''
def is_vanilla() -> bool:
import sys
return not hasattr(__builtins__, '__IPYTHON__') and 'bpython' not in sys.argv[0]
def setup_history():
import atexit
import readline
from pathlib import Path
state_home = Path("${config.xdg.stateHome}")
history = state_home / "python" / "history"
readline.read_history_file(str(history))
atexit.register(readline.write_history_file, str(history))
if is_vanilla():
setup_history()
'';
};
}