2016-10-22 20:49:26 +00:00
|
|
|
{ pkgs ? import <nixpkgs> {} }:
|
2016-10-18 21:14:18 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
eval = pkgs.lib.evalModules
|
|
|
|
{ check = true;
|
|
|
|
args = { pkgs = import <nixpkgs> {}; };
|
|
|
|
modules =
|
|
|
|
[ config
|
2016-11-06 21:38:31 +00:00
|
|
|
./modules/system
|
2016-11-05 21:47:09 +00:00
|
|
|
./modules/system/activation-scripts.nix
|
|
|
|
./modules/system/etc.nix
|
2016-11-06 21:38:31 +00:00
|
|
|
./modules/environment
|
2016-11-01 20:25:22 +00:00
|
|
|
./modules/launchd
|
2016-11-06 21:38:31 +00:00
|
|
|
./modules/programs/tmux.nix
|
2016-10-18 21:14:18 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
config =
|
2016-10-19 21:25:15 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2016-10-18 21:14:18 +00:00
|
|
|
{
|
2016-10-19 18:03:17 +00:00
|
|
|
environment.systemPackages =
|
2016-11-05 23:08:33 +00:00
|
|
|
[ pkgs.lnl.zsh
|
|
|
|
pkgs.lnl.tmux
|
|
|
|
pkgs.lnl.vim
|
2016-10-19 18:03:17 +00:00
|
|
|
pkgs.curl
|
|
|
|
pkgs.fzf
|
|
|
|
pkgs.gettext
|
|
|
|
pkgs.git
|
|
|
|
pkgs.jq
|
|
|
|
pkgs.silver-searcher
|
|
|
|
|
|
|
|
pkgs.nix-repl
|
|
|
|
pkgs.nox
|
|
|
|
];
|
2016-10-18 21:14:18 +00:00
|
|
|
|
2016-11-03 19:40:29 +00:00
|
|
|
launchd.daemons.nix-daemon =
|
2016-11-03 22:28:33 +00:00
|
|
|
{ serviceConfig.Program = "${pkgs.nix}/bin/nix-daemon";
|
2016-11-03 19:40:29 +00:00
|
|
|
serviceConfig.KeepAlive = true;
|
|
|
|
serviceConfig.RunAtLoad = true;
|
2016-11-03 22:28:33 +00:00
|
|
|
serviceConfig.EnvironmentVariables.SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
|
2016-11-03 19:40:29 +00:00
|
|
|
serviceConfig.EnvironmentVariables.TMPDIR = "/nix/tmp";
|
|
|
|
serviceConfig.SoftResourceLimits.NumberOfFiles = 4096;
|
|
|
|
serviceConfig.ProcessType = "Background";
|
|
|
|
};
|
|
|
|
|
2016-11-05 23:08:33 +00:00
|
|
|
programs.tmux.loginShell = "${pkgs.lnl.zsh}/bin/zsh -l";
|
2016-11-03 19:40:29 +00:00
|
|
|
programs.tmux.enableSensible = true;
|
|
|
|
programs.tmux.enableMouse = true;
|
2016-11-07 21:47:17 +00:00
|
|
|
programs.tmux.enableFzf = true;
|
2016-11-03 19:40:29 +00:00
|
|
|
programs.tmux.enableVim = true;
|
|
|
|
|
2016-11-06 22:38:42 +00:00
|
|
|
programs.tmux.tmuxConfig = ''
|
|
|
|
bind 0 set status
|
|
|
|
|
|
|
|
set -g status-bg black
|
|
|
|
set -g status-fg white
|
|
|
|
'';
|
|
|
|
|
2016-10-21 18:56:23 +00:00
|
|
|
environment.variables.EDITOR = "vim";
|
2016-10-19 21:25:15 +00:00
|
|
|
environment.variables.HOMEBREW_CASK_OPTS = "--appdir=/Applications/cask";
|
2016-10-18 21:14:18 +00:00
|
|
|
|
2016-11-03 22:28:33 +00:00
|
|
|
environment.variables.GIT_SSL_CAINFO = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
|
|
|
|
environment.variables.SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
|
2016-10-21 18:56:23 +00:00
|
|
|
|
|
|
|
environment.shellAliases.l = "ls -lh";
|
|
|
|
environment.shellAliases.ls = "ls -G";
|
2016-11-05 23:08:33 +00:00
|
|
|
environment.shellAliases.g = "git log --graph --oneline";
|
|
|
|
environment.shellAliases.gd = "git diff --minimal -p";
|
2016-10-21 18:56:23 +00:00
|
|
|
|
2016-11-05 15:54:04 +00:00
|
|
|
environment.etc."zprofile".text = ''
|
|
|
|
# /etc/zprofile: DO NOT EDIT -- this file has been generated automatically.
|
|
|
|
# This file is read for login shells.
|
2016-11-01 20:25:22 +00:00
|
|
|
|
2016-11-05 15:54:04 +00:00
|
|
|
# Only execute this file once per shell.
|
|
|
|
if [ -n "$__ETC_ZPROFILE_SOURCED" ]; then return; fi
|
|
|
|
__ETC_ZPROFILE_SOURCED=1
|
2016-11-03 19:40:29 +00:00
|
|
|
|
2016-10-18 21:14:18 +00:00
|
|
|
autoload -U promptinit && promptinit
|
2016-11-05 15:54:04 +00:00
|
|
|
PROMPT='%B%(?..%? )%b⇒ '
|
|
|
|
RPROMPT='%F{green}%~%f'
|
2016-10-18 21:14:18 +00:00
|
|
|
|
2016-10-22 20:49:26 +00:00
|
|
|
bindkey -e
|
2016-10-18 21:14:18 +00:00
|
|
|
setopt autocd
|
2016-11-02 19:13:01 +00:00
|
|
|
|
2016-11-05 15:54:04 +00:00
|
|
|
autoload -U compinit && compinit
|
2016-10-18 21:14:18 +00:00
|
|
|
|
2016-11-16 22:19:49 +00:00
|
|
|
nix () {
|
|
|
|
cmd=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
case $cmd in
|
|
|
|
'b'|'build') nix-build --no-out-link -E "with import <nixpkgs> {}; $@" ;;
|
|
|
|
'e'|'eval') nix-instantiate --eval -E "with import <nixpkgs> {}; $@" ;;
|
|
|
|
'i'|'instantiate') nix-instantiate -E "with import <nixpkgs> {}; $@" ;;
|
|
|
|
'r'|'repl') nix-repl '<nixpkgs>' ;;
|
|
|
|
's'|'shell') nix-shell -E "with import <nixpkgs> {}; $@" ;;
|
|
|
|
'x'|'exec') nix-shell '<nixpkgs>' -p "$@" --run zsh ;;
|
|
|
|
'z'|'zsh') nix-shell '<nixpkgs>' -A "$@" --run zsh ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2016-11-05 15:54:04 +00:00
|
|
|
nixdarwin-rebuild () {
|
2016-11-16 22:19:49 +00:00
|
|
|
cmd=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
case $cmd in
|
|
|
|
'build') nix-build --no-out-link '<nixpkgs>' -A nixdarwin.toplevel "$@" ;;
|
|
|
|
'repl') nix-repl "$HOME/.nixpkgs/config.nix" "$@" ;;
|
|
|
|
'shell') nix-shell '<nixpkgs>' -p nixdarwin.toplevel --run '${pkgs.lnl.zsh}/bin/zsh -l' "$@" ;;
|
|
|
|
'switch') nix-env -f '<nixpkgs>' -iA nixdarwin.toplevel "$@" && nix-shell '<nixpkgs>' -A nixdarwin.toplevel --run 'sudo $out/activate' && exec ${pkgs.lnl.zsh}/bin/zsh -l ;;
|
|
|
|
esac
|
2016-11-05 15:54:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
conf=$HOME/src/nixpkgs-config
|
|
|
|
pkgs=$HOME/.nix-defexpr/nixpkgs
|
|
|
|
|
|
|
|
# Read system-wide modifications.
|
|
|
|
if test -f /etc/zprofile.local; then
|
|
|
|
. /etc/zprofile.local
|
|
|
|
fi
|
2016-11-03 19:40:29 +00:00
|
|
|
'';
|
|
|
|
|
2016-11-05 15:54:04 +00:00
|
|
|
environment.etc."zshenv".text = ''
|
|
|
|
# /etc/zshenv: DO NOT EDIT -- this file has been generated automatically.
|
|
|
|
# This file is read for all shells.
|
2016-10-18 21:14:18 +00:00
|
|
|
|
2016-11-05 15:54:04 +00:00
|
|
|
# Only execute this file once per shell.
|
|
|
|
# But don't clobber the environment of interactive non-login children!
|
|
|
|
|
|
|
|
if [ -n "$__ETC_ZSHENV_SOURCED" ]; then return; fi
|
|
|
|
export __ETC_ZSHENV_SOURCED=1
|
2016-11-02 19:04:51 +00:00
|
|
|
|
2016-11-05 15:54:04 +00:00
|
|
|
export NIX_PATH=nixpkgs=$HOME/.nix-defexpr/nixpkgs
|
|
|
|
|
2016-11-02 19:04:51 +00:00
|
|
|
# Set up secure multi-user builds: non-root users build through the
|
|
|
|
# Nix daemon.
|
|
|
|
if [ "$USER" != root -a ! -w /nix/var/nix/db ]; then
|
|
|
|
export NIX_REMOTE=daemon
|
|
|
|
fi
|
2016-10-18 21:14:18 +00:00
|
|
|
|
2016-11-05 23:08:33 +00:00
|
|
|
# Read system-wide modifications.
|
|
|
|
if test -f /etc/zshenv.local; then
|
|
|
|
. /etc/zshenv.local
|
|
|
|
fi
|
2016-11-05 15:54:04 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
environment.etc."zshrc".text = ''
|
|
|
|
# /etc/zshrc: DO NOT EDIT -- this file has been generated automatically.
|
|
|
|
# This file is read for interactive shells.
|
|
|
|
|
|
|
|
# Only execute this file once per shell.
|
|
|
|
if [ -n "$__ETC_ZSHRC_SOURCED" -o -n "$NOSYSZSHRC" ]; then return; fi
|
|
|
|
__ETC_ZSHRC_SOURCED=1
|
|
|
|
|
|
|
|
# history defaults
|
|
|
|
SAVEHIST=2000
|
|
|
|
HISTSIZE=2000
|
|
|
|
HISTFILE=$HOME/.zsh_history
|
2016-11-02 19:04:51 +00:00
|
|
|
|
2016-11-05 15:54:04 +00:00
|
|
|
setopt HIST_IGNORE_DUPS SHARE_HISTORY HIST_FCNTL_LOCK
|
|
|
|
|
2016-11-05 23:08:33 +00:00
|
|
|
export PATH=${config.environment.systemPath}''${PATH:+:$PATH}
|
|
|
|
typeset -U PATH
|
|
|
|
|
2016-11-05 15:54:04 +00:00
|
|
|
${config.system.build.setEnvironment}
|
|
|
|
${config.system.build.setAliases}
|
|
|
|
|
|
|
|
# Read system-wide modifications.
|
|
|
|
if test -f /etc/zshrc.local; then
|
|
|
|
. /etc/zshrc.local
|
|
|
|
fi
|
2016-10-18 21:14:18 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
in {
|
2016-10-19 18:03:17 +00:00
|
|
|
inherit eval;
|
|
|
|
|
2016-11-07 18:59:05 +00:00
|
|
|
allowUnfree = true;
|
|
|
|
|
2016-10-18 21:14:18 +00:00
|
|
|
packageOverrides = self: {
|
|
|
|
|
|
|
|
nixdarwin = eval.config.system.build;
|
|
|
|
|
2016-11-05 23:08:33 +00:00
|
|
|
lnl.zsh = pkgs.runCommand pkgs.zsh.name
|
|
|
|
{ buildInputs = [ pkgs.makeWrapper ]; }
|
|
|
|
''
|
|
|
|
source $stdenv/setup
|
|
|
|
|
|
|
|
mkdir -p $out/bin
|
|
|
|
makeWrapper "${pkgs.zsh}/bin/zsh" "$out/bin/zsh"
|
|
|
|
'';
|
|
|
|
|
|
|
|
lnl.tmux = pkgs.runCommand pkgs.tmux.name
|
|
|
|
{ buildInputs = [ pkgs.makeWrapper ]; }
|
|
|
|
''
|
|
|
|
source $stdenv/setup
|
|
|
|
|
|
|
|
mkdir -p $out/bin
|
|
|
|
makeWrapper "${pkgs.tmux}/bin/tmux" "$out/bin/tmux" \
|
|
|
|
--add-flags -f --add-flags "/run/current-system/etc/tmux.conf" \
|
|
|
|
'';
|
|
|
|
|
2016-10-18 21:14:18 +00:00
|
|
|
lnl.vim = pkgs.vim_configurable.customize {
|
|
|
|
name = "vim";
|
|
|
|
vimrcConfig.customRC = ''
|
|
|
|
set nocompatible
|
|
|
|
filetype plugin indent on
|
|
|
|
syntax on
|
|
|
|
|
|
|
|
colorscheme solarized
|
|
|
|
set bg=dark
|
|
|
|
|
|
|
|
set et sw=2 ts=2
|
|
|
|
set bs=indent,start
|
|
|
|
|
2016-10-19 21:25:15 +00:00
|
|
|
set nowrap
|
2016-10-18 21:14:18 +00:00
|
|
|
set list
|
|
|
|
set listchars=tab:»·,trail:·,extends:⟩,precedes:⟨
|
2016-10-19 18:03:17 +00:00
|
|
|
set fillchars+=vert:\ ,stl:\ ,stlnc:\
|
|
|
|
|
2016-11-04 23:08:20 +00:00
|
|
|
set lazyredraw
|
|
|
|
|
2016-10-19 18:03:17 +00:00
|
|
|
set clipboard=unnamed
|
|
|
|
|
2016-10-20 21:31:53 +00:00
|
|
|
cmap <C-g> <Esc>
|
|
|
|
imap <C-g> <Esc>
|
|
|
|
nmap <C-g> <Esc>
|
|
|
|
omap <C-g> <Esc>
|
|
|
|
vmap <C-g> <Esc>
|
2016-10-19 18:03:17 +00:00
|
|
|
|
2016-11-01 20:25:22 +00:00
|
|
|
vmap s S
|
|
|
|
|
|
|
|
cnoremap %% <C-r>=expand('%:h') . '/'<CR>
|
|
|
|
|
2016-10-19 18:03:17 +00:00
|
|
|
set hlsearch
|
2016-11-01 20:25:22 +00:00
|
|
|
nnoremap // :nohlsearch<CR>
|
2016-10-19 18:03:17 +00:00
|
|
|
|
2016-11-01 20:25:22 +00:00
|
|
|
let mapleader = ' '
|
|
|
|
nnoremap <Leader>p :FZF<CR>
|
|
|
|
nnoremap <silent> <Leader>e :exe 'FZF ' . expand('%:h')<CR>
|
2016-11-02 19:04:51 +00:00
|
|
|
|
|
|
|
source $HOME/.vimrc.local
|
2016-10-18 21:14:18 +00:00
|
|
|
'';
|
2016-11-03 19:40:29 +00:00
|
|
|
vimrcConfig.vam.knownPlugins = with pkgs.vimUtils; (pkgs.vimPlugins // {
|
|
|
|
vim-nix = buildVimPluginFrom2Nix {
|
|
|
|
name = "vim-nix-unstable";
|
|
|
|
src = ../vim-nix;
|
|
|
|
};
|
|
|
|
});
|
2016-10-18 21:14:18 +00:00
|
|
|
vimrcConfig.vam.pluginDictionaries = [
|
2016-10-21 18:56:23 +00:00
|
|
|
{ names = [ "fzfWrapper" "youcompleteme" "fugitive" "surround" "vim-nix" "colors-solarized" ]; }
|
2016-10-18 21:14:18 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|