summaryrefslogtreecommitdiff
path: root/common.nix
blob: 23c5244a9c03cce8ba46ad194c04547bf2fb70d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
{ pkgs, ... }:

let
  homedir = builtins.getEnv "HOME";
  locale = "en_US.UTF-8";
  gpgid = "D09299626FA78AF8";
  gitCommitTemplate = ./git-commit-template;
in
{
  home = {
    packages = import ./packages.nix { inherit pkgs; };
    sessionVariables = {
      GPGID = gpgid;
      EDITOR = "emacsclient";
      LANG = locale;
      LANGUAGE = locale;
      #LC_ALL = locale;
      PATH = "${homedir}/bin:${homedir}/.cabal/bin:${homedir}/.local/bin:$PATH";
      PAGER = "less";
      LEDGER_FILE = "${homedir}/.hledger.journal";
      XTERM_LOCALE = locale;
      LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
    };
    keyboard.options = [ "caps:ctrl_modifier" ];
    file = {
      mutt = {
        text = (builtins.readFile ./muttrc) +
          (builtins.readFile ./mutt/solarized.muttrc);
        target = ".muttrc";
      };
      mailcap = {
        source = ./mailcap;
        target = ".mailcap";
      };
      tmux = {
        source = ./tmux;
        target = ".tmux.conf";
      };
    };
  };

  programs = {
    home-manager = {
      enable = true;
      path = "${homedir}/cfg/home-manager";
    };

    ssh = {
      enable = true;
      forwardAgent = true;
      matchBlocks = {
        hidor-kahih = {
          hostname = "home.simatime.com";
          user = "ben";
          identityFile = [ "${homedir}/.ssh/hidor-kahih" ];
          identitiesOnly = true;
        };
        nutin-madaj = {
          hostname = "simatime.com";
          user = "ben";
          identityFile = [ "${homedir}/.ssh/id_rsa" ];
          identitiesOnly = true;
        };
      };
    };

    direnv = {
      enable = true;
    };

    skim = {
      enable = true;
      enableBashIntegration = true;
    };

    vim = {
      enable = true;
      plugins = [
        "ctrlp"
        "fugitive"
        "editorconfig-vim"
        "surround"
        "vim-colorschemes"
      ];
      extraConfig = builtins.readFile ./vimrc;
    };

    git = {
      enable = true;
      userName  = "Ben Sima";
      userEmail = "ben@bsima.me";
      ignores = [ "*~" "*.swp" ];
      package = pkgs.gitAndTools.gitFull;
      signing = {
        key = gpgid;
        signByDefault = true;
      };
      aliases = {
        authors = "shortlog -s -n";
      };
      extraConfig = ''
        [push]
        default = simple

        [commit]
        template = ${gitCommitTemplate}

        [sendemail]
        smtpuser = ben@bsima.me
        smptserverport = 587
        smptserver = mail.bsima.me
        chainreplyto = false
        composeencoding = UTF-8
      '';
    };

    bash = {
      enable = true;
      initExtra = ''
        DIR=~/.nix-profile/etc/profile.d
        [[ -f "$DIR/nix.sh" ]] && . "$DIR/nix.sh"
        [[ -f "$DIR/hm-session-vars.sh" ]] && . "$DIR/hm-session-vars.sh"
        function cd() {
          builtin cd "$@" && ls
        }
      '';
      shellAliases = {
        #z = "fasd_cd -d"; # cd, same functionality as j in autojump
        #zz = "fasd_cd -d -i"; # cd with interactive selection
          a = "fasd -a"; # any
          add = "git add --ignore-removal";
          ci = "git commit";
          d = "fasd -d"; # directory
          day = "date +%a";
          ddate = "date +%Y.%m.%d";
          dday = "date +%A";
          et = "emacs -nw"; # emacs in a terminal
        f = "fasd -f"; # file
        fetch = "git fetch";
        g = "grep -in";
        ga = "git add -A";
        gb = "git branch";
        gc = "git commit";
        gca = "git commit -a";
        gco = "git checkout";
        gd = "git diff";
        gl = "git pull --prune";
        glog = ''git log --decorate --all --graph --pretty=format:"%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset" --abbrev-commit --date=relative'';
        gp = "git push origin HEAD";
        gs = "git status -sb";
        hs = "home-manager switch";
        ll = "ls -l";
        pull = "git pull";
        push = "git push";
        rm = "rm -i";
        s = "fasd -si"; # show / search / select
        sd = "fasd -sid"; # interactive directory selection
        sf = "fasd -sif"; # interactive file selection
        showpath = "echo $PATH | sed 's/:/\n/g'";
        tdate = "date +%Y.%m.%d..%H.%M";
        ttime = "date +%H.%M";
        typeless = "history | tail -n 20000 | sed 's/.*  //' | sort | uniq -c | sort -g | tail -n 100";
        v = "vim";
        "v." = "vim .";
        vs = "vim $(sk -m)";
        vk = "vim $(sk -m)";
        vimdiff = "vim -d";
      };
    };

    emacs = {
      enable = true;
      extraPackages = epkgs: import ./emacs-packages.nix { inherit epkgs; };
    };
  };
}