Compare commits

..

No commits in common. "77eef949b6241448bed329e384aefa0a2d88860c" and "b5c39614c924942275f1cc6c9ea320875a8d9323" have entirely different histories.

5 changed files with 300 additions and 208 deletions

View file

@ -1,190 +1,83 @@
{ pkgs, config, lib, ... }: { pkgs, config, ... }:
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 home-manager.enable = true;
commonRc = lib.strings.concatLines ([ bash.enable = true; # Just in case the default shell is not ZSH, so we still have the variables
'' zsh = {
# Colored ls enable = true;
# TODO Doesn't allow completion enableAutosuggestions = true;
_colored_ls() { enableCompletion = true;
\ls -lh --color=always $@ | awk ' enableSyntaxHighlighting = true;
BEGIN { # syntaxHighlighting.enable = true; # 23.11 syntax
FPAT = "([[:space:]]*[^[:space:]]+)"; historySubstringSearch.enable = true;
OFS = ""; initExtra = builtins.readFile ./zshrc.sh;
} defaultKeymap = "viins";
{ history = {
$1 = "\033[36m" $1 "\033[0m"; size = 100000;
$2 = "\033[31m" $2 "\033[0m"; save = 100000;
$3 = "\033[32m" $3 "\033[0m"; expireDuplicatesFirst = true;
$4 = "\033[32m" $4 "\033[0m";
$5 = "\033[31m" $5 "\033[0m";
$6 = "\033[34m" $6 "\033[0m";
$7 = "\033[34m" $7 "\033[0m";
print
}
'
}
alias ll="_colored_ls"
alias la="_colored_ls -a"
''
] ++ map (d: "mkdir -p ${d}") (builtins.attrValues direnv));
commonSessionVariables = {
TIME_STYLE = "+%Y-%m-%d %H:%M:%S";
# Less colors
LESS = "-R";
LESS_TERMCAP_mb = "$'\E[1;31m'"; # begin blink
LESS_TERMCAP_md = "$'\E[1;36m'"; # begin bold
LESS_TERMCAP_me = "$'\E[0m'"; # reset bold/blink
LESS_TERMCAP_so = "$'\E[01;44;33m'"; # begin reverse video
LESS_TERMCAP_se = "$'\E[0m'"; # reset reverse video
LESS_TERMCAP_us = "$'\E[1;32m'"; # begin underline
LESS_TERMCAP_ue = "$'\E[0m'"; # reset underline
# Fzf
FZF_COMPLETION_OPTS = "${lib.strings.concatStringsSep " " config.programs.fzf.fileWidgetOptions}";
}; };
commonShellAliases = {
cp = "cp -i --reflink=auto";
grep = "grep --color=auto";
dd = "dd status=progress";
rm = "rm -v --one-file-system";
free = "free -m";
diff = "diff --color=auto";
dmesg = "dmesg --ctime";
wget = "wget --hsts-file ${config.xdg.cacheHome}/wget-hsts";
};
historySize = 100000;
historyFile = "${config.xdg.cacheHome}/shell_history";
in
{
home-manager.enable = true;
bash = {
enable = true;
bashrcExtra = lib.strings.concatLines [
commonRc
''
shopt -s expand_aliases
shopt -s histappend
''
];
sessionVariables = commonSessionVariables;
historySize = historySize;
historyFile = historyFile;
historyFileSize = historySize;
historyControl = [ "erasedups" "ignoredups" "ignorespace" ];
shellAliases = commonShellAliases;
};
zsh = {
enable = true;
enableAutosuggestions = true;
enableCompletion = true;
enableSyntaxHighlighting = true;
# syntaxHighlighting.enable = true; # 23.11 syntax
historySubstringSearch.enable = true;
initExtra = lib.strings.concatLines [
commonRc
(builtins.readFile ./zshrc.sh)
];
defaultKeymap = "viins";
history = {
size = historySize;
save = historySize;
path = historyFile;
expireDuplicatesFirst = true;
};
sessionVariables = commonSessionVariables;
shellAliases = commonShellAliases;
};
dircolors = {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
# UPST This thing put stuff in .dircolors when it actually doesn't have to
};
powerline-go = {
enable = true;
modules = [ "user" "host" "venv" "cwd" "perms" "git" ];
modulesRight = [ "jobs" "exit" "duration" "load" ];
settings = {
colorize-hostname = true;
max-width = 25;
cwd-max-dir-size = 10;
duration = "$( test -n \"$__TIMER\" && echo $(( $EPOCHREALTIME - $\{__TIMER:-EPOCHREALTIME})) || echo 0 )";
# UPST Implement this properly in home-manager, would allow for bash support
};
extraUpdatePS1 = ''unset __TIMER'';
};
# neovim = {
# enable = true;
# defaultEditor = true;
# vimAlias = true;
# viAlias = true;
# vimdiffAlias = true;
# };
# FIXME Still want this despite using nixvim
gpg = {
enable = true;
homedir = "${config.xdg.stateHome}/gnupg";
settings = {
# Remove fluff
no-greeting = true;
no-emit-version = true;
no-comments = true;
# Output format that I prefer
keyid-format = "0xlong";
# Show fingerprints
with-fingerprint = true;
# Make sure to show if key is invalid
# (should be default on most platform,
# but just to be sure)
list-options = "show-uid-validity";
verify-options = "show-uid-validity";
# Stronger algorithm (https://wiki.archlinux.org/title/GnuPG#Different_algorithm)
personal-digest-preferences = "SHA512";
cert-digest-algo = "SHA512";
default-preference-list = "SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed";
personal-cipher-preferences = "TWOFISH CAMELLIA256 AES 3DES";
};
publicKeys = [{
source = builtins.fetchurl {
url = "https://keys.openpgp.org/vks/v1/by-fingerprint/4FBA930D314A03215E2CDB0A8312C8CAC1BAC289";
sha256 = "sha256:10y9xqcy1vyk2p8baay14p3vwdnlwynk0fvfbika65hz2z8yw2cm";
};
trust = "ultimate";
}];
};
fzf = {
enable = true;
enableZshIntegration = true;
defaultOptions = [ "--height 40%" "--layout=default" ];
fileWidgetOptions = [ "--preview '[[ -d {} ]] && ls -l --color=always {} || [[ \$(file --mime {}) =~ binary ]] && file --brief {} || (highlight -O ansi -l {} || coderay {} || rougify {} || cat {}) 2> /dev/null | head -500'" ];
};
# TODO highlight or bat
nix-index = {
enable = true;
enableZshIntegration = true;
};
less.enable = true;
}; };
powerline-go = {
enable = true;
modules = [ "user" "host" "venv" "cwd" "perms" "git" ];
modulesRight = [ "jobs" "exit" "duration" "load" ];
settings = {
colorize-hostname = true;
max-width = 25;
cwd-max-dir-size = 10;
duration = "$( test -n \"$__TIMER\" && echo $(( $EPOCHREALTIME - $\{__TIMER:-EPOCHREALTIME})) || echo 0 )";
# UPST Implement this properly in home-manager
};
extraUpdatePS1 = ''unset __TIMER'';
};
# neovim = {
# enable = true;
# defaultEditor = true;
# vimAlias = true;
# viAlias = true;
# vimdiffAlias = true;
# };
# FIXME Still want this despite using nixvim
gpg = {
enable = true;
homedir = "${config.xdg.stateHome}/gnupg";
settings = {
# Remove fluff
no-greeting = true;
no-emit-version = true;
no-comments = true;
# Output format that I prefer
keyid-format = "0xlong";
# Show fingerprints
with-fingerprint = true;
# Make sure to show if key is invalid
# (should be default on most platform,
# but just to be sure)
list-options = "show-uid-validity";
verify-options = "show-uid-validity";
# Stronger algorithm (https://wiki.archlinux.org/title/GnuPG#Different_algorithm)
personal-digest-preferences = "SHA512";
cert-digest-algo = "SHA512";
default-preference-list = "SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed";
personal-cipher-preferences = "TWOFISH CAMELLIA256 AES 3DES";
};
publicKeys = [{
source = builtins.fetchurl {
url = "https://keys.openpgp.org/vks/v1/by-fingerprint/4FBA930D314A03215E2CDB0A8312C8CAC1BAC289";
sha256 = "sha256:10y9xqcy1vyk2p8baay14p3vwdnlwynk0fvfbika65hz2z8yw2cm";
};
trust = "ultimate";
}];
};
fzf.enable = true;
# TODO highlight or bat
nix-index = {
enable = true;
enableZshIntegration = true;
};
};
home = { home = {
stateVersion = "23.05"; stateVersion = "23.05";
language = { language = {
@ -269,30 +162,5 @@ in
syncthing syncthing
]; ];
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"
];
}; };
} }

49
config/shell/bashrc Normal file
View file

@ -0,0 +1,49 @@
#!/usr/bin/env bash
#
# Bash aliases and customizations
#
# Shell options
shopt -s expand_aliases
shopt -s histappend
HISTCONTROL=ignoreboth:erasedups
# Prompt customization
if command -v powerline-go > /dev/null
then
INTERACTIVE_BASHPID_TIMER="${HOME}/.cache/bash_timer_$$"
PS0='$(echo $SECONDS > "$INTERACTIVE_BASHPID_TIMER")'
function _update_ps1() {
local __ERRCODE=$?
local __DURATION=0
if [ -e "$INTERACTIVE_BASHPID_TIMER" ]; then
local __END=$SECONDS
local __START=$(cat "$INTERACTIVE_BASHPID_TIMER")
__DURATION="$(($__END - ${__START:-__END}))"
\rm -f "$INTERACTIVE_BASHPID_TIMER"
fi
echo -en "\033]0; ${USER}@${HOSTNAME} $PWD\007"
# echo -en "… $\r"
eval "$(powerline-go -shell bash -eval -duration $__DURATION -error $__ERRCODE "${POWERLINE_GO_DEFAULT_OPTS[@]}")"
}
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
else
export PS1="\[\e]2;\u@\H \w\a\]\[\e[0;37m\][\[\e[0;${col}m\]\u\[\e[0;37m\]@\[\e[0;34m\]\h \[\e[0;36m\]\W\[\e[0;37m\]]\$\[\e[0m\] "
fi
# Completion
trysource /usr/share/bash-completion/bash_completion
# Fuzzy matching all the way
trysource /usr/share/fzf/completion.bash
trysource /usr/share/fzf/key-bindings.bash

16
config/shell/commonenv Normal file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env sh
#
# Bash / ZSH common environment variables and functions
#
export TIME_STYLE='+%Y-%m-%d %H:%M:%S'
export LESS=-R
export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;44;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline
eval $(dircolors --sh)

64
config/shell/commonrc Normal file
View file

@ -0,0 +1,64 @@
#!/usr/bin/env sh
#
# Bash / ZSH aliases and customizations
#
# Shell options
HISTSIZE=100000
HISTFILE="$HOME/.cache/shell_history"
## COMMAND CONFIGURATION
# Completion for existing commands
alias cp="cp -i --reflink=auto"
alias grep="grep --color=auto"
alias dd='dd status=progress'
alias rm='rm -v --one-file-system'
alias free='free -m'
alias diff='diff --color=auto'
alias dmesg='dmesg --ctime'
alias wget='wget --hsts-file $HOME/.cache/wget-hsts'
# [ -f ~/.local/bin/colorSchemeApplyFzf ] && . ~/.local/bin/colorSchemeApplyFzf # Only applies RGB colors...
FZF_DEFAULT_OPTS="--height 40% --layout=default"
FZF_CTRL_T_OPTS="--preview '[[ -d {} ]] && ls -l --color=always {} || [[ \$(file --mime {}) =~ binary ]] && file --brief {} || (highlight -O ansi -l {} || coderay {} || rougify {} || cat {}) 2> /dev/null | head -500'"
FZF_COMPLETION_OPTS="${FZF_CTRL_T_OPTS}"
# Colored ls
_colored_ls() {
\ls -lh --color=always $@ | awk '
BEGIN {
FPAT = "([[:space:]]*[^[:space:]]+)";
OFS = "";
}
{
$1 = "\033[36m" $1 "\033[0m";
$2 = "\033[31m" $2 "\033[0m";
$3 = "\033[32m" $3 "\033[0m";
$4 = "\033[32m" $4 "\033[0m";
$5 = "\033[31m" $5 "\033[0m";
$6 = "\033[34m" $6 "\033[0m";
$7 = "\033[34m" $7 "\033[0m";
print
}
'
}
alias ll="_colored_ls"
alias la="_colored_ls -a"
# To keep until https://github.com/openssh/openssh-portable/commit/f64f8c00d158acc1359b8a096835849b23aa2e86
# is merged
function _ssh {
if [ "${TERM}" = "alacritty" ]
then
TERM=xterm-256color ssh "$@"
else
ssh "$@"
fi
}
alias ssh='_ssh'
## FUNCTIONS

View file

@ -5,10 +5,105 @@
# #
# 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