Nix Migration

This commit is contained in:
Evan Reichard 2022-11-15 12:32:46 -05:00 committed by Evan Reichard
parent 0c2bc7b391
commit 2660c89d37
11 changed files with 205 additions and 354 deletions

122
.bashrc
View File

@ -1,122 +0,0 @@
if [ -e /Users/evanreichard/.nix-profile/etc/profile.d/nix.sh ]; then . /Users/evanreichard/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer
# ------------------------------------------------------------------------------
# ---------------------------------- VI MODE -----------------------------------
# ------------------------------------------------------------------------------
set -o vi
# ------------------------------------------------------------------------------
# ---------------------------------- ALIASES -----------------------------------
# ------------------------------------------------------------------------------
alias vi="/Applications/MacVim.app/Contents/bin/mvim -v"
alias vim="/Applications/MacVim.app/Contents/bin/mvim -v"
alias grep="grep --color"
# Python URL Encode / Decoders
alias urldecode='python -c "import sys, urllib as ul; \
print ul.unquote_plus(sys.argv[1])"'
alias urlencode='python -c "import sys, urllib as ul; \
print ul.quote_plus(sys.argv[1])"'
# Spin up a Docker container mounting hosts PWD to `/mount` in the container
alias fast_docker='docker run -ti -v $(pwd):/mount ubuntu /bin/bash'
# ------------------------------------------------------------------------------
# --------------------------------- FUNCTIONS ----------------------------------
# ------------------------------------------------------------------------------
function cache {
# Description
# Caches the output and return of any command
#
# Usage:
# cache curl google.com
#
# Notes:
# Stores data in ~/.bash-cache/* - You need to manually clean up cache.
cmd="$*"
name=$(echo "$PWD-$cmd" | base64)
if [[ -f ~/.bash-cache/$name.exit ]] && [[ $(cat ~/.bash-cache/$name.exit) -eq 0 ]]; then
printf "CACHED:\n\n"
else
mkdir -p ~/.bash-cache
eval "$cmd" > ~/.bash-cache/$name.out
echo $? > ~/.bash-cache/$name.exit
fi
cat ~/.bash-cache/$name.out
}
function sfind(){
# Description:
# Finds a file with name $1 and searches file using grep with $2
#
# Usage:
# sfind *.csv evan
find . -name "$1" -print0 | xargs -0 grep "$2"
}
function csv2mdt(){
# Description:
# Converts a CSV file to Markdown table format.
#
# Usage:
# To stdout:
# csv2mdt test.csv
# To clipboard:
# csv2mdt test.csv | pbcopy
cat $1 | sed 1p | LC_ALL=C sed -e 's/,/ |\&nbsp\;\&nbsp\; /g' -e 's/^/| /g' -e 's/$/ |/g' -e '2 s/[^|]/-/g' | LC_ALL=C tr -d $'\r'
}
function ggrep(){
# Description:
# Use grep to search through all git history. Search results return file and
# git commit hash. Using git commit hash, you can view state of repo in
# GitHub: https://github.com/<USER_OR_ORG>/<REPO>/tree/<GIT_HASH>
#
# Usage:
# No Directory Specification
# ggrep -in get_config
# Specify Directory
# ggrep -in get_config -- /rules
#
# Notes:
# To see specific arguments allowed, see `man git-grep`
GREP_ARGS=$(echo "$@" | sed "s/\(^.*\)--\(.*$\)/\1/")
PATH_ARGS=$(echo "$@" | sed "s/\(^.*\)--\(.*$\)/\2/")
if [[ "$@" == "$GREP_ARGS" ]]; then
unset PATH_ARGS
fi
if [[ -n $PATH_ARGS ]]; then
git rev-list --all -- $PATH_ARGS | xargs -J{} git grep $GREP_ARGS {} -- $PATH_ARGS
else
git rev-list --all | xargs -J{} git grep $GREP_ARGS {}
fi
}
# ------------------------------------------------------------------------------
# ---------------------------------- EXPORTS -----------------------------------
# ------------------------------------------------------------------------------
export PATH=$HOME/.local/bin:$HOME/.yarn/bin:$HOME/Development/Tools/flutter/bin:$PATH
export GOPATH=$HOME/go
export KUBE_EDITOR="/Applications/MacVim.app/Contents/bin/mvim -v"
export NIX_PYTHONPATH=$(python3 -c "import sys; print(sys.base_prefix)")
# ------------------------------------------------------------------------------
# --------------------------------- POWERLINE ----------------------------------
# ------------------------------------------------------------------------------
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. $HOME/.local/lib/python3.9/site-packages/powerline/bindings/bash/powerline.sh
# ------------------------------------------------------------------------------
# ------------------------------ TMUX & NEOFETCH -------------------------------
# ------------------------------------------------------------------------------
[ ! -z $TMUX ] || tmux a || tmux
neofetch

View File

@ -1,18 +0,0 @@
{
"groups": {
"gitstatus": { "fg": "gray8", "bg": "gray2", "attrs": [] },
"gitstatus_branch": { "fg": "gray8", "bg": "gray2", "attrs": [] },
"gitstatus_branch_clean": { "fg": "green", "bg": "gray2", "attrs": [] },
"gitstatus_branch_dirty": { "fg": "gray8", "bg": "gray2", "attrs": [] },
"gitstatus_branch_detached": { "fg": "mediumpurple", "bg": "gray2", "attrs": [] },
"gitstatus_tag": { "fg": "darkcyan", "bg": "gray2", "attrs": [] },
"gitstatus_behind": { "fg": "gray10", "bg": "gray2", "attrs": [] },
"gitstatus_ahead": { "fg": "gray10", "bg": "gray2", "attrs": [] },
"gitstatus_staged": { "fg": "green", "bg": "gray2", "attrs": [] },
"gitstatus_unmerged": { "fg": "brightred", "bg": "gray2", "attrs": [] },
"gitstatus_changed": { "fg": "mediumorange", "bg": "gray2", "attrs": [] },
"gitstatus_untracked": { "fg": "brightestorange", "bg": "gray2", "attrs": [] },
"gitstatus_stashed": { "fg": "darkblue", "bg": "gray2", "attrs": [] },
"gitstatus:divider": { "fg": "gray8", "bg": "gray2", "attrs": [] }
}
}

View File

@ -1,47 +0,0 @@
{
"segments": {
"left": [
{
"function": "powerline.segments.shell.mode"
},
{
"function": "powerline.segments.common.net.hostname",
"priority": 10
},
{
"function": "powerline.segments.common.env.user",
"priority": 30
},
{
"function": "powerline.segments.common.env.virtualenv",
"priority": 50
},
{
"function": "powerline.segments.shell.cwd",
"priority": 10
},
{
"function": "powerline.segments.shell.jobnum",
"priority": 20
},
{
"function": "powerline_gitstatus.gitstatus",
"priority": 40
}
],
"right": [
{
"function": "powerline.segments.shell.last_pipe_status",
"priority": 10
},
{
"function": "powerline.segments.common.vcs.stash",
"priority": 50
},
{
"function": "powerline.segments.common.vcs.branch",
"priority": 40
}
]
}
}

View File

@ -1,28 +0,0 @@
{
"segments": {
"right": [
{
"function": "powerline.segments.common.sys.cpu_load_percent",
"priority": 50
},
{
"function": "powerline.segments.common.time.date"
},
{
"function": "powerline.segments.common.time.date",
"name": "time",
"args": {
"format": "%H:%M",
"istime": true
}
},
{
"function": "powerline.segments.common.bat.battery",
"priority": 50
},
{
"function": "powerline.segments.common.net.hostname"
}
]
}
}

View File

@ -1,6 +0,0 @@
set show-mode-in-prompt on
# set vi-cmd-mode-string "\1\e[1;48;5;246;38;5;237m\2 CMD \1\e[48;5;239;38;5;246m\2\1\e[0m\2"
# set vi-ins-mode-string "\1\e[1;48;5;109;38;5;237m\2 INS \1\e[48;5;239;38;5;109m\2\1\e[0m\2"
set vi-ins-mode-string \1\e[48;5;117;1m\2 INS \1\e[38;5;117;48;5;31;1m\2\1\e[0m\2
set vi-cmd-mode-string \1\e[48;5;166;1m\2 CMD \1\e[38;5;166;48;5;31;1m\2\1\e[0m\2

View File

@ -1,34 +0,0 @@
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set-option -g default-shell /Users/evanreichard/.nix-profile/bin/bash
set-option -g prefix C-t
set-option -g renumber-windows on
# Open new windows / tabs in same dir
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# Copy-paste integration
set-option -g default-command "reattach-to-user-namespace -l bash"
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' to begin selection as in Vim
#bind-key -t vi-copy v begin-selection
#bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# Update default binding of `Enter` to also use copy-pipe
#unbind -t vi-copy Enter
#bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
# Bind ']' to use pbpaste
bind ] run "reattach-to-user-namespace pbpaste | tmux load-buffer - && tmux paste-buffer"
# Powerline
source $HOME/.local/lib/python2.7/site-packages/powerline/bindings/tmux/powerline.conf
set -g default-terminal "screen-256color"
run -b '~/.tmux/plugins/tpm/tpm'

98
.vimrc
View File

@ -1,98 +0,0 @@
" Python Settings - Needed for Nix Python
set pythondll=$HOME/.nix-profile/bin/python3
set pythonhome=$NIX_PYTHONPATH
set pythonthreedll=$HOME/.nix-profile/bin/python3
set pythonthreehome=$NIX_PYTHONPATH
" Vundle & Plugins
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'ctrlp.vim'
Plugin 'airblade/vim-gitgutter'
Plugin 'VundleVim/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'chrisbra/csv.vim'
Plugin 'dracula/vim'
Bundle 'powerline/powerline', {'rtp': 'powerline/bindings/vim/'}
Plugin 'psf/black'
Plugin 'dart-lang/dart-vim-plugin'
Plugin 'natebosch/vim-lsc'
Plugin 'natebosch/vim-lsc-dart'
call vundle#end()
" Set Dart SDK
let g:ycm_dart_bin_folder_path = '/Users/evanreichard/Development/Tools/flutter/bin/cache/dart-sdk/bin'
let g:lsc_auto_map = v:true
" filetype off
filetype plugin indent on
" Highlight IP Addresses
syn match ipaddr /\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)/
hi link ipaddr Identifier
" Powerline
set laststatus=2
set t_Co=256
let g:Powerline_symbols = "fancy"
" Disable Modeline
set modelines=0
set nomodeline
" Set Mouse Select & Scroll
set mouse=a
" MiniBufExpl
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
" Turn syntax highlighting on
syntax on
" No line wrapping
set nowrap
" Line numbers
set nu
" Highlights searches (done by forward slash in normal mode)
set hlsearch
" Make backspace act normal
set backspace=2
" Disable swap files (no recovery if you dont save!)
set noswapfile
" Set vertical red line at the 80 char column
" set colorcolumn=80
" Set tab = 4 spaces
set tabstop=4
" Addects >> << ++ and automatic indentation
set shiftwidth=4
" Sets the tab key to softtabstop / tabstop
set expandtab
" synchronize with system clipboard (yank and paste in normal is effectively
" CMD+C & CMD+V in insert mode
set clipboard=unnamed
" Folding rules
set foldmethod=indent
set foldnestmax=10
set foldlevel=2
set nofoldenable
" CSV Settings
let g:csv_autocmd_arrange = 1
let g:csv_autocmd_arrange_size = 1024*1024*10
let b:csv_arrange_align = 'l*'
" netrw
let g:netrw_banner = 0
let g:netrw_liststyle = 4
let g:netrw_chgwin = 2
let g:netrw_browse_split = 3
" remap shift-enter to fire up the sidebar
" the same remap as above - may be necessary in some distros
nnoremap <silent> <C-M> :leftabove 25vs<CR>:e .<CR>
" View *.hex files in hex
au BufReadPost *.hex silent %!xxd

View File

@ -1 +1 @@
# dotfiles
# Nix Home Manager Configuration

9
extraConfig.tmux Normal file
View File

@ -0,0 +1,9 @@
# VIM, Prefix, Renumber
setw -g mode-keys vi
set-option -g prefix C-t
set-option -g renumber-windows on
# Maintain Directory
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"

54
extraConfig.vim Normal file
View File

@ -0,0 +1,54 @@
" lightline config
let g:lightline = {
\ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" },
\ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }
\ }
" set nowrap, line numbers, hightlight search
set nowrap
set nu
set hlsearch
" set fold settings
set foldmethod=indent
set foldnestmax=10
set foldlevel=2
set nofoldenable
" synchronize with system clipboard
set clipboard=unnamed
" remap shift-enter to fire up the sidebar
" the same remap as above - may be necessary in some distros
nnoremap <silent> <C-M> :leftabove 25vs<CR>:e .<CR>
" View *.hex files in hex
au BufReadPost *.hex silent %!xxd
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
set signcolumn=yes
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: There's always complete item selected by default, you may want to enable
" no select by `"suggest.noselect": true` in your configuration file.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction

141
home.nix Normal file
View File

@ -0,0 +1,141 @@
{ config, pkgs, ... }:
{
# Home Manager Config
home.username = "evanreichard";
home.homeDirectory = "/Users/evanreichard";
home.stateVersion = "22.05";
programs.home-manager.enable = true;
# Global Packages
home.packages = [
pkgs.bashInteractive
pkgs.htop
pkgs.k9s
pkgs.kubectl
pkgs.mosh
pkgs.neofetch
];
# Other Programs
programs.jq.enable = true;
programs.pandoc.enable = true;
# ----------------------
# --------- git --------
# ----------------------
programs.git = {
enable = true;
userName = "Evan Reichard";
userEmail = "evan@reichard.io";
};
# ----------------------
# ------ readline ------
# ----------------------
programs.readline = {
enable = true;
extraConfig = ''
# Show Prompt
set show-mode-in-prompt on
# Approximate VIM Dracula Colors
set vi-ins-mode-string \1\e[01;38;5;23;48;5;231m\2 INS \1\e[38;5;231;48;5;238m\2\1\e[0m\2
set vi-cmd-mode-string \1\e[01;38;5;22;48;5;148m\2 CMD \1\e[38;5;148;48;5;238m\2\1\e[0m\2
'';
};
# ----------------------
# -------- bash --------
# ----------------------
programs.bash = {
enable = true;
profileExtra =''
set -o vi
[ ! -z $TMUX ] || tmux a || tmux
neofetch
'';
};
# ----------------------
# -------- tmux --------
# ----------------------
programs.tmux = {
enable = true;
clock24 = true;
shell = "${pkgs.bashInteractive}/bin/bash";
plugins = with pkgs.tmuxPlugins; [
yank
cpu
resurrect
continuum
{
plugin = dracula;
extraConfig = ''
set -g @dracula-show-battery false
set -g @dracula-show-powerline true
set -g @dracula-refresh-rate 10
set -g @dracula-military-time true
set -g @dracula-plugins "battery cpu-usage ram-usage time"
'';
}
];
extraConfig = builtins.readFile ./extraConfig.tmux;
};
# ----------------------
# ------- neovim -------
# ----------------------
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
withNodeJs = true;
withPython3 = true;
plugins = with pkgs.vimPlugins; [
coc-eslint
coc-json
coc-pyright
coc-yaml
dracula-vim
lightline-vim
vim-nix
];
coc = {
enable = true;
package = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "coc.nvim";
version = "2022-11-03";
src = pkgs.fetchFromGitHub {
owner = "neoclide";
repo = "coc.nvim";
rev = "5f52e41be1ff19ce1f1bd3307144e7d96703b7fd";
sha256 = "0nm8jgdgxbdlvcpl12fs2fgxww5nizjpqd2ywm2n7ca0lsjpqcx0";
};
meta.homepage = "https://github.com/neoclide/coc.nvim/";
};
};
extraConfig = builtins.readFile ./extraConfig.vim;
};
# ----------------------
# ------ powerline -----
# ----------------------
programs.powerline-go = {
enable = true;
modules = [
"host"
"cwd"
"git"
"docker"
"venv"
];
};
}