diff --git a/home/config/xdg/default.nix b/home/config/xdg/default.nix index 8610aa6..d47ecd6 100644 --- a/home/config/xdg/default.nix +++ b/home/config/xdg/default.nix @@ -1,6 +1,9 @@ { config, ... }: { - imports = [ ./mimetypes.nix ]; + imports = [ + ./mimetypes.nix + ./directory-spec-overrides.nix + ]; xdg = { enable = true; userDirs = { diff --git a/home/config/xdg/directory-spec-overrides.nix b/home/config/xdg/directory-spec-overrides.nix new file mode 100644 index 0000000..27fd5db --- /dev/null +++ b/home/config/xdg/directory-spec-overrides.nix @@ -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 + ''; + }; +} diff --git a/home/home.nix b/home/home.nix index a8dfda5..d765f8d 100644 --- a/home/home.nix +++ b/home/home.nix @@ -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; diff --git a/home/programs/zsh/default.nix b/home/programs/zsh/default.nix index ccbf5a0..8ff0065 100644 --- a/home/programs/zsh/default.nix +++ b/home/programs/zsh/default.nix @@ -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; diff --git a/hosts/common.nix b/hosts/common.nix index 2b4790e..509ae48 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -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 = [