dotfiles/nix/home.nix
2019-08-24 02:49:54 -07:00

282 lines
7.1 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ config, lib, pkgs, ... }:
with lib;
let
git-plan = pkgs.buildGoPackage rec {
name = "git-plan";
version = "0";
goPackagePath = "gitlab.com/haaksmash/git-plan";
src = pkgs.fetchFromGitLab {
owner = "haaksmash";
repo = "git-plan";
rev = "30bc84ffc319383d3c209ec94213db898a6e0e37";
sha256 = "1x6swpm2qkrxxl612siihszz2zayy3c84rf18mg48w1kqjqj1qxc";
};
goDeps = ./git-plan.nix;
};
in {
home.packages = with pkgs; [
direnv
git-plan
htop
jq
keybase
lastpass-cli
nox
tree
ranger
ripgrep
zsh-autosuggestions
zsh-history-substring-search
zsh-syntax-highlighting
];
programs.direnv = {
enable = true;
stdlib = ''
layout_postgres() {
export PGDATA="$(direnv_layout_dir)/tmp/pgdata"
export PGHOST="$PGDATA"
if [[ ! -d "$PGDATA" ]]; then
initdb --locale=$LANG
cat <<EOF >>"$PGDATA/postgresql.conf"
listen_addresses = 'localhost'
unix_socket_directories = '$PGHOST'
EOF
echo "CREATE DATABASE $USER;" | postgres --single -E postgres
fi
}
layout_go() {
export GOPATH="$(direnv_layout_dir)/tmp/golibs"
if [[ ! -d "$GOPATH" ]]; then
mkdir -p $GOPATH
fi
export PATH="$GOPATH/bin:$PATH"
}
'';
};
programs.command-not-found.enable = true;
programs.git = {
enable = true;
userName = "Haak Saxberg";
userEmail = "haak.erling@gmail.com";
ignores = [
".idea/"
".direnv/"
".envrc"
".tools-info"
"*~"
"*.swp"
];
};
programs.zsh = {
enable = true;
enableCompletion = true;
defaultKeymap = "viins";
initExtra = mkForce (''
export LOCALE_ARCHIVE="/usr/lib/locale/locale-archive"
export NIX_PATH=$HOME/.nix-defexpr/channels:$NIX_PATH
export EDITOR=vim
source $HOME/.nix-profile/etc/profile.d/nix.sh
source $HOME/.nix-profile/share/fzf/key-bindings.zsh
source $HOME/.nix-profile/share/fzf/completion.zsh
source $HOME/.nix-profile/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source $HOME/.nix-profile/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source $HOME/.config/zsh/local.zsh
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey -M viins 'jj' vi-cmd-mode
eval "$(direnv hook zsh)"
'');
oh-my-zsh = {
enable = true;
theme = "bureau";
plugins = [
"vi-mode"
"git"
"z"
"nix-shell"
"tmuxinator"
];
};
};
programs.neovim = {
enable = true;
vimAlias = true;
withPython = true;
configure = {
packages.nixBundle = with pkgs.vimPlugins; {
start = [
vim-sensible
vim-startify
vim-javascript
vim-ruby
vim-nix
elm-vim
vim-elixir
alchemist-vim
haskell-vim
vim-markdown
vimtex
vim-airline
rainbow
vim-signify
vim-indent-guides
vim-surround
fugitive
easymotion
tagbar
vinegar
undotree
vim-test
ale
fzf-vim
fzfWrapper
LanguageClient-neovim
deoplete-nvim
papercolor-theme
];
};
customRC = ''
filetype plugin indent on
" ALE
let g:ale_fix_on_save = 1
" Easymotion
map / <Plug>(easymotion-sn)
omap / <Plug>(easymotion-tn)
map n <Plug>(easymotion-next)
map N <Plug>(easymotion-prev)
let g:EasyMotion_landing_highlight = 0
" Rainbow parentheses
let g:rainbow_conf = {
\ 'guifgs': ['RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3', 'RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3', 'RoyalBlue3', 'DarkOrchid3', 'firebrick3', 'RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3'],
\ 'ctermfgs': ['red', 'brown', 'blue', 'gray', 'green', 'magenta', 'cyan', 'darkred', 'brown', 'darkblue', 'gray', 'darkgreen', 'darkmagenta', 'darkcyan', 'red'],
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold']
\}
let g:rainbow_active = 1
" Vim-Test
nmap <silent> <leader>t :TestNearest<CR>
nmap <silent> <leader>T :TestFile<CR>
nmap <silent> <leader>a :TestSuite<CR>
nmap <silent> <leader>l :TestLast<CR>
nmap <silent> <leader>g :TestVisit<CR>
let test#strategy = "neovim"
" Deoplete
let g:deoplete#enable_at_startup = 1
" Indent guides
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_start_level = 2
" let netrw look like NERDTree
let g:netrw_liststyle = 3
let mapleader=","
set nobackup
set noswapfile
set pastetoggle=<F2>
set nowrap
set background=dark
colorscheme PaperColor
set nocompatible
set number relativenumber
set numberwidth=1
set cursorline
set cursorcolumn
set ruler
set list
set listchars=tab:>-,trail:-,extends:>,precedes:<,nbsp:+,eol:$
set matchpairs+=<:>
set ts=2
set shiftwidth=2
set expandtab
" Open new split panes to right and bottom, which feels more natural
set splitbelow
set splitright
""" Searching and Patterns
set ignorecase
set smartcase
set smarttab
set hlsearch
" Add the g flag to search/replace by default
set gdefault
"recalculate the trailing whitespace warning when idle, and after saving
autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning
" strip trailing whitespace
autocmd BufWritePre * :%s/\s\+$//e
""" Handy remaps
noremap ; :
inoremap jj <Esc>
map <silent> <leader>V :source ~/.config/nvim/init.vim<CR>:filetype detect<CR>:exe ":echo 'vimrc reloaded'"<CR>
map \q :q<CR>
map \w :w<CR>
noremap Q <nop>
""" Terminal mode remaps
tnoremap <Esc> <C-\><C-n>
nnoremap <leader>o :below 10sp term://$SHELL<cr>i
" Quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" Dont reset cursor to start of line when moving around.
set nostartofline
" minimal number of lines to keep above/below cursorline
set scrolloff=10
" Local overrides?
if filereadable($HOME . "/.vimrc.local")
source ~/.vimrc.local
endif
'';
};
};
programs.tmux = {
enable = true;
tmuxinator = {
enable = true;
};
};
programs.fzf = {
enable = true;
enableZshIntegration = true;
defaultCommand = "rg --no-ignore --follow --files --hidden --smart-case --glob \\\"!.git/*\\\"";
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
home.file.".tmux.conf" = {
source = ./tmux/tmux.conf;
};
}