345 lines
12 KiB
Nix
345 lines
12 KiB
Nix
{ pkgs, config, lib, ... }:
|
|
{
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
nix = {
|
|
package = lib.mkDefault pkgs.nixFlakes;
|
|
settings = {
|
|
experimental-features = [ "nix-command" "flakes" ];
|
|
warn-dirty = false;
|
|
};
|
|
};
|
|
|
|
programs =
|
|
let
|
|
# TODO Those directory creations should probably done on home-manager activation
|
|
commonSessionVariables = {
|
|
TIME_STYLE = "+%Y-%m-%d %H:%M:%S";
|
|
# Less colors
|
|
LESS = "-R";
|
|
LESS_TERMCAP_mb = "$(echo $'\\E[1;31m')"; # begin blink
|
|
LESS_TERMCAP_md = "$(echo $'\\E[1;36m')"; # begin bold
|
|
LESS_TERMCAP_me = "$(echo $'\\E[0m')"; # reset bold/blink
|
|
LESS_TERMCAP_so = "$(echo $'\\E[01;44;33m')"; # begin reverse video
|
|
LESS_TERMCAP_se = "$(echo $'\\E[0m')"; # reset reverse video
|
|
LESS_TERMCAP_us = "$(echo $'\\E[1;32m')"; # begin underline
|
|
LESS_TERMCAP_ue = "$(echo $'\\E[0m')"; # reset underline
|
|
# Fzf
|
|
FZF_COMPLETION_OPTS = "${lib.strings.concatStringsSep " " config.programs.fzf.fileWidgetOptions}";
|
|
};
|
|
commonShellAliases = {
|
|
# Replacement commands
|
|
# ls = "lsd"; # lsd is suuuper slow for large directories
|
|
cat = "bat -pp";
|
|
|
|
# Completion for existing commands
|
|
mkdir = "mkdir -v";
|
|
# cp = "cp -i"; # Disabled because conflicts with the ZSH/Bash one. This separation is confusing I swear.
|
|
mv = "mv -iv";
|
|
free = "free -h";
|
|
df = "df -h";
|
|
ffmpeg = "ffmpeg -hide_banner";
|
|
ffprobe = "ffprobe -hide_banner";
|
|
ffplay = "ffplay -hide_banner";
|
|
numbat = "numbat --intro-banner off";
|
|
insect = "numbat";
|
|
|
|
# Frequent mistakes
|
|
sl = "ls";
|
|
al = "la";
|
|
mdkir = "mkdir";
|
|
systemclt = "systemctl";
|
|
please = "sudo";
|
|
|
|
# Shortcuts for commonly used commands
|
|
ll = "lsd -l";
|
|
la = "lsd -la";
|
|
s = "sudo -s -E";
|
|
|
|
|
|
# Give additional config to those programs, and not have them in my path
|
|
bower = "bower --config.storage.packages=${config.xdg.cacheHome}/bower/packages --config.storage.registry=${config.xdg.cacheHome}/bower/registry --config.storage.links=${config.xdg.cacheHome}/bower/links";
|
|
iftop = "iftop -c ${config.xdg.configHome}/iftoprc";
|
|
lmms = "lmms --config ${config.xdg.configHome}/lmmsrc.xml";
|
|
|
|
# Preference
|
|
vi = "nvim";
|
|
vim = "nvim";
|
|
wol = "wakeonlan"; # TODO Really, isn't wol better? Also wtf Arch aliases to pass because neither is installed anyways x)
|
|
mutt = "neomutt";
|
|
|
|
# Bash/Zsh only
|
|
cp = "cp -i --reflink=auto";
|
|
grep = "grep --color=auto";
|
|
dd = "dd status=progress";
|
|
rm = "rm -v --one-file-system";
|
|
# free = "free -m"; # Disabled because... no? Why?
|
|
diff = "diff --color=auto";
|
|
dmesg = "dmesg --ctime";
|
|
wget = "wget --hsts-file ${config.xdg.cacheHome}/wget-hsts";
|
|
|
|
# Imported from scripts
|
|
rms = ''${pkgs.findutils}/bin/find . -name "*.sync-conflict-*" -delete''; # Remove syncthing conflict files
|
|
pw = ''${pkgs.pwgen}/bin/pwgen 32 -y''; # Generate passwords. ln((26*2+10)**32)/ln(2) ≅ 190 bits of entropy
|
|
newestFile = ''${pkgs.findutils}/bin/find -type f -printf '%T+ %p\n' | sort | tail'';
|
|
oldestFile = ''${pkgs.findutils}/bin/find -type f -printf '%T+ %p\n' | sort | head'';
|
|
tracefiles = ''${pkgs.strace}/bin/strace -f -t -e trace=file'';
|
|
};
|
|
historySize = 100000;
|
|
historyFile = "${config.xdg.stateHome}/shell_history";
|
|
in
|
|
{
|
|
|
|
home-manager.enable = true;
|
|
bash = {
|
|
enable = true;
|
|
bashrcExtra = ''
|
|
shopt -s expand_aliases
|
|
shopt -s histappend
|
|
'';
|
|
sessionVariables = commonSessionVariables;
|
|
historySize = historySize;
|
|
historyFile = historyFile;
|
|
historyFileSize = historySize;
|
|
historyControl = [ "erasedups" "ignoredups" "ignorespace" ];
|
|
shellAliases = commonShellAliases // config.frogeye.shellAliases;
|
|
};
|
|
zsh = {
|
|
enable = true;
|
|
enableAutosuggestions = true;
|
|
enableCompletion = true;
|
|
syntaxHighlighting.enable = true;
|
|
historySubstringSearch.enable = true;
|
|
initExtra = builtins.readFile ./zshrc.sh;
|
|
defaultKeymap = "viins";
|
|
history = {
|
|
size = historySize;
|
|
save = historySize;
|
|
path = historyFile;
|
|
expireDuplicatesFirst = true;
|
|
};
|
|
sessionVariables = commonSessionVariables;
|
|
shellAliases = commonShellAliases // config.frogeye.shellAliases;
|
|
};
|
|
bat = {
|
|
enable = true;
|
|
config = {
|
|
theme = "base16";
|
|
style = "full";
|
|
};
|
|
};
|
|
lsd = {
|
|
enable = true;
|
|
settings = {
|
|
size = "short";
|
|
};
|
|
colors = {
|
|
# Base16 only, so it reuses the current theme.
|
|
date = { day-old = 4; hour-old = 6; older = 5; };
|
|
git-status = { conflicted = 14; default = 13; deleted = 1; ignored = 13; modified = 3; new-in-index = 2; new-in-workdir = 2; renamed = 4; typechange = 3; unmodified = 13; };
|
|
group = 6;
|
|
inode = { invalid = 245; valid = 13; };
|
|
links = { invalid = 9; valid = 14; };
|
|
permission = { acl = 6; context = 14; exec = 1; exec-sticky = 5; no-access = 245; octal = 6; read = 2; write = 3; };
|
|
size = { large = 1; medium = 9; none = 11; small = 3; };
|
|
tree-edge = 13;
|
|
user = 2;
|
|
};
|
|
};
|
|
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
|
|
echo -en "\033]0; $USER@$HOST $PWD\007"
|
|
'';
|
|
};
|
|
git.enable = true;
|
|
gpg.enable = true;
|
|
fzf = {
|
|
enable = true;
|
|
enableZshIntegration = true;
|
|
defaultOptions = [ "--height 40%" "--layout=default" ];
|
|
fileWidgetOptions = [ "--preview '[[ -d {} ]] && ${pkgs.coreutils}/bin/ls -l --color=always {} || [[ \$(${pkgs.file}/bin/file --mime {}) =~ binary ]] && ${pkgs.file}/bin/file --brief {} || (${pkgs.highlight}/bin/highlight -O ansi -l {} || coderay {} || rougify {} || ${pkgs.coreutils}/bin/cat {}) 2> /dev/null | head -500'" ];
|
|
# TODO Above not working... not really used either?
|
|
# file and friends are not in PATH by default... so here we want aboslute paths, which means those won't get reloaded. Meh.
|
|
};
|
|
nix-index = {
|
|
# For non-NixOS systems
|
|
enable = false; # TODO Index is impossible to generate, should use https://github.com/nix-community/nix-index-database
|
|
# but got no luck without flakes
|
|
enableZshIntegration = true;
|
|
};
|
|
less.enable = true;
|
|
nixvim.enable = true;
|
|
readline = {
|
|
enable = true;
|
|
variables = {
|
|
"bell-style" = "none";
|
|
"colored-completion-prefix" = true;
|
|
"colored-stats" = true;
|
|
"completion-ignore-case" = true;
|
|
"completion-query-items" = 200;
|
|
"editing-mode" = "vi";
|
|
"history-preserve-point" = true;
|
|
"history-size" = 10000;
|
|
"horizontal-scroll-mode" = false;
|
|
"mark-directories" = true;
|
|
"mark-modified-lines" = false;
|
|
"mark-symlinked-directories" = true;
|
|
"match-hidden-files" = true;
|
|
"menu-complete-display-prefix" = true;
|
|
"page-completions" = true;
|
|
"print-completions-horizontally" = false;
|
|
"revert-all-at-newline" = false;
|
|
"show-all-if-ambiguous" = true;
|
|
"show-all-if-unmodified" = true;
|
|
"show-mode-in-prompt" = true;
|
|
"skip-completed-text" = true;
|
|
"visible-stats" = false;
|
|
};
|
|
extraConfig = builtins.readFile ./inputrc;
|
|
};
|
|
tmux.enable = true;
|
|
translate-shell.enable = true; # TODO Cool config?
|
|
password-store.enable = true;
|
|
};
|
|
xdg = {
|
|
configFile = {
|
|
"iftoprc" = {
|
|
text = ''
|
|
port-resolution: no
|
|
promiscuous: no
|
|
port-display: on
|
|
link-local: yes
|
|
use-bytes: yes
|
|
show-totals: yes
|
|
log-scale: yes
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
home = {
|
|
activation = {
|
|
# Prevent Virtualbox from creating a "VirtualBox VMs" folder in $HOME
|
|
setVirtualboxSettings = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
|
if command -v VBoxManage > /dev/null
|
|
then
|
|
VBoxManage setproperty machinefolder ${config.xdg.dataHome}/virtualbox
|
|
fi
|
|
'';
|
|
};
|
|
stateVersion = "23.11";
|
|
language = {
|
|
base = "en_US.UTF-8";
|
|
# time = "en_DK.UTF-8"; # TODO Disabled because complaints during nixos-rebuild switch
|
|
};
|
|
packages = with pkgs; [
|
|
# Terminal utils
|
|
coreutils
|
|
moreutils
|
|
rename
|
|
which
|
|
file
|
|
|
|
# Pipe utils
|
|
gnugrep
|
|
gnused
|
|
gawk
|
|
|
|
# Extraction
|
|
gnutar
|
|
unzip
|
|
unrar
|
|
p7zip
|
|
|
|
# Documentation
|
|
man
|
|
tldr
|
|
neofetch
|
|
|
|
# nix utils
|
|
nix-diff
|
|
nix-tree
|
|
nix-output-monitor
|
|
|
|
# remote
|
|
wget
|
|
curl
|
|
openssl
|
|
openssh
|
|
rsync
|
|
borgbackup
|
|
|
|
# cleanup
|
|
ncdu
|
|
jdupes
|
|
duperemove
|
|
compsize
|
|
|
|
# local monitoring
|
|
htop
|
|
iotop
|
|
iftop
|
|
lsof
|
|
strace
|
|
pv
|
|
progress
|
|
speedtest-cli
|
|
|
|
# toolbox
|
|
sox
|
|
imagemagick
|
|
numbat
|
|
|
|
# password
|
|
pwgen
|
|
|
|
];
|
|
sessionVariables = {
|
|
# Favourite commands
|
|
PAGER = "less";
|
|
EDITOR = "nvim";
|
|
|
|
# Extra config
|
|
BOOT9_PATH = "${config.xdg.dataHome}/citra-emu/sysdata/boot9.bin";
|
|
CCACHE_CONFIGPATH = "${config.xdg.configHome}/ccache.conf";
|
|
# INPUTRC = "${config.xdg.configHome}/inputrc"; # UPST Will use programs.readline, but doesn't allow path setting
|
|
LESSHISTFILE = "${config.xdg.stateHome}/lesshst";
|
|
NODE_REPL_HISTORY = "${config.xdg.cacheHome}/node_repl_history";
|
|
# TODO I think we're not using the urxvt daemon on purpose?
|
|
# TODO this should be desktop only, as a few things are too.
|
|
SQLITE_HISTFILE = "${config.xdg.stateHome}/sqlite_history";
|
|
YARN_DISABLE_SELF_UPDATE_CHECK = "true"; # This also disable the creation of a ~/.yarnrc file
|
|
} // lib.optionalAttrs config.frogeye.desktop.xorg {
|
|
# Favourite commands
|
|
VISUAL = "nvim";
|
|
|
|
# Extra config
|
|
RXVT_SOCKET = "${config.xdg.stateHome}/urxvtd"; # Used to want -$HOME suffix, hopefullt this isn't needed
|
|
# XAUTHORITY = "${config.xdg.configHome}/Xauthority"; # Disabled as this causes lock-ups with DMs
|
|
};
|
|
# TODO Session variables only get reloaded on login I think.
|
|
sessionPath = [
|
|
"${config.home.homeDirectory}/.local/bin"
|
|
"${config.home.homeDirectory}/.config/dotfiles/hm/scripts" # Not Nix path otherwise it gets converted into store,
|
|
# and then every time you want to modify a script you have to rebuild and re-login...
|
|
];
|
|
# TODO Way to automatically setup an home-manager install
|
|
};
|
|
}
|