nix/misc/xdg.nix
2024-07-05 01:26:15 +02:00

75 lines
2.3 KiB
Nix

{ config, lib, pkgs, ... }:
let
HOME = config.home-manager.users.krizej.home.homeDirectory;
in {
home-manager.users.krizej = {
home.packages = with pkgs; [
xdg-user-dirs
xdg-desktop-portal
xdg-desktop-portal-gnome
];
home.sessionVariables = rec {
# xdg crap thx poz
XDG_DATA_HOME = "${HOME}/.local/share";
XDG_CONFIG_HOME = "${HOME}/.config";
XDG_STATE_HOME = "${HOME}/.local/state";
XDG_CACHE_HOME = "${HOME}/.cache";
ANDROID_USER_HOME = "${XDG_DATA_HOME}/android";
ANDROID_HOME = "${XDG_DATA_HOME}/android/sdk";
GRADLE_USER_HOME = "${XDG_DATA_HOME}/gradle";
PYTHONSTARTUP = "${XDG_CONFIG_HOME}/python/pythonrc";
HISTFILE = "${XDG_CACHE_HOME}/bash/history";
CARGO_HOME = "${XDG_DATA_HOME}/cargo";
_JAVA_OPTIONS = "-Djava.utils.prefs.userRoot=${XDG_CONFIG_HOME}/java";
GNUPGHOME = "${XDG_DATA_HOME}/gnupg";
WINEPREFIX = "${XDG_DATA_HOME}/wine";
RUSTUP_HOME = "${XDG_DATA_HOME}/rustup";
NUGET_PACKAGES = "${XDG_CACHE_HOME}/NuGetPackages";
FCEUX_HOME = "${XDG_CONFIG_HOME}/fceux";
DOTNET_CLI_HOME = "${XDG_CONFIG_HOME}/dotnet";
GTK2_RC_FILES = lib.mkForce "${XDG_CONFIG_HOME}/gtk-2.0/gtkrc";
};
xdg.userDirs = {
enable = true;
desktop = "${HOME}/desktop";
documents = "${HOME}/documents";
download = "${HOME}/downloads";
music = "${HOME}/music";
pictures = "${HOME}/pictures";
publicShare = "${HOME}/public";
templates = "${HOME}/templates";
videos = "${HOME}/videos";
};
home.file = {
".config/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 os
import atexit
import readline
from pathlib import Path
if state_home := os.environ.get('XDG_STATE_HOME'):
state_home = Path(state_home)
else:
state_home = Path.home() / '.local' / 'state'
history: Path = state_home / 'python_history'
readline.read_history_file(str(history))
atexit.register(readline.write_history_file, str(history))
if is_vanilla():
setup_history()
'';
};
};
}