treewide: override several programs to conform to xdg dir spec

This commit is contained in:
Oystein Kristoffer Tveit 2024-06-08 12:37:01 +02:00
parent dc17c4e8ce
commit 8dc56e4aa7
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
5 changed files with 104 additions and 20 deletions

View File

@ -1,6 +1,9 @@
{ config, ... }:
{
imports = [ ./mimetypes.nix ];
imports = [
./mimetypes.nix
./directory-spec-overrides.nix
];
xdg = {
enable = true;
userDirs = {

View File

@ -0,0 +1,63 @@
{ config, pkgs, lib, ... }:
{
nix.settings.use-xdg-base-directories = true;
home.sessionVariables = let
inherit (config.xdg) dataHome cacheHome configHome userDirs;
in {
TEXMFHOME = "${dataHome}/texmf";
TEXMFVAR = "${cacheHome}/texlive";
TEXMFCONFIG = "${configHome}/texlive";
PSQL_HISTORY = "${dataHome}/psql_history";
SQLITE_HISTORY= "${dataHome}/sqlite_history";
MYSQL_HISTFILE = "${dataHome}/mysql_history";
NODE_REPL_HISTORY = "${dataHome}/node_repl_history";
GDB_HISTFILE = "${dataHome}/gdb_history";
PYTHON_HISTORY = "${dataHome}/python_history";
GHCUP_USE_XDG_DIRS = "true";
ANDROID_USER_HOME = "${dataHome}/android";
AZURE_CONFIG_DIR = "${dataHome}/azure";
CARGO_HOME = "${dataHome}/cargo";
CUDA_CACHE_PATH = "${cacheHome}/nv";
DOCKER_CONFIG = "${configHome}/docker";
DOTNET_CLI_HOME = "${dataHome}/dotnet";
DOT_SAGE = "${configHome}/sagemath";
ELM_HOME = "${configHome}/";
GOPATH = "${dataHome}/go";
GRADLE_USER_HOME = "${dataHome}/gradle";
ICEAUTHORITY = "${cacheHome}/ICEauthority";
NIMBLE_DIR = "${dataHome}/nimble";
NLTK_DATA = "${dataHome}/nltk_data";
NRFUTIL_HOME = "${dataHome}/nrfutil";
NUGET_PACKAGES = "${cacheHome}/nuget-packages";
PARALLEL_HOME = "${configHome}/parallel";
PYENV_ROOT = "${dataHome}/pyenv";
RUSTUP_HOME = "${dataHome}/rustup";
STACK_ROOT = "${dataHome}/stack";
W3M_DIR = "${dataHome}/w3m";
WINEPREFIX = "${dataHome}/wine";
# TODO: these needs to be set before the user session has fully initialized
# XINITRC = "$XDG_CONFIG_HOME/x11/initrc";
# XAUTHORITY
# ERRFILE = "${cacheHome}/X11/xsession-errors";
# USERXSESSION
# XCOMPOSECACHE="${cacheHome}/X11/xcompose";
# XCURSOR_PATH
};
xdg.configFile = {
"npm/npmrc".text = ''
prefix=${config.xdg.dataHome}/npm
cache=${config.xdg.cacheHome}/npm
init-module=${config.xdg.configHome}/npm/config/npm-init.js
'';
"bpython/config".text = ''
[general]
hist_file = ${config.xdg.dataHome}/bpython_history
'';
};
}

View File

@ -48,29 +48,18 @@ in {
./services/copyq.nix
];
nix.settings = {
use-xdg-base-directories = true;
};
home = {
stateVersion = "22.05";
username = "h7x4";
homeDirectory = "/home/h7x4";
file = {
".ghci".text = ''
:set prompt "${extendedLib.termColors.front.magenta "[GHCi]λ"} ".
'';
".pyrc".text = ''
#!/usr/bin/env python3
import sys
# You also need \x01 and \x02 to separate escape sequence, due to:
# https://stackoverflow.com/a/9468954/1147688
sys.ps1='\x01\x1b${extendedLib.termColors.front.blue "[Python]> "}\x02>>>\x01\x1b[0m\x02 ' # bright yellow
sys.ps2='\x01\x1b[1;49;31m\x02...\x01\x1b[0m\x02 ' # bright red
'';
};
sessionVariables = {
TEXMFHOME = "$HOME/documents/texmf";
};
sessionPath = [
"$HOME/.local/bin"
];
pointerCursor = mkIf graphics {
package = pkgs.capitaine-cursors;
@ -79,6 +68,26 @@ in {
};
keyboard.options = [ "caps:escape" ];
sessionVariables = {
PYTHONSTARTUP = "${config.xdg.configHome}/python/pyrc";
};
};
xdg.configFile = {
"ghc/ghci.conf".text = ''
:set prompt "${extendedLib.termColors.front.magenta "[GHCi]λ"} "
'';
"python/pyrc".text = ''
#!/usr/bin/env python3
import sys
# You also need \x01 and \x02 to separate escape sequence, due to:
# https://stackoverflow.com/a/9468954/1147688
sys.ps1='\x01\x1b${extendedLib.termColors.front.blue "[Python]> "}\x02>>>\x01\x1b[0m\x02 ' # bright yellow
sys.ps2='\x01\x1b[1;49;31m\x02...\x01\x1b[0m\x02 ' # bright red
'';
};
news.display = "silent";
@ -88,6 +97,12 @@ in {
programs = {
home-manager.enable = true;
bash = {
enable = true;
historyFile = "${config.xdg.dataHome}/bash_history";
historySize = 100000;
};
bat.enable = true;
bottom.enable = true;
eza.enable = true;

View File

@ -13,7 +13,9 @@
'';
# TODO: Regenerate zcompdump with a systemd timer
completionInit = "autoload -Uz compinit && compinit -C";
completionInit = ''
autoload -Uz compinit && compinit -C -d "${config.xdg.cacheHome}/zsh/zcompdump-$ZSH_VERSION"
'';
history = {
extended = true;

View File

@ -25,6 +25,7 @@ in {
experimental-features = [ "nix-command" "flakes" "repl-flake" ];
log-lines = 50;
trusted-users = [ "h7x4" "nix-builder" ];
use-xdg-base-directories = true;
};
buildMachines = [