niksos/hosts/common/desktop/xdg-ninja.nix

85 lines
3 KiB
Nix

{
config,
...
}: let
inherit (config.poz.other.system) username;
hmCfg = config.home-manager.users.${username};
# https://specifications.freedesktop.org/basedir-spec/latest/
XDG_CACHE_HOME = "$HOME/.cache";
XDG_CONFIG_HOME = "$HOME/.config";
XDG_DATA_HOME = "$HOME/.local/share";
XDG_STATE_HOME = "$HOME/.local/state";
in {
# most of the random ass env vars taken from `pkgs.xdg-ninja`
environment.sessionVariables = {
inherit
XDG_CACHE_HOME
XDG_CONFIG_HOME
XDG_DATA_HOME
XDG_STATE_HOME
;
ANDROID_HOME = "${XDG_DATA_HOME}/android";
CARGO_HOME = "${XDG_DATA_HOME}/cargo";
DOTNET_CLI_HOME = "${XDG_DATA_HOME}/dotnet";
GOPATH = "${XDG_DATA_HOME}/go";
GNUPGHOME = "${XDG_DATA_HOME}/gnupg";
GRADLE_USER_HOME = "${XDG_DATA_HOME}/gradle";
HISTFILE = "${XDG_STATE_HOME}/bash/history";
MYSQL_HISTFILE = "${XDG_STATE_HOME}/mysql/history";
NPM_CONFIG_USERCONFIG = "${XDG_CONFIG_HOME}/npm/npmrc";
NUGET_PACKAGES = "${XDG_CACHE_HOME}/NuGetPackages";
_JAVA_OPTIONS = "-Djava.util.prefs.userRoot=${XDG_CONFIG_HOME}/java";
PARALLEL_HOME = "${XDG_CONFIG_HOME}/parallel";
PYTHONSTARTUP = "${XDG_CONFIG_HOME}/python/pythonrc";
RUSTUP_HOME = "${XDG_DATA_HOME}/rustup";
WINEPREFIX = "${XDG_DATA_HOME}/wine";
XAUTHORITY = "\$XDG_RUNTIME_DIR/Xauthority";
};
poz.programs.zsh.extraAliases = {
gdb = "gdb -n -x ${XDG_CONFIG_HOME}/gdb/init";
pidgin = "pidgin --config=${XDG_DATA_HOME}/purple";
svn = "svn --config-dir ${XDG_CONFIG_HOME}/subversion";
wget = "wget --hsts-file=\"${XDG_DATA_HOME}/wget-hsts\"";
};
home-manager.users.${username} = {
xdg = {
configFile = {
"npm/npmrc".text = ''
prefix=${XDG_DATA_HOME}/npm
cache=${XDG_CACHE_HOME}/npm
tmp=\$XDG_RUNTIME_DIR/npm
init-module=${XDG_CONFIG_HOME}/npm/config/npm-init.js
'';
"python/pythonrc".text = ''
import os
import atexit
import readline
history = os.path.join(os.environ['XDG_CACHE_HOME'], 'python_history')
try:
readline.read_history_file(history)
except OSError:
pass
def write_history():
try:
readline.write_history_file(history)
except OSError:
pass
atexit.register(write_history)
'';
};
cacheHome = "${hmCfg.home.homeDirectory}/.cache";
configHome = "${hmCfg.home.homeDirectory}/.config";
dataHome = "${hmCfg.home.homeDirectory}/.local/share";
stateHome = "${hmCfg.home.homeDirectory}/.local/state";
};
};
}