nix: Add most of shenv
This commit is contained in:
parent
ab4e33a825
commit
77eef949b6
|
@ -1,32 +1,53 @@
|
||||||
{ pkgs, config, lib, ... }:
|
{ pkgs, config, lib, ... }:
|
||||||
|
let
|
||||||
|
direnv = {
|
||||||
|
# Environment variables making programs stay out of $HOME, but also needing we create a directory for them
|
||||||
|
CARGOHOME = "${config.xdg.cacheHome}/cargo"; # There are config in there that we can version if one want
|
||||||
|
CCACHE_DIR = "${config.xdg.cacheHome}/ccache"; # The config file alone seems to be not enough
|
||||||
|
DASHT_DOCSETS_DIR = "${config.xdg.cacheHome}/dash_docsets";
|
||||||
|
GOPATH = "${config.xdg.cacheHome}/go";
|
||||||
|
GRADLE_USER_HOME = "${config.xdg.cacheHome}/gradle";
|
||||||
|
MIX_ARCHIVES = "${config.xdg.cacheHome}/mix/archives";
|
||||||
|
MONO_GAC_PREFIX = "${config.xdg.cacheHome}/mono";
|
||||||
|
npm_config_cache = "${config.xdg.cacheHome}/npm";
|
||||||
|
PARALLEL_HOME = "${config.xdg.cacheHome}/parallel";
|
||||||
|
TERMINFO = "${config.xdg.configHome}/terminfo";
|
||||||
|
WINEPREFIX = "${config.xdg.stateHome}/wineprefix/default";
|
||||||
|
YARN_CACHE_FOLDER = "${config.xdg.cacheHome}/yarn";
|
||||||
|
# TODO Some of that stuff is not really relavant any more
|
||||||
|
};
|
||||||
|
dotfilesPath = "$HOME/.dotfiles"; # FIXME I think we want it in ~/.config/dotfiles, also, should be an option
|
||||||
|
in
|
||||||
{
|
{
|
||||||
|
|
||||||
programs =
|
programs =
|
||||||
let
|
let
|
||||||
commonRc = ''
|
commonRc = lib.strings.concatLines ([
|
||||||
# Colored ls
|
''
|
||||||
# TODO Doesn't allow completion
|
# Colored ls
|
||||||
_colored_ls() {
|
# TODO Doesn't allow completion
|
||||||
\ls -lh --color=always $@ | awk '
|
_colored_ls() {
|
||||||
BEGIN {
|
\ls -lh --color=always $@ | awk '
|
||||||
FPAT = "([[:space:]]*[^[:space:]]+)";
|
BEGIN {
|
||||||
OFS = "";
|
FPAT = "([[:space:]]*[^[:space:]]+)";
|
||||||
}
|
OFS = "";
|
||||||
{
|
}
|
||||||
$1 = "\033[36m" $1 "\033[0m";
|
{
|
||||||
$2 = "\033[31m" $2 "\033[0m";
|
$1 = "\033[36m" $1 "\033[0m";
|
||||||
$3 = "\033[32m" $3 "\033[0m";
|
$2 = "\033[31m" $2 "\033[0m";
|
||||||
$4 = "\033[32m" $4 "\033[0m";
|
$3 = "\033[32m" $3 "\033[0m";
|
||||||
$5 = "\033[31m" $5 "\033[0m";
|
$4 = "\033[32m" $4 "\033[0m";
|
||||||
$6 = "\033[34m" $6 "\033[0m";
|
$5 = "\033[31m" $5 "\033[0m";
|
||||||
$7 = "\033[34m" $7 "\033[0m";
|
$6 = "\033[34m" $6 "\033[0m";
|
||||||
print
|
$7 = "\033[34m" $7 "\033[0m";
|
||||||
}
|
print
|
||||||
'
|
}
|
||||||
}
|
'
|
||||||
alias ll="_colored_ls"
|
}
|
||||||
alias la="_colored_ls -a"
|
alias ll="_colored_ls"
|
||||||
'';
|
alias la="_colored_ls -a"
|
||||||
|
''
|
||||||
|
] ++ map (d: "mkdir -p ${d}") (builtins.attrValues direnv));
|
||||||
commonSessionVariables = {
|
commonSessionVariables = {
|
||||||
TIME_STYLE = "+%Y-%m-%d %H:%M:%S";
|
TIME_STYLE = "+%Y-%m-%d %H:%M:%S";
|
||||||
# Less colors
|
# Less colors
|
||||||
|
@ -248,6 +269,30 @@
|
||||||
syncthing
|
syncthing
|
||||||
|
|
||||||
];
|
];
|
||||||
sessionVariables = { };
|
sessionVariables = {
|
||||||
|
# Favourite commands
|
||||||
|
PAGER = "${pkgs.coreutils}/bin/less";
|
||||||
|
EDITOR = "${pkgs.neovim}/bin/nvim";
|
||||||
|
VISUAL = "${pkgs.neovim}/bin/nvim";
|
||||||
|
BROWSER = "${config.programs.qutebrowser.package}/bin/qutebrowser";
|
||||||
|
} // direnv // {
|
||||||
|
BOOT9_PATH = "${config.xdg.dataHome}/citra-emu/sysdata/boot9.bin";
|
||||||
|
CCACHE_CONFIGPATH = "${config.xdg.configHome}/ccache.conf";
|
||||||
|
INPUTRC = "${config.xdg.configHome}/inputrc";
|
||||||
|
LESSHISTFILE = "${config.xdg.stateHome}/lesshst";
|
||||||
|
NODE_REPL_HISTORY = "${config.xdg.cacheHome}/node_repl_history";
|
||||||
|
PYTHONSTARTUP = "${config.xdg.configHome}/pythonstartup.py";
|
||||||
|
RXVT_SOCKET = "${config.xdg.stateHome}/urxvtd"; # Used to want -$HOME suffix, hopefullt this isn't needed
|
||||||
|
SCREENRC = "${config.xdg.configHome}/screenrc";
|
||||||
|
SQLITE_HISTFILE = "${config.xdg.stateHome}/sqlite_history";
|
||||||
|
YARN_DISABLE_SELF_UPDATE_CHECK = "true"; # This also disable the creation of a ~/.yarnrc file
|
||||||
|
# XAUTHORITY = "${config.xdg.configHome}/Xauthority"; # Disabled as this causes lock-ups with DMs
|
||||||
|
};
|
||||||
|
# TODO Session variables only get reloaded on login I think.
|
||||||
|
sessionPath = [
|
||||||
|
"$HOME/.local/bin"
|
||||||
|
"${config.home.sessionVariables.GOPATH}"
|
||||||
|
"${dotfilesPath}/config/scripts"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,105 +5,10 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
# Favourite commands
|
# Favourite commands
|
||||||
export PAGER=less
|
|
||||||
export EDITOR=nvim
|
|
||||||
export VISUAL=nvim
|
|
||||||
export BROWSER=qutebrowser
|
|
||||||
|
|
||||||
direnv() { # environment variable name, path
|
|
||||||
export "$1"="$2"
|
|
||||||
mkdir -p "$2"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Program-specific
|
|
||||||
|
|
||||||
export JAVA_FONTS=/usr/share/fonts/TTF # 2019-04-25 Attempt to remove .java/fonts remove if it didn't work
|
|
||||||
# export ANDROID_HOME=/opt/android-sdk
|
|
||||||
# export ARDUINO=/usr/share/arduino
|
|
||||||
# export ARDUINO_DIR=$ARDUINO
|
|
||||||
# export ARDMK_VENDOR=archlinux-arduino
|
|
||||||
|
|
||||||
# Get out of my $HOME!
|
|
||||||
export BOOT9_PATH="$HOME/.local/share/citra-emu/sysdata/boot9.bin"
|
|
||||||
direnv CARGOHOME "$HOME/.cache/cargo" # There are config in there that we can version if one want
|
|
||||||
export CCACHE_CONFIGPATH="$HOME/.config/ccache.conf"
|
|
||||||
direnv CCACHE_DIR "$HOME/.cache/ccache" # The config file alone seems to be not enough
|
|
||||||
direnv DASHT_DOCSETS_DIR "$HOME/.cache/dash_docsets"
|
|
||||||
direnv GOPATH "$HOME/.cache/go"
|
|
||||||
direnv GRADLE_USER_HOME "$HOME/.cache/gradle"
|
|
||||||
export INPUTRC="$HOME/.config/inputrc"
|
|
||||||
export LESSHISTFILE="$HOME/.cache/lesshst"
|
|
||||||
direnv MIX_ARCHIVES "$HOME/.cache/mix/archives"
|
|
||||||
direnv MONO_GAC_PREFIX "$HOME/.cache/mono"
|
|
||||||
export NODE_REPL_HISTORY="$HOME/.cache/node_repl_history"
|
|
||||||
direnv npm_config_cache "$HOME/.cache/npm"
|
|
||||||
direnv PARALLEL_HOME "$HOME/.cache/parallel"
|
|
||||||
export PYTHONSTARTUP="$HOME/.config/pythonstartup.py"
|
|
||||||
export SCREENRC="$HOME/.config/screenrc"
|
|
||||||
export SQLITE_HISTFILE="$HOME/.cache/sqlite_history"
|
|
||||||
direnv TERMINFO "$HOME/.config/terminfo"
|
|
||||||
export RXVT_SOCKET="$HOME/.cache/urxvtd-$HOST"
|
|
||||||
export VIMINIT="source $HOME/.config/vim/loader.vim"
|
|
||||||
direnv WINEPREFIX "$HOME/.cache/wineprefix/default"
|
|
||||||
direnv YARN_CACHE_FOLDER "$HOME/.cache/yarn"
|
|
||||||
export YARN_DISABLE_SELF_UPDATE_CHECK=true # This also disable the creation of a ~/.yarnrc file
|
|
||||||
# Disabled since this causes lockups with DMs
|
|
||||||
# export XAUTHORITY="$HOME/.config/Xauthority"
|
|
||||||
|
|
||||||
# And for the rest, see aliases
|
# And for the rest, see aliases
|
||||||
direnv JUNKHOME "$HOME/.cache/junkhome"
|
direnv JUNKHOME "$HOME/.cache/junkhome"
|
||||||
|
|
||||||
# For software that did not understand that XDG variables have defaults
|
|
||||||
direnv XDG_DATA_HOME "$HOME/.local/share"
|
|
||||||
direnv XDG_CONFIG_HOME "$HOME/.config"
|
|
||||||
export XDG_DATA_DIRS="/usr/local/share/:/usr/share/"
|
|
||||||
export XDG_CONFIG_DIRS="/etc/xdg"
|
|
||||||
direnv XDG_CACHE_HOME "$HOME/.cache"
|
|
||||||
# Please don't set XDG_RUNTIME_DIR as it
|
|
||||||
# screw with user daemons such as PulseAudio
|
|
||||||
|
|
||||||
# Path
|
|
||||||
|
|
||||||
# Function stolen from Arch Linux /etc/profile
|
|
||||||
appendpath() {
|
|
||||||
if [ ! -d "$1" ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
case ":$PATH:" in
|
|
||||||
*:"$1":*) ;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
export PATH="${PATH:+$PATH:}$1"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
prependpath() {
|
|
||||||
if [ ! -d "$1" ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
case ":$PATH:" in
|
|
||||||
*:"$1":*) ;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
export PATH="$1${PATH:+:$PATH}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
prependpath '/usr/lib/ccache/bin'
|
|
||||||
prependpath "${GOPATH}/bin"
|
|
||||||
prependpath "$HOME/.local/bin"
|
|
||||||
prependpath "$HOME/.config/scripts"
|
|
||||||
|
|
||||||
# If running on termux, load those extra scripts
|
|
||||||
[ -d /data/data/com.termux/ ] && (
|
|
||||||
prependpath "$HOME/.termux/scripts"
|
|
||||||
prependpath "$HOME/.termux/bin"
|
|
||||||
)
|
|
||||||
|
|
||||||
# For superseding commands with better ones if they are present
|
|
||||||
|
|
||||||
# SSH Agent
|
# SSH Agent
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue