91 lines
2.7 KiB
Nix
91 lines
2.7 KiB
Nix
{ lib, pkgs, config, ...}: let
|
|
inherit (lib) mkIf mkEnableOption mkOption;
|
|
cfg = config.chuj.xdg;
|
|
user = config.chuj.system.user;
|
|
in {
|
|
options.chuj.xdg = {
|
|
enable = mkEnableOption "xdg";
|
|
};
|
|
|
|
config = let
|
|
hmCfg = config.home-manager.users.${user};
|
|
HOME = hmCfg.home.homeDirectory;
|
|
in mkIf cfg.enable {
|
|
xdg.portal = {
|
|
enable = true;
|
|
xdgOpenUsePortal = true;
|
|
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
|
|
config.common.default = [ "*" ];
|
|
};
|
|
|
|
home-manager.users.${user} = {
|
|
xdg = {
|
|
dataHome = "${HOME}/.local/share";
|
|
configHome = "${HOME}/.config";
|
|
stateHome = "${HOME}/.local/state";
|
|
cacheHome = "${HOME}/.cache";
|
|
|
|
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.sessionVariables = let
|
|
XDG_DATA_HOME = hmCfg.xdg.dataHome;
|
|
XDG_CONFIG_HOME = hmCfg.xdg.configHome;
|
|
XDG_STATE_HOME = hmCfg.xdg.stateHome;
|
|
XDG_CACHE_HOME = hmCfg.xdg.cacheHome;
|
|
in {
|
|
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";
|
|
};
|
|
|
|
home.packages = with pkgs; [
|
|
xdg-user-dirs
|
|
xdg-utils
|
|
];
|
|
|
|
xdg.configFile = {
|
|
"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)
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|