Personal Nix setup

Initial Commit

kitten.sh 4af18e78

+17
.editorconfig
···
···
+
# http://editorconfig.org
+
root = true
+
+
[*]
+
charset = utf-8
+
indent_size = 2
+
end_of_line = lf
+
indent_style = space
+
insert_final_newline = true
+
trim_trailing_whitespace = true
+
+
[*.md]
+
max_line_length = 100
+
trim_trailing_whitespace = false
+
+
[COMMIT_EDITMSG]
+
max_line_length = 0
+17
.gitmodules
···
···
+
[submodule "channels/nixpkgs"]
+
path = channels/nixpkgs
+
url = https://github.com/NixOS/nixpkgs-channels.git
+
branch = nixpkgs-unstable
+
shallow = true
+
[submodule "channels/darwin"]
+
path = channels/darwin
+
url = https://github.com/LnL7/nix-darwin.git
+
branch = master
+
[submodule "channels/home-manager"]
+
path = channels/home-manager
+
url = https://github.com/rycee/home-manager.git
+
branch = master
+
[submodule "channels/nixpkgs-unstable"]
+
path = channels/nixpkgs-unstable
+
url = https://github.com/NixOS/nixpkgs.git
+
shallow = true
+1
channels/binary-caches/nixpkgs
···
···
+
https://cache.nixos.org
+14
channels/default.nix
···
···
+
rec {
+
__nixPath = [
+
{ prefix = "binary-caches"; path = ./binary-caches; }
+
{ prefix = "darwin"; path = ./darwin; }
+
{ prefix = "darwin-config"; path = ../configuration.nix; }
+
{ prefix = "home-manager"; path = ./home-manager; }
+
{ prefix = "nixos"; path = ./nixpkgs; }
+
{ prefix = "nixos-config"; path = ../configuration.nix; }
+
{ prefix = "nixpkgs"; path = ./nixpkgs; }
+
{ prefix = "nixpkgs-unstable"; path = ./nixpkgs-unstable; }
+
];
+
+
nixPath = map ({ prefix, path }: "${prefix}=${__replaceStrings [ "/mnt/" ] [ "/" ] (toString path)}") __nixPath;
+
}
+17
config/gpg.nix
···
···
+
{ lib, pkgs, ... }:
+
+
let
+
inherit (lib) optionalAttrs mkMerge;
+
inherit (lib.systems.elaborate { system = builtins.currentSystem; }) isLinux isDarwin;
+
in {
+
environment.systemPackages = [
+
pkgs.gnupg
+
];
+
+
programs.gnupg = {
+
agent = {
+
enable = true;
+
enableSSHSupport = true;
+
};
+
};
+
}
+7
config/home/default.nix
···
···
+
{
+
imports = [
+
./git.nix
+
./zsh.nix
+
./tmux.nix
+
];
+
}
+57
config/home/git.nix
···
···
+
{
+
programs.git = {
+
enable = true;
+
userName = "Phil Pluckthun";
+
userEmail = "phil@kitten.sh";
+
+
signing = {
+
signByDefault = true;
+
key = "303B6A9A312AA035";
+
};
+
+
ignores = [
+
".DS_Store"
+
"*.sw[nop]"
+
"*.undodir"
+
".env"
+
"*.orig"
+
];
+
+
lfs = {
+
enable = true;
+
};
+
+
aliases = {
+
s = "status -s";
+
last = "log -1";
+
lol = "log --oneline";
+
recommit = "commit -a --amend --no-edit";
+
pushf = "push --force-with-lease";
+
glog = "log --oneline --decorate --all --graph";
+
};
+
+
delta = {
+
enable = true;
+
options = [
+
"--tabs=2"
+
"--theme=base16"
+
];
+
};
+
+
extraConfig = {
+
status.showUntrackedFiles = "all";
+
push.default = "simple";
+
color.ui = "auto";
+
pull.rebase = true;
+
fetch.prune = true;
+
diff.tool = "vimdiff";
+
diff.sunmodule = "log";
+
diff.compactionHeuristic = true;
+
merge.ff = "only";
+
merge.tool = "vimdiff";
+
difftool.prompt = false;
+
mergetool.prompt = true;
+
"mergetool \"vimdiff\"".cmd = "nvim -d $LOCAL $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J'";
+
};
+
};
+
}
+80
config/home/tmux.nix
···
···
+
{ lib, pkgs, ... }:
+
+
let
+
inherit (lib.systems.elaborate { system = builtins.currentSystem; }) isLinux;
+
+
defaultActiveColor = "yellow";
+
defaultInactiveColor = "colour241";
+
defaultFeatureColor = "colour14";
+
defaultBorderColor = "colour10";
+
in {
+
programs.tmux = {
+
enable = true;
+
aggressiveResize = true;
+
baseIndex = 1;
+
escapeTime = 0;
+
historyLimit = 5000;
+
keyMode = "vi";
+
shortcut = "a";
+
terminal = "xterm-256color";
+
+
secureSocket = isLinux;
+
+
plugins = [ ];
+
+
extraConfig = ''
+
set -g mouse on
+
+
set -g status-left-length 32
+
set -g status-right-length 150
+
set -g status-interval 5
+
+
set-option -ga terminal-overrides ",xterm-256color*:Tc:smso"
+
+
set-option -g status-style fg=${defaultActiveColor},bg=default
+
+
set-window-option -g window-status-style fg=${defaultInactiveColor},bg=default
+
+
set-window-option -g window-status-current-style fg=${defaultActiveColor},bg=default
+
set-window-option -g window-status-current-format "#[bold]#I #W"
+
set-option -g pane-border-style fg=${defaultInactiveColor}
+
set-option -g pane-active-border-style fg=${defaultBorderColor}
+
set-option -g message-style fg=${defaultActiveColor},bg=default
+
set-option -g display-panes-active-colour ${defaultActiveColor}
+
set-option -g display-panes-colour ${defaultInactiveColor}
+
+
set-window-option -g clock-mode-colour ${defaultActiveColor}
+
+
set -g window-status-format "#I #W"
+
+
set -g status-left "#[fg=${defaultFeatureColor},bold]#S "
+
set -g status-right "#[fg=${defaultInactiveColor}] %R %d %b"
+
+
set -g pane-border-style fg=colour238,bg=colour238
+
set -g pane-active-border-style fg=colour238,bg=colour238
+
+
unbind C-p
+
bind C-p paste-buffer
+
+
bind -n C-h select-pane -L
+
bind -n C-j select-pane -D
+
bind -n C-k select-pane -U
+
bind -n C-l select-pane -R
+
+
bind -r h resize-pane -L 2
+
bind -r j resize-pane -D 2
+
bind -r k resize-pane -U 2
+
bind -r l resize-pane -R 2
+
+
bind b kill-pane
+
'';
+
};
+
+
programs.zsh.shellAliases = {
+
ta = "tmux attach -t";
+
ts = "tmux new-session -s";
+
tl = "tmux list-sessions";
+
tksv = "tmux kill-server";
+
tkss = "tmux kill-session -t";
+
};
+
}
+23
config/home/zsh.nix
···
···
+
{
+
programs.zsh = {
+
enable = true;
+
enableAutosuggestions = true;
+
+
shellAliases = {
+
ls = "ls --color=auto";
+
ll = "ls -l";
+
};
+
};
+
+
programs.starship = {
+
enable = true;
+
enableZshIntegration = true;
+
+
settings = {
+
add_newline = false;
+
character.symbol = "➜";
+
aws.disabled = true;
+
cmd_duration.disabled = true;
+
};
+
};
+
}
+16
config/nodejs.nix
···
···
+
{ cfg, pkgs, pkgs-unstable, ... }:
+
+
{
+
environment.systemPackages =
+
(with pkgs-unstable;
+
let nodejs = nodejs-14_x;
+
in [
+
nodejs
+
(yarn.override { inherit nodejs; })
+
]
+
);
+
+
environment.interactiveShellInit = ''
+
export PATH=$HOME/.yarn/bin:$PATH
+
'';
+
}
+112
config/nvim/basic.vim
···
···
+
" Set default shell
+
set shell=/bin/bash
+
+
set hidden
+
+
" Encoding
+
set encoding=utf8
+
+
" Indentation
+
filetype plugin indent off
+
set autoindent
+
set nosmartindent
+
set ts=2
+
set shiftwidth=2
+
set expandtab
+
+
" Max Width
+
set textwidth=0
+
+
" Lazy redraw for e.g. macros
+
set lazyredraw
+
+
" Lower default updatetime
+
set updatetime=300
+
+
" No wrapping except onmarkdown and html
+
set nowrap
+
autocmd FileType markdown setlocal wrap
+
autocmd FileType html setlocal wrap
+
+
" Make backspace usable
+
set backspace=indent,eol,start
+
+
" Show matching brackets
+
set showmatch
+
+
" Searching
+
set ignorecase
+
set hlsearch
+
set incsearch
+
+
" Smartcaps
+
set smartcase
+
+
" Statusbar
+
set ruler
+
set laststatus=2
+
set statusline=%F%m%r%h%w\ [%l,%c]\ [%L,%p%%]
+
+
" Scrolling
+
set scrolloff=2
+
+
" No code folding
+
set nofoldenable
+
+
" No Backup
+
set nobackup
+
set nowritebackup
+
set nowb
+
set noswapfile
+
+
" Line numbers
+
set number
+
+
" Open new split panes to right and bottom, which feels more natural
+
set splitbelow
+
set splitright
+
+
" Always use vertical diffs
+
set diffopt+=vertical
+
+
" Italics support
+
set t_ZH=^[[3m
+
set t_ZR=^[[23m
+
+
" Fold by indentation
+
set foldenable
+
set foldmethod=indent
+
set foldnestmax=9
+
set foldlevelstart=3
+
+
set shortmess+=I
+
set shortmess+=c
+
+
" Persist undo history
+
if has('persistent_undo')
+
if !isdirectory($HOME."/.cache/vim")
+
call mkdir($HOME."/.cache/vim", "", 0770)
+
endif
+
+
if !isdirectory($HOME."/.cache/vim/undo")
+
call mkdir($HOME."/.cache/vim/undo", "", 0770)
+
endif
+
+
set undodir=~/.cache/vim/undo
+
set undofile
+
set undolevels=1000
+
set undoreload=10000
+
endif
+
+
" Strip Trailing Whitespace on Save
+
function! TrimWhiteSpace()
+
%s/\s\+$//e
+
endfunction
+
autocmd BufWritePre * :call TrimWhiteSpace()
+
+
" Command livepreview for nvim
+
if has('nvim')
+
set inccommand=nosplit
+
endif
+
+
+100
config/nvim/default.nix
···
···
+
{ pkgs, fetchgit, ... }:
+
+
let
+
inherit (import <nixpkgs> {}) fetchFromGitHub;
+
inherit (pkgs.vimUtils) buildVimPluginFrom2Nix;
+
+
plugins.vim-purge-undodir = buildVimPluginFrom2Nix {
+
pname = "purge_undodir.vim";
+
version = "2017-09-11";
+
src = fetchFromGitHub {
+
owner = "jsfaint";
+
repo = "purge_undodir.vim";
+
rev = "7115b2462b7738dd796e9febecbd24055793789f";
+
sha256 = "1c20bk4g3a930pqs6w1wcw34wj7xpcp6zi1wkx7jadxqjjwgcclp";
+
};
+
meta.homepage = "https://github.com/jsfaint/purge_undodir.vim";
+
};
+
+
plugins.vitality-vim = buildVimPluginFrom2Nix {
+
pname = "vitality.vim";
+
version = "2017-01-30";
+
src = fetchFromGitHub {
+
owner = "sjl";
+
repo = "vitality.vim";
+
rev = "0f693bff572689ad52b781c012dad4926cd924f6";
+
sha256 = "06zjlyp86clv3airxaw45d94kcrznd36m5r4dpj6lfrijwc4xhly";
+
};
+
meta.homepage = "https://github.com/sjl/vitality.vim";
+
};
+
+
plugins.vim-zipper = buildVimPluginFrom2Nix {
+
pname = "vim-zipper";
+
version = "2016-09-13";
+
src = fetchFromGitHub {
+
owner = "sts10";
+
repo = "vim-zipper";
+
rev = "5e60e2b39362168598db543f0c99bad930d5966f";
+
sha256 = "088m30inpq9rwd0c7pyick7ibji2vdhdf4hzd6iy4c5z1mn9kch1";
+
};
+
meta.homepage = "https://github.com/sts10/vim-zipper";
+
};
+
+
plugins.vim-golden-ratio = buildVimPluginFrom2Nix {
+
pname = "vim-golden-ratio";
+
version = "2020-04-03";
+
src = fetchFromGitHub {
+
owner = "roman";
+
repo = "golden-ratio";
+
rev = "8313b6d6723c9e77ef1d3760af2cdd244e8db043";
+
sha256 = "03nm1wr0qsrirg4z4171f4nygnqgb6w06ldr6rbbz4a1f7j8j654";
+
};
+
meta.homepage = "https://github.com/roman/golden-ratio";
+
};
+
+
plugins.vim-listtoggle = buildVimPluginFrom2Nix {
+
pname = "vim-listtoggle";
+
version = "2019-03-13";
+
src = fetchFromGitHub {
+
owner = "Valloric";
+
repo = "ListToggle";
+
rev = "63fb8acb57d57380b2e30e7a831247140559c95f";
+
sha256 = "1fbshc3pjm0d1nnig2wnbj9yf39iagva44k2qhl85zfz1pv7sv57";
+
};
+
meta.homepage = "https://github.com/Valloric/ListToggle";
+
};
+
in {
+
environment.variables = { EDITOR = "vim"; };
+
+
environment.systemPackages = with pkgs; [
+
(neovim.override {
+
viAlias = true;
+
vimAlias = true;
+
+
configure = {
+
customRC = pkgs.callPackage ./vimrc.nix {};
+
vam.knownPlugins = pkgs.vimPlugins // plugins;
+
vam.pluginDictionaries = [
+
{ name = "palenight-vim"; }
+
{ name = "vim-repeat"; }
+
{ name = "editorconfig-vim"; }
+
{ name = "vim-purge-undodir"; }
+
{ name = "lightline-vim"; }
+
{ name = "vitality-vim"; }
+
{ name = "vim-zipper"; }
+
{ name = "vim-golden-ratio"; }
+
{ name = "goyo-vim"; }
+
{ name = "limelight-vim"; }
+
{ name = "fzf-vim"; }
+
{ name = "vim-dirvish"; }
+
{ name = "vim-fugitive"; }
+
{ name = "vim-listtoggle"; }
+
{ name = "vim-polyglot"; }
+
{ name = "vim-easymotion"; }
+
{ name = "vim-surround"; }
+
{ name = "coc-nvim"; }
+
];
+
};
+
}
+
)];
+
}
+149
config/nvim/keymap.vim
···
···
+
" Set leader to space
+
let mapleader=" "
+
nnoremap <Space> <nop>
+
+
" unmap F1 help
+
nmap <F1> <nop>
+
imap <F1> <nop>
+
+
" Map <C-w> , to vsp and . to sp
+
nnoremap <C-w>, :vsp<CR>
+
nnoremap <C-w>. :sp<CR>
+
+
" Map semicolon to colon
+
noremap ; :
+
+
" Quick/Location list Toggle
+
let g:lt_location_list_toggle_map = '<leader>p'
+
let g:lt_quickfix_list_toggle_map = '<leader>q'
+
+
" fzf
+
nnoremap <silent> <Leader>o :GFiles<CR>
+
+
" Agerium
+
function! Agerium()
+
let params = input('Search files for: ')
+
execute 'Ag ' . params
+
endfunction
+
nnoremap <Leader>f :call Agerium()<CR>
+
+
" Easymotion Shortcuts
+
map n <Plug>(easymotion-next)
+
map N <Plug>(easymotion-prev)
+
+
" Gif config
+
map / <Plug>(easymotion-sn)
+
omap / <Plug>(easymotion-tn)
+
+
" unmap arrow keys
+
noremap <Up> <Nop>
+
noremap <Down> <Nop>
+
noremap <Left> <Nop>
+
noremap <Right> <Nop>
+
+
" Remap Arrow keys
+
map <Up> <Plug>(easymotion-k)
+
map <Down> <Plug>(easymotion-j)
+
map <Left> <Plug>(easymotion-linebackward)
+
map <Right> <Plug>(easymotion-lineforward)
+
+
" Move to previous/next buffer
+
nnoremap <silent> <leader>h :bprevious<CR>
+
nnoremap <silent> <leader>l :bnext<CR>
+
+
" Go to last used buffer
+
nnoremap <leader>j <C-^>
+
+
" Close a buffer
+
nnoremap <silent> <leader>k :bp <BAR> bd #<CR>
+
+
" List buffers
+
nnoremap <silent> <leader>b :Buffers<CR>
+
+
" List buffer commits
+
nnoremap <silent> <leader>c :BCommits<CR>
+
+
" List git status files
+
nnoremap <silent> <leader>c :GFiles?<CR>
+
+
" Toggle zen mode
+
nnoremap <silent> <leader>z :Goyo<CR>
+
+
" Blackhole all x commands and make X behave like d
+
nnoremap X "_d
+
nnoremap XX "_dd
+
vnoremap X "_d
+
vnoremap x "_d
+
nnoremap x "_x
+
+
" Make the dot command work as expected in visual mode (via
+
" https://www.reddit.com/r/vim/comments/3y2mgt/do_you_have_any_minor_customizationsmappings_that/cya0x04)
+
vnoremap . :norm.<CR>
+
+
" Allows you to visually select a section and then hit @ to run a macro on all lines
+
" https://medium.com/@schtoeffel/you-don-t-need-more-than-one-cursor-in-vim-2c44117d51db#.3dcn9prw6
+
function! ExecuteMacroOverVisualRange()
+
echo "@".getcmdline()
+
execute ":'<,'>normal @".nr2char(getchar())
+
endfunction
+
" Executes a macro for each line in visual selection
+
xnoremap @ :<C-u>call ExecuteMacroOverVisualRange()<CR>
+
+
" Have the indent commands re-highlight the last visual selection to make
+
" multiple indentations easier
+
vnoremap > >gv
+
vnoremap < <gv
+
+
" Make Ctrl-c behave exactly like Escape (because it matters to completions)
+
inoremap <c-c> <ESC>
+
xnoremap <c-c> <ESC>
+
+
" Use tab for trigger completion with characters ahead and navigate.
+
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
+
inoremap <silent><expr> <TAB>
+
\ pumvisible() ? "\<C-n>" :
+
\ <SID>check_back_space() ? "\<TAB>" :
+
\ coc#refresh()
+
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
+
+
function! s:check_back_space() abort
+
let col = col('.') - 1
+
return !col || getline('.')[col - 1] =~# '\s'
+
endfunction
+
+
" Use <c-space> to trigger completion.
+
inoremap <silent><expr> <c-space> coc#refresh()
+
+
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
+
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
+
+
" Use `[g` and `]g` to navigate diagnostics
+
nmap <silent> [g <Plug>(coc-diagnostic-prev)
+
nmap <silent> ]g <Plug>(coc-diagnostic-next)
+
+
" Remap keys for gotos
+
nmap <silent> gd <Plug>(coc-definition)
+
nmap <silent> gy <Plug>(coc-type-definition)
+
nmap <silent> gi <Plug>(coc-implementation)
+
nmap <silent> gr <Plug>(coc-references)
+
nmap <silent> gn <Plug>(coc-rename)
+
+
function! s:show_documentation()
+
if (index(['vim','help'], &filetype) >= 0)
+
execute 'h '.expand('<cword>')
+
else
+
call CocAction('doHover')
+
endif
+
endfunction
+
+
" Use K to show documentation in preview window
+
nnoremap <silent> K :call <SID>show_documentation()<CR>
+
+
" Highlight symbol under cursor on CursorHold
+
autocmd CursorHold * silent call CocActionAsync('highlight')
+
+
" Show all diagnostics
+
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
+
+
" Find symbol of current document
+
nnoremap <silent> <space>s :<C-u>CocList outline<cr>
+51
config/nvim/plugins.vim
···
···
+
" coc.nvim
+
let g:coc_global_extensions = [ 'coc-tsserver', 'coc-eslint', 'coc-json' ]
+
+
" Polyglot
+
let g:javascript_plugin_flow = 1
+
let g:jsx_ext_required = 0
+
+
" EasyMotion
+
let g:EasyMotion_do_mapping = 0
+
let g:EasyMotion_smartcase = 1
+
let g:EasyMotion_startofline = 0
+
+
" Fugitive
+
let g:Gitv_OpenHorizontal = 1
+
let g:Gitv_WipeAllOnClose = 1
+
let g:Gitv_DoNotMapCtrlKey = 1
+
+
" fzf
+
let g:fzf_layout = { 'down': '~30%' }
+
let g:fzf_buffers_jump = 1
+
+
" Vitality
+
let g:vitality_always_assume_iterm = 1
+
+
" Limelight
+
let g:limelight_conceal_ctermfg = '#4c5259'
+
let g:limelight_conceal_guifg = '#4c5259'
+
+
" Goyo
+
let g:goyo_height = '85%'
+
let g:goyo_width = '80%'
+
+
" Lightline
+
set noshowmode
+
+
let g:lightline = {
+
\ 'colorscheme': 'one',
+
\ 'active': {
+
\ 'left': [ [ 'mode', 'paste' ],
+
\ [ 'readonly', 'filename' ] ],
+
\ },
+
\ 'component_function': {
+
\ 'filename': 'LightlineFilename',
+
\ },
+
\ }
+
+
function! LightlineFilename()
+
let filename = @% !=# '' ? @% : '[No Name]'
+
let modified = &modified ? ' +' : ''
+
return filename . modified
+
endfunction
+71
config/nvim/theme.vim
···
···
+
" Enable true color support
+
if (has("nvim"))
+
" For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198
+
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
+
endif
+
+
if (has("termguicolors"))
+
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
+
set termguicolors
+
endif
+
+
" Enable cursor shape switching
+
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
+
+
function! ResetTheme()
+
" Don't reset background colour
+
let &t_ut=''
+
+
" Better display for messages
+
set cmdheight=2
+
+
" Always show signcolumns
+
set signcolumn=yes
+
+
" Disable all bolds
+
set t_md=
+
+
" Palenight Italics
+
let g:palenight_terminal_italics=1
+
+
" Syntax highlighting
+
syntax enable
+
set background=dark
+
set cursorline
+
colorscheme palenight
+
+
" Translucent background
+
hi LineNr ctermfg=232 ctermbg=232 cterm=bold guifg=#16181c guibg=#16181c gui=bold
+
hi CursorLine ctermbg=232 guibg=#16181c
+
hi CursorLineNR ctermfg=235 ctermbg=232 cterm=bold guifg=#404449 guibg=#16181c gui=bold
+
hi NonText guifg=#404449 guibg=NONE gui=NONE
+
hi SpecialKey guifg=#404449 guibg=NONE gui=NONE
+
hi VertSplit ctermfg=235 ctermbg=235 cterm=NONE guifg=#282c34 guibg=#282c34 gui=NONE
+
hi Normal guifg=#f8f8f2 guibg=NONE gui=NONE
+
+
" Some theming for ALE
+
hi ALEWarningSign ctermfg=70 ctermbg=NONE cterm=NONE guifg=#4BAE16 guibg=NONE gui=NONE
+
hi ALEErrorSign ctermfg=166 ctermbg=NONE cterm=NONE guifg=#D3422E guibg=NONE gui=NONE
+
endfunction
+
+
call ResetTheme()
+
+
" Goyo Hooks
+
function! s:goyo_enter()
+
silent !tmux set status off
+
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
+
set listchars=
+
set scrolloff=999
+
Limelight
+
endfunction
+
+
function! s:goyo_leave()
+
silent !tmux set status on
+
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
+
set scrolloff=2
+
Limelight!
+
call ResetTheme()
+
endfunction
+
+
autocmd! User GoyoEnter nested call <SID>goyo_enter()
+
autocmd! User GoyoLeave nested call <SID>goyo_leave()
+16
config/nvim/vimrc.nix
···
···
+
{ stdenv, writeText }:
+
+
let
+
basic = builtins.readFile ./basic.vim;
+
theme = builtins.readFile ./theme.vim;
+
plugins = builtins.readFile ./plugins.vim;
+
keymap = builtins.readFile ./keymap.vim;
+
in
+
+
''
+
${basic}
+
${theme}
+
${plugins}
+
${keymap}
+
''
+
+27
config/shell.nix
···
···
+
{ lib, pkgs, ... }:
+
+
let
+
inherit (lib) mkMerge optionalAttrs;
+
inherit (lib.systems.elaborate { system = builtins.currentSystem; }) isLinux isDarwin;
+
in
+
+
mkMerge [
+
{
+
environment.systemPackages = [ pkgs.zsh ];
+
environment.pathsToLink = [ "/share/zsh" ];
+
+
programs.zsh = {
+
enable = true;
+
promptInit = lib.mkDefault "";
+
};
+
}
+
+
(optionalAttrs isDarwin {
+
environment.shells = [ pkgs.zsh ];
+
environment.loginShell = pkgs.zsh;
+
})
+
+
(optionalAttrs isLinux {
+
users.defaultUserShell = pkgs.zsh;
+
})
+
]
+7
configuration.nix
···
···
+
{
+
imports = [
+
./nix/nix-path.nix
+
./modules
+
./profiles/common.nix
+
];
+
}
+15
modules/darwin.nix
···
···
+
{ options, pkgs, ... }:
+
+
let
+
inherit (import ../channels) __nixPath;
+
in {
+
# Create /etc/bashrc that loads the nix-darwin environment.
+
programs.bash.enable = true;
+
+
# Recreate /run/current-system symlink after boot.
+
services.activate-system.enable = true;
+
+
# Auto-upgrade and manage nix with nix-darwin
+
services.nix-daemon.enable = true;
+
nix.package = pkgs.nix;
+
}
+11
modules/default.nix
···
···
+
{ lib, ... }:
+
+
let
+
inherit (lib) optional flatten;
+
inherit (lib.systems.elaborate { system = builtins.currentSystem; }) isLinux isDarwin;
+
in {
+
imports = flatten [
+
./home-manager.nix
+
(optional isDarwin ./darwin.nix)
+
];
+
}
+12
modules/home-manager.nix
···
···
+
{ lib, ... }:
+
+
let
+
inherit (lib) optional flatten;
+
inherit (import ../channels) __nixPath;
+
inherit (lib.systems.elaborate { system = builtins.currentSystem; }) isLinux isDarwin;
+
in {
+
imports = flatten [
+
(optional isDarwin <home-manager/nix-darwin>)
+
(optional isLinux <home-manager/nixos>)
+
];
+
}
+20
nix/hostname.nix
···
···
+
{ lib, ... }:
+
+
let
+
+
inherit (lib) maybeEnv fileContents;
+
inherit (lib.systems.elaborate { system = builtins.currentSystem; }) isLinux isDarwin;
+
+
in
+
+
maybeEnv "HOST" (fileContents (
+
if !isDarwin then
+
/etc/hostname
+
else
+
derivation {
+
name = "hostname";
+
system = builtins.currentSystem;
+
builder = "/bin/sh";
+
args = [ "-c" "/usr/sbin/scutil --get LocalHostName > $out" ];
+
}
+
))
+45
nix/nix-path.nix
···
···
+
{ config, lib, ... }:
+
+
let
+
+
inherit (import ../channels) __nixPath nixPath;
+
inherit (lib) mkForce;
+
inherit (lib.systems.elaborate { system = builtins.currentSystem; }) isLinux isDarwin;
+
+
in
+
+
rec {
+
nixpkgs = {
+
config.allowUnfree = true;
+
};
+
+
nix.nixPath = mkForce nixPath;
+
+
_module.args =
+
let
+
+
pkgsConf = {
+
inherit (config.nixpkgs) localSystem crossSystem;
+
config = config.nixpkgs.config // nixpkgs.config;
+
};
+
+
in
+
+
rec {
+
pkgs = import <nixpkgs> (
+
if isLinux then {
+
inherit (pkgsConf) config localSystem crossSystem;
+
} else {
+
inherit (pkgsConf) config;
+
}
+
);
+
+
pkgs-unstable = import <nixpkgs-unstable> (
+
if isLinux then {
+
inherit (pkgsConf) config localSystem crossSystem;
+
} else {
+
inherit (pkgsConf) config;
+
}
+
);
+
};
+
}
+16
profiles/common.nix
···
···
+
{ lib, ... }:
+
+
let
+
inherit (lib) optional flatten;
+
inherit (lib.systems.elaborate { system = builtins.currentSystem; }) isLinux isDarwin;
+
in {
+
imports = flatten [
+
./users.nix
+
../config/shell.nix
+
../config/nvim/default.nix
+
../config/nodejs.nix
+
../config/gpg.nix
+
+
(optional isDarwin ./darwin.nix)
+
];
+
}
+7
profiles/darwin.nix
···
···
+
{ pkgs, ... }:
+
+
{
+
environment.systemPackages = [
+
pkgs.coreutils
+
];
+
}
+23
profiles/users.nix
···
···
+
{ pkgs, lib, ... }:
+
+
let
+
inherit (lib) optionalAttrs mkMerge mkIf mkDefault;
+
inherit (lib.systems.elaborate { system = builtins.currentSystem; }) isLinux isDarwin;
+
+
home = import ../config/home/default.nix;
+
in
+
+
mkMerge [
+
{
+
home-manager.users.phil = home;
+
users.users.phil.home = mkIf isDarwin "/Users/phil";
+
}
+
+
(optionalAttrs isLinux {
+
users.users.phil = {
+
isNormalUser = true;
+
uid = 1000;
+
home = "/home/phil";
+
};
+
})
+
]