summaryrefslogtreecommitdiff
path: root/linux.nix
blob: 9201647faf8cac9da3fd6417fe8d90c7a760c04c (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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
{ pkgs, lib, ... }:

let
  homedir = builtins.getEnv "HOME";
  gitCommitTemplate = ./git-commit-template;
  gpgid = "D09299626FA78AF8";
  cmdtree = pkgs.stdenv.mkDerivation {
    name = "cmdtree";
    src = fetchGit {
      url = "https://git.sr.ht/~jb55/cmdtree";
      ref = "master";
      rev = "5606078e8fa02462f0208d9f9cad98c7673812e6";
    };
    buildPhase = ''
      cp ${./cfg.def.h} ./cfg.def.h
      make
    '';
    installPhase = ''
      mkdir -p $out/bin
      cp ./cmdtree $out/bin
    '';
    buildInputs = [ pkgs.xorg.libX11 pkgs.xorg.libXft ];
  };

  base16-scheme = "spacemacs";
  base16 = pkgs.stdenv.mkDerivation {
    name = "base16-builder";
    src = builtins.fetchTarball {
      url = "https://github.com/auduchinok/base16-builder/archive/51e3ad4d447fc3f1f539d0bfe33c851728fb6b5f.tar.gz";
      sha256 = "1qir689h38c6jr7fbbqbc3029544zgv41lrrqdcq26kcwxcwjrz1";
    };
    nativeBuildInputs = [pkgs.ruby];
    buildPhase = "${pkgs.ruby}/bin/ruby base16 -s schemes/${base16-scheme}.yml";
    installPhase = ''
      mkdir -p $out
      cp -r output/* $out
    '';
  };
  theme = lib.removeSuffix "\n" (builtins.readFile "${homedir}/.local/share/xtheme");
  xresources = "${base16}/xresources/base16-${base16-scheme}.${theme}.xresources";

  colors = { # derived from spacemacs
    "dark" = {
      highlight = "#5d4d7a";
      background = "#292b2e";
      foreground = "#b2b2b2";
    };
    "light" = {
      highlight = "#67b11d";
      background = "#f6f1e1";
      foreground = "#655370";
    };
  };
in
{
  imports = [ ./common.nix ./email.nix ];
  home = {
    keyboard.options = [ "caps:ctrl_modifier" ];
    file = {
      mutt = {
        text = (builtins.readFile ./muttrc) +
          (builtins.readFile ./mutt/solarized.muttrc);
        target = ".muttrc";
      };
      mailcap = {
        source = ./mailcap;
        target = ".mailcap";
      };
    };

    packages = with pkgs; [

    beets
    bind
    blueman
    cmdtree
    dict
    dmenu
    dolphin
    exercism
    feh
    flameshot
    glibcLocales # rofi locale fix -- https://github.com/rycee/home-manager/issues/354#issuecomment-415914278
    gnumake
    gnupg
    gopher
    hledger
    hledger-ui
    hledger-web
    keybase-gui
    ledger
    libnotify
    minitube
    mononoki
    mplayer
    msmtp
    muchsync
    neomutt
    obs-studio
    pandoc
    pasystray
    pavucontrol
    pdftk
    pinentry
    qutebrowser
    sqlite
    tdesktop
    terminus
    texlive.combined.scheme-full
    vlc
    xorg.xmodmap
    xournal
    xterm
    yank
    youtube-dl
    zathura

    # languages i regularly use
    clojure
    ghc
    guile
    ocaml
    python3
    lispPackages.quicklisp
    sbcl
    ];
  };
  fonts.fontconfig.enable = true;

  xresources = {
    properties = {
      "XTerm*font" = "-*-FiraMono-medium-r-normal--18-*-*-*-*-*-iso10646-1";
      "XTerm*faceName" = "FireMono";
      "XTerm*faceSize" = "10";
      "XTerm*termName" = "xterm-256color";
      "XTerm*metaSendsEscape" = true;
      "XTerm*utf8" = true;
      #"Xautolock.time:" = 1;
      #"Xautolock.locker:" = "xlock";
      #"Xautolock.corners:" = "+0-0";
      #"Xautolock.cornerdelay:" = 3;
      #"Xautolock.notify:" = 30;
      #"Xautolock.notifier:" = "notify-send -u critical -t 10000 -- 'Locking screen in 30 seconds'";
    };
    extraConfig = builtins.readFile(xresources);
  };

  services = {
    emacs.enable = true;
    network-manager-applet.enable = true;

    kbfs.enable = true;
    keybase.enable = true;

    polybar = {
      # https://github.com/0x746866/dots/blob/master/polybar/config
      enable = true;
      config = {
        "bar/top" = {
          background = colors."${theme}".background;
          font-0 = "FiraSans:size=16";
          font-1 = "Font Awesome 5:pixelsize=11;1";
          font-2 = "MaterialIcons:size=10:antialias=false;2";
          foreground = colors."${theme}".foreground;
          height = "30";
          module-margin = 1;
          modules-center = "date";
          modules-left = "volume-bar";
          modules-right = [ "battery" "cpu" "mem" "temp" ];
          monitor = "\${env:MONITOR:HDMI-1}";
          monitor-fallback = "\${env:MONITOR:eDP-1}";
          radius = 0;
          separator = "|";
          tray-background = colors."${theme}".background;
          tray-detached = false;
          tray-maxsize = 16;
          tray-offset-x = 0;
          tray-offset-y = 0;
          tray-padding = 0;
          tray-position = "right";
          tray-scale = 1;
          width = "100%";
        };
        "module/date" = {
          type = "internal/date";
          internal = 5;
          date = "%Y.%m.%d";
          time = "%H.%M";
          label = "%date%..%time%";
        };
        "module/battery" = {
          type = "internal/battery";
          battery = "BAT0";
          adapter = "AC";
          full-at = 99;
        };
        "module/volume-bar" = {
          type = "internal/volume";
          bar-volume-font = 2;
          bar-volume-width = 9;
          format-volume = "<label-volume><bar-volume>";
          label-volume = " .) ";
          label-muted = " .) mute";
          label-volume-foreground = colors.${theme}.foreground;
          format-muted-foreground = colors.${theme}.foreground;
          bar-volume-foreground-0 = colors.${theme}.foreground;
          bar-volume-foreground-1 = colors.${theme}.foreground;
          bar-volume-foreground-2 = colors.${theme}.foreground;
          bar-volume-foreground-3 = colors.${theme}.foreground;
          bar-volume-foreground-4 = colors.${theme}.foreground;
          bar-volume-foreground-5 = colors.${theme}.foreground;
          bar-volume-foreground-6 = colors.${theme}.foreground;
          bar-volume-gradient = true;
          bar-volume-indicator = "•";
          bar-volume-fill = "•";
          bar-volume-empty = "·";
          bar-volume-empty-foreground = colors.${theme}.foreground;
        };
        "module/ethernet" = {
          type = "internal/network";
          interface = "enp1s0";
          label-connected = "eth up: %upspeed:9% down: %downspeed%";
          label-disconnected = "no eth";
        };
        "module/wifi" = {
          type = "internal/network";
          interface = "wlan1";
          label-connected = "wifi up: %upspeed% down: %downspeed%";
          label-disconnected = "no wifi";
        };
        "module/cpu" = {
          type = "internal/cpu";
          interval = 3;
          format-padding = 1;
          format = "<label> <ramp-coreload>";
          label = " %percentage:2%%";
          ramp-coreload-0 = "▂";
          ramp-coreload-1 = "▃";
          ramp-coreload-2 = "▄";
          ramp-coreload-3 = "▅";
          ramp-coreload-4 = "▆";
          ramp-coreload-5 = "▇";
          ramp-coreload-0-foreground = colors.${theme}.foreground;
          ramp-coreload-1-foreground = colors.${theme}.foreground;
          ramp-coreload-2-foreground = colors.${theme}.foreground;
          ramp-coreload-3-foreground = colors.${theme}.foreground;
          ramp-coreload-4-foreground = colors.${theme}.foreground;
          ramp-coreload-5-foreground = colors.${theme}.highlight;
        };
        "module/temp" = {
          type = "internal/temperature";
          interval = 3;
          thermal-zone = 0;
          warn-temperature = 70;
          format = "<ramp> <label>";
          format-padding = 1;
          label = "%temperature-c%";
          ramp-0 = "_";
          ramp-1 = ".";
          ramp-2 = ":";
          ramp-3 = "|";
          ramp-4 = "!!";
          ramp-0-foreground = colors.${theme}.foreground;
          ramp-1-foreground = colors.${theme}.foreground;
          ramp-2-foreground = colors.${theme}.foreground;
          ramp-3-foreground = colors.${theme}.foreground;
          ramp-4-foreground = colors.${theme}.highlight;
          format-warn = "<label-warn>";
          label-warn = "  %temperature-c%";
          label-warn-padding = 1;
          label-warn-foreground = colors.${theme}.highlight;
        };
        "module/mem" = {
          type = "internal/memory";
          interval = 3;
          format = "<label>";
          label-padding = 1;
          label = " |[]| %percentage_used%%";
        };
      };
      script = ''
        polybar top &
      '';
    };

    dunst = {
      enable = true;
      settings = {
          global = {
          geometry = "320x5-10+30";
          transparency = 0;
          frame_color = colors."${theme}".highlight;
          frame_width = 3; # same as xmonad border
          separator_color = "frame";
          font = "Fira Sans";
          background = colors."${theme}".background;
          foreground = colors."${theme}".foreground;
          padding = 10;
          horizontal_padding = 10;
          word_wrap = "yes";
          markup = "full";
          format = "<b>%s</b>\\n%b\\n";
        };

        urgency_normal = {
          background = colors."${theme}".background;
          foreground = colors."${theme}".foreground;
          timeout = 10;
        };
      };
    };

    redshift = {
      enable = true;
      latitude = "33.044444";
      longitude = "-117.271667";
      temperature = {
        day = 6000;
        night = 3500;
      };
    };

    gpg-agent = {
      enable = true;
      enableScDaemon = true;
      defaultCacheTtl = 72000;
      maxCacheTtl = 7200;
      enableSshSupport = false;
      enableExtraSocket = true;
      verbose = true;
      extraConfig = ''
        allow-emacs-pinentry
        # StreamLocalBindUnlink yes
        # RemoteForward /home/ben/.gnupg/S.gpg-agent /home/ben/.gnupg/S.gpg-agent.extra
      '';
    };
  };

  xsession = {
    enable = true;
    pointerCursor = {
      package = pkgs.vanilla-dmz;
      name = "Vanilla-DMZ";
    };
    windowManager = {
      xmonad = {
        enable = true;
        extraPackages = hpkgs: [
          hpkgs.xmonad-contrib
          hpkgs.xmonad-extras
          hpkgs.monad-logger
          #hpkgs.taffybar
        ];
        enableContribAndExtras = true;
        config = ./xmonad.hs;
      };
    };
  };

  programs = {
    git = {
      enable = true;
      userName  = "Ben Sima";
      userEmail = "ben@bsima.me";
      ignores = [ "*~" "*.swp" ];
      package = pkgs.gitAndTools.gitFull;
      signing = {
        key = gpgid;
        signByDefault = false;
      };
      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
      '';
    };

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

    firefox = {
      enable = true;
    };

    chromium = {
      enable = true;
    };

    rofi = {
      enable = true;
    };
  };
}