This commit is contained in:
2026-02-15 22:26:47 +00:00
commit 7be0309d27
19 changed files with 860 additions and 0 deletions

72
hm_programs/bash.nix Normal file
View File

@@ -0,0 +1,72 @@
{ config, hostCfg, ... }:
let
gitPrompt = builtins.fetchurl {
url =
"https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh";
sha256 = "7ff718f4a06fd0a0be7edfef926abb41b1353c48c1515ad312d226965b74943a";
};
PROJECT_ROOT = ./.;
in {
programs = {
bash = {
enable = true;
profileExtra = ''
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
'';
initExtra = ''
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias sudonix='sudo env PATH=$PATH'
alias k='kubectl'
alias rm="trash-put"
# export BASH_COMPLETION_USER_DIR=$HOME/.nix-profile/share/bash-completion.d/
# Eternal bash history.
# ---------------------
# Undocumented feature which sets the size to "unlimited".
# http://stackoverflow.com/questions/9457233/unlimited-bash-history
export HISTFILESIZE=
export HISTSIZE=
# export HISTTIMEFORMAT="[%F %T] "
# Change the file location because certain bash sessions truncate .bash_history file upon close.
# http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login
export HISTFILE=~/.bash_eternal_history
# Force prompt to write history after every command.
# PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
PROMPT_COMMAND="history -a '$HISTFILE'; $PROMPT_COMMAND"
# Source custom configuration
if [ -f "$HOME/.bashrc.zs00lt" ]; then
. "${PROJECT_ROOT}/config-files/bashrc.zs00lt"
fi
# source <(kubectl completion bash)
# source <(helm completion bash)
# source <(rclone completion bash)
source ${gitPrompt}
eval "$(starship init bash)"
'';
};
};
}

3
hm_programs/default.nix Normal file
View File

@@ -0,0 +1,3 @@
{ ... }: {
imports = [ ./bash.nix ./git.nix ./tmux.nix ./vim.nix ];
}

65
hm_programs/git.nix Normal file
View File

@@ -0,0 +1,65 @@
{ ... }:
{
programs.git = {
enable = true;
ignores = [ ".tmp" "tmp" ".envrc" ];
settings = {
user.name = "alfonzso";
user.email = "alfonzso@gmail.com";
core = {
editor = "nvim";
whitespace = "trailing-space,space-before-tab";
quotepath = "off";
};
# pull.rebase = "true";
stash = { showPatch = "1"; };
color = {
pager = "true";
diff = "true";
grep = "true";
interactive = "true";
status = "always";
ui = "true";
};
"merge \"po\"" = {
name = "Gettext merge driver";
driver = "git-merge-po.sh %O %A %B";
};
apply = { whitespace = "fix"; };
diff = {
tool = "nvim -d";
colorMoved = "default";
};
"color \"diff-highlight\"" = {
oldNormal = "red bold";
oldHighlight = "red bold 52";
newNormal = "green bold";
newHighlight = "green bold 22";
};
"color \"diff\"" = {
meta = "yellow";
frag = "magenta bold";
commit = "yellow bold";
old = "red bold";
new = "green bold";
whitespace = "red reverse";
};
merge = { tool = "nvim"; };
"mergetool \"meld\"" = {
cmd = ''meld "$LOCAL" "$MERGED" "$REMOTE" --output "$MERGED"'';
};
"mergetool \"nvim\"" = {
cmd =
"nvim -d \"$LOCAL\" \"$REMOTE\" \"$MERGED\" -c '$wincmd w' -c 'wincmd J'";
};
"mergetool \"vscode\"" = { cmd = ''code --wait "$MERGED"''; };
};
};
}

41
hm_programs/tmux.nix Normal file
View File

@@ -0,0 +1,41 @@
{ pkgs, ... }: {
programs.tmux = {
enable = true;
extraConfig = ''
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# bind-key q last-window
# bind q last-window
bind-key -T prefix e switch-client -T last_window
bind-key -T last_window e last-window
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -sg escape-time 250
set-window-option -g mode-keys vi
# press <prefix>T to toggle between Cb and Ca
# bind-key T run-shell "~/.tmux/toggle-prefix.sh"
set-option -g default-shell "${pkgs.bash}/bin/bash"
set -g default-terminal "screen-256color"
new -n WindowName bash --login
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'git@github.com/user/plugin'
# set -g @plugin 'git@bitbucket.com/user/plugin'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
'';
};
}

43
hm_programs/vim.nix Normal file
View File

@@ -0,0 +1,43 @@
{ config, pkgs, hostCfg, ... }:
# let
# hostCfg = config.hostCfg ;
# in
let
hostCfg = { username = "nixos"; };
in
{
programs.vim = {
enable = true;
defaultEditor = true;
# config = builtins.readFile ~/.vimrc;
# extraConfig = builtins.readFile /home/nixos/.vimrc;
plugins = with pkgs.vimPlugins; [
vim-fzf-coauthorship
vim-sensible
vim-automkdir
vim-nix # Syntax highlighting for Nix
nerdtree # File explorer
fugitive # Git integration
];
extraConfig = ''
" NERDTree configuration
" nnoremap <leader>n :NERDTreeToggle<CR>
set tabstop =2
set softtabstop =2
set shiftwidth =2
set expandtab
set backupdir=/home/${hostCfg.username}/.vim-tmp
set directory=/home/${hostCfg.username}/.vim-tmp
set exrc
set secure
" Reopen the last edited position in files
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
'';
};
}