1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-06 08:47:00 +00:00
nix-darwin/config.nix

266 lines
8.1 KiB
Nix
Raw Normal View History

{ pkgs ? import <nixpkgs> {} }:
2016-10-18 23:14:18 +02:00
let
eval = pkgs.lib.evalModules
{ check = true;
args = { pkgs = import <nixpkgs> {}; };
modules =
[ config
2016-11-06 22:38:31 +01:00
./modules/system
./modules/system/activation-scripts.nix
./modules/system/defaults
./modules/system/etc.nix
2016-12-01 23:56:20 +01:00
./modules/system/launchd.nix
2016-11-06 22:38:31 +01:00
./modules/environment
2016-11-01 21:25:22 +01:00
./modules/launchd
2016-11-06 22:38:31 +01:00
./modules/programs/tmux.nix
2016-10-18 23:14:18 +02:00
];
};
config =
{ config, lib, pkgs, ... }:
2016-10-18 23:14:18 +02:00
{
2016-10-19 20:03:17 +02:00
environment.systemPackages =
[ pkgs.lnl.zsh
pkgs.lnl.tmux
pkgs.lnl.vim
2016-10-19 20:03:17 +02:00
pkgs.curl
pkgs.fzf
pkgs.gettext
pkgs.git
pkgs.jq
pkgs.silver-searcher
pkgs.nix-repl
pkgs.nox
];
2016-10-18 23:14:18 +02:00
2016-12-02 23:54:46 +01:00
launchd.agents.activate-system =
{ serviceConfig.Program = "${config.system.build.activate}";
serviceConfig.RunAtLoad = true;
};
2016-11-03 20:40:29 +01:00
launchd.daemons.nix-daemon =
2016-12-02 23:54:46 +01:00
{ serviceConfig.Program = "/nix/var/nix/profiles/default/bin/nix-daemon";
2016-11-03 20:40:29 +01:00
serviceConfig.KeepAlive = true;
serviceConfig.ProcessType = "Background";
serviceConfig.SoftResourceLimits.NumberOfFiles = 4096;
2016-12-02 23:54:46 +01:00
serviceConfig.EnvironmentVariables.TMPDIR = "/nix/tmp";
serviceConfig.EnvironmentVariables.SSL_CERT_FILE = "/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt";
2016-11-30 23:49:58 +01:00
serviceConfig.EnvironmentVariables.NIX_BUILD_HOOK="/nix/var/nix/profiles/default/libexec/nix/build-remote.pl";
serviceConfig.EnvironmentVariables.NIX_CURRENT_LOAD="/nix/tmp/current-load";
serviceConfig.EnvironmentVariables.NIX_REMOTE_SYSTEMS="/etc/nix/machines";
2016-11-03 20:40:29 +01:00
};
system.defaults.global.InitialKeyRepeat = 10;
system.defaults.global.KeyRepeat = 1;
programs.tmux.loginShell = "${pkgs.lnl.zsh}/bin/zsh -l";
2016-11-03 20:40:29 +01:00
programs.tmux.enableSensible = true;
programs.tmux.enableMouse = true;
2016-11-07 22:47:17 +01:00
programs.tmux.enableFzf = true;
2016-11-03 20:40:29 +01:00
programs.tmux.enableVim = true;
2016-11-06 23:38:42 +01:00
programs.tmux.tmuxConfig = ''
bind 0 set status
set -g status-bg black
set -g status-fg white
'';
2016-10-21 20:56:23 +02:00
environment.variables.EDITOR = "vim";
environment.variables.HOMEBREW_CASK_OPTS = "--appdir=/Applications/cask";
2016-10-18 23:14:18 +02:00
2016-11-03 23:28:33 +01: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 20:56:23 +02:00
environment.shellAliases.l = "ls -lh";
environment.shellAliases.ls = "ls -G";
2016-11-30 23:49:58 +01:00
environment.shellAliases.g = "git log --oneline --max-count 42";
environment.shellAliases.gl = "git log --graph --oneline";
environment.shellAliases.gd = "git diff --minimal --patch";
2016-10-21 20:56:23 +02: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 21:25:22 +01:00
# Only execute this file once per shell.
if [ -n "$__ETC_ZPROFILE_SOURCED" ]; then return; fi
__ETC_ZPROFILE_SOURCED=1
2016-11-03 20:40:29 +01:00
2016-10-18 23:14:18 +02:00
autoload -U promptinit && promptinit
PROMPT='%B%(?..%? )%b '
RPROMPT='%F{green}%~%f'
2016-10-18 23:14:18 +02:00
bindkey -e
2016-10-18 23:14:18 +02:00
setopt autocd
2016-11-02 20:13:01 +01:00
autoload -U compinit && compinit
2016-10-18 23:14:18 +02:00
2016-11-16 23:19:49 +01: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
}
nixdarwin-rebuild () {
2016-11-16 23:19:49 +01:00
cmd=$1
shift
case $cmd in
2016-12-02 23:54:46 +01:00
'build') nix-build '<nixpkgs>' -A nixdarwin.toplevel "$@" ;;
2016-11-16 23:19:49 +01:00
'repl') nix-repl "$HOME/.nixpkgs/config.nix" "$@" ;;
'shell') nix-shell '<nixpkgs>' -p nixdarwin.toplevel --run '${pkgs.lnl.zsh}/bin/zsh -l' "$@" ;;
2016-12-02 23:03:42 +01:00
'switch') sudo nix-env --profile /nix/var/nix/profiles/system --set $(nix-build --no-out-link '<nixpkgs>' -A nixdarwin.toplevel) && nix-shell '<nixpkgs>' -A nixdarwin.toplevel --run 'sudo $out/activate' && exec ${pkgs.lnl.zsh}/bin/zsh -l ;;
2016-11-16 23:19:49 +01:00
esac
}
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 20:40:29 +01: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 23:14:18 +02: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 20:04:51 +01:00
2016-11-30 23:49:58 +01:00
export NIX_PATH=nixpkgs=$HOME/.nix-defexpr/nixpkgs:$NIX_PATH/.nix-defexpr/channels_root
2016-11-02 20:04:51 +01: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 23:14:18 +02:00
# Read system-wide modifications.
if test -f /etc/zshenv.local; then
. /etc/zshenv.local
fi
'';
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 20:04:51 +01:00
setopt HIST_IGNORE_DUPS SHARE_HISTORY HIST_FCNTL_LOCK
export PATH=${config.environment.systemPath}''${PATH:+:$PATH}
typeset -U PATH
${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 23:14:18 +02:00
'';
};
in {
2016-10-19 20:03:17 +02:00
inherit eval;
2016-11-07 19:59:05 +01:00
allowUnfree = true;
2016-10-18 23:14:18 +02:00
packageOverrides = self: {
nixdarwin = eval.config.system.build;
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 23:14:18 +02: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
set nowrap
2016-10-18 23:14:18 +02:00
set list
set listchars=tab:»·,trail:·,extends:,precedes:
2016-10-19 20:03:17 +02:00
set fillchars+=vert:\ ,stl:\ ,stlnc:\
2016-11-05 00:08:20 +01:00
set lazyredraw
2016-10-19 20:03:17 +02:00
set clipboard=unnamed
2016-11-01 21:25:22 +01:00
vmap s S
cnoremap %% <C-r>=expand('%:h') . '/'<CR>
2016-10-19 20:03:17 +02:00
set hlsearch
2016-11-01 21:25:22 +01:00
nnoremap // :nohlsearch<CR>
2016-10-19 20:03:17 +02:00
2016-11-01 21:25:22 +01:00
let mapleader = ' '
nnoremap <Leader>p :FZF<CR>
nnoremap <silent> <Leader>e :exe 'FZF ' . expand('%:h')<CR>
2016-11-02 20:04:51 +01:00
source $HOME/.vimrc.local
2016-10-18 23:14:18 +02:00
'';
2016-11-03 20:40:29 +01:00
vimrcConfig.vam.knownPlugins = with pkgs.vimUtils; (pkgs.vimPlugins // {
vim-nix = buildVimPluginFrom2Nix {
name = "vim-nix-unstable";
src = ../vim-nix;
};
});
2016-10-18 23:14:18 +02:00
vimrcConfig.vam.pluginDictionaries = [
2016-10-21 20:56:23 +02:00
{ names = [ "fzfWrapper" "youcompleteme" "fugitive" "surround" "vim-nix" "colors-solarized" ]; }
2016-10-18 23:14:18 +02:00
];
};
};
}