aboutsummaryrefslogtreecommitdiff
path: root/nixos/configuration.nix
blob: 08f8a38a13e87b2c0e8b808b3baffc19e4932115 (plain) (blame)
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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
{ config, pkgs, ... }:

let localConfiguration = import /etc/nixos/local-configuration.nix;
in
{
  imports =
    [ # Include the results of the hardware scan.
      /etc/nixos/hardware-configuration.nix
    ];

  # Use the systemd-boot EFI boot loader.
  boot = {
    loader = {
      systemd-boot.enable = true;
      efi.canTouchEfiVariables = true;
    };
    initrd = {
      luks.devices = [
        {
          name = "root";
          device = localConfiguration.luksDevice;
          preLVM = true;
        }
      ];
    };
  };

  hardware = {
    bluetooth.enable = true;
    pulseaudio = {
      package = pkgs.pulseaudioFull;
      enable = true;
    };
  };

  networking.hostName = localConfiguration.hostName;
  networking.networkmanager.enable = true;

  # Auto-upgrade channel
  # https://nixos.org/nixos/manual/index.html#idm140737316795120
  system.autoUpgrade.enable = true;

  nix.gc = {
    automatic = true;
    dates = "03:15"; # change to hour?
  };

  # Select internationalisation properties.
  i18n = {
    consoleFont = "Lat2-Terminus16";
    consoleKeyMap = "br-abnt2";
    defaultLocale = "en_US.UTF-8";
  };

  # Set your time zone.
  time.timeZone = "America/Sao_Paulo";

  virtualisation.docker.enable = true;
  virtualisation.virtualbox.host.enable = true;

  fonts.fonts = with pkgs; [
    source-code-pro
    fira-code
    fira-mono
    fira-code-symbols
    freefont_ttf
  ];


  environment.systemPackages =
    let
      # pkgsUnstable = import(fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz) {};
      # pkgs-18-03 = import(pkgs.fetchzip {
      #   url = "https://github.com/NixOS/nixpkgs/archive/18.03.zip";
      #   sha256 = "0hk4y2vkgm1qadpsm4b0q1vxq889jhxzjx3ragybrlwwg54mzp4f";
      # }) {};

      timidityWithEvenMoreFormats = with pkgs; timidity.overrideAttrs (oldAttrs: {
        configureFlags = oldAttrs.configureFlags ++ [ "--enable-audio=vorbis,flac" ];
        buildInputs = oldAttrs.buildInputs ++ [ libogg libvorbis flac ];
      });

      # See https://github.com/NixOS/nixpkgs/issues/53938#issuecomment-454158967
      untested-quodlibet-full = with pkgs; quodlibet-full.overrideAttrs (oldAttrs: {
        doInstallCheck = false;
        doCheck = false;
      });

      # https://github.com/nixos/nixpkgs/blob/0d202221f98e500f1df79112dc464d013eefcdae/pkgs/development/web/nodejs/v10.nix#L4
    in with pkgs; [
      ## Personal data tools

      gitAndTools.git-open
      gitAndTools.gitFull
      gitAndTools.diff-so-fancy
      gitAndTools.git-annex
      gitAndTools.gitRemoteGcrypt
      gitAndTools.git-dit
      gitAndTools.git-secrets
      git-crypt
      git-lfs
      gnupg
      mr
      nextcloud-client
      owncloud-client
      borgbackup
      git-sizer


      ## CLI tools

      bash
      bash-completion
      nix-bash-completions
      youtube-dl
      wget
      vim
      thefuck
      tmux
      tmuxinator
      sox                         # =play=
      gettext                     # =envsubst=
      ag
      gnugrep
      ack
      htop
      rlwrap
      awscli
      jq
      openvpn
      xclip
      bc                          # binary calculator used in nucli
      sassc
      watchman
      ipfs
      gnumake
      gcc
      psmisc                      # =killall=
      xorg.xkill
      autojump
      bfg-repo-cleaner
      pwgen
      gksu                        # =gksudo=
      gnome2.GConf                # https://github.com/NixOS/nixpkgs/issues/15978
      lsof
      pciutils
      python27Packages.pywatchman # =watchman-wait=
      libressl
      tree
      i2p
      libxml2                     # =xmllint=
      unzip                       # used by extract bash function and Clojure go-to-source
      odt2txt                     # used to diff odf files
      feh                         # simplistic image viewer
      nixUnstable                 # =nix=
      zip
      zlib
      redis
      alsaUtils                   # for xmonad volume commands
      multimarkdown               # =markdown=
      pup                         # command-line HTML parsing https://github.com/ericchiang/pup
      binutils-unwrapped          # =ar= command for cargo build
      nssTools                    # =pk12util=
      gitAndTools.hub             # GitHub helper
      insomnia
      bind                        # =dig=
      file
      gitlab-runner
      sshpass
      zathura                    # for viewing Emacs PDF files
      nvi
      cacert
      gtypist
      pandoc
      inotify-tools
      fzf
      ncdu
      fd
      nnn
      python36Packages.python-slugify
      moreutils                  # =vipe=
      bazel
      graphviz                   # =dot= and others

      diffoscope                 #
      poppler_utils              # used by diffoscope for comparing PDF files
      pdftk                      #

      gnome3.libgnome-keyring
      gnome3.gnome-keyring


      ## Mail

      notmuch
      isync


      ## Spell checking

      (aspellWithDicts (ps : with ps; [ en eo fr pt_BR ]))
      languagetool


      ## NixOS

      pypi2nix
      bundix


      ## Music

      texlive.combined.scheme-full
      lilypond
      python36Packages.python-ly
      lame
      frescobaldi
      timidityWithEvenMoreFormats


      ## Programming tools

      sbcl
      stack
      leiningen
      python3
      python
      yarn
      elixir
      openjdk
      solc
      bundler
      rustup
      cargo
      clojure    # =clj=
      visualvm   # JVM profiling tool
      ant
      maven
      go_bootstrap
      rakudo
      bats
      ledger
      newsboat
      perl
      dhall
      dhall-json
      nodePackages.node2nix
      shellcheck
      # (haskell.lib.justStaticExecutables haskellPackages.github-backup)
      rustracer
      xsel
      buku
      nodejs-10_x


      ## Containers and VMs

      packer
      docker_compose
      docker-machine
      vagrant
      kubernetes
      ansible
      qemu
      gnome3.gtk-vnc


      ## xmonad

      xorg.xmodmap
      trayer
      dmenu
      escrotum
      xorg.xbacklight
      networkmanagerapplet
      playerctl
      lightdm
      fvwm                         # =xpmroot=
      haskellPackages.xmobar
      haskellPackages.yeganesh
      arandr


      ## GUI programs

      untested-quodlibet-full
      inkscape
      calibre
      cozy
      rhythmbox
      gpodder
      firefox
      emacs
      tdesktop
      vlc
      keepassx2-http
      yubioath-desktop
      # tor-browser-bundle-bin
      transmission_gtk
      libreoffice
      android-studio
      # androidsdk_extras
      # androidndk
      patchwork-classic
      # gnome3.gpaste


      ## Cryptocururencies

      electrum
      zbar          # for on-screen QR Code scanning
      monero


      ## nu specific packages

      sshuttle
      slack
      chromium
    ];

  nixpkgs.config = {
    android_sdk.accept_license = true;
    allowUnfree = true; # Require for slack (unfree) derivation
  };


  # Look at
  # https://www.vivaolinux.com.br/topico/Off-Code-Cafe/Me-apresente-sua-distro

  programs = {
    bash.enableCompletion = true;
  };

  services = {
    cron.enable = true;
    # We can see the actual generated crontab at /etc/crontab
    cron.systemCronJobs = [
      # Sync emails with mbsync every hour
      "0 * * * * andreh /home/andreh/dev/libre/dotfiles/scripts/mail.sh -s"

      # Refresh local RSS files every hour
      "0 * * * * andreh /home/andreh/dev/libre/dotfiles/scripts/atom.sh"

      # Make read-only copy of TODOs.org every hour
      # "0 * * * * andreh /home/andreh/dev/libre/dotfiles/scripts/cp-todos.sh -s"
    ];

    xserver = {
      enable = true;
      layout = "br";
      xkbOptions = "caps:swapescape";

      windowManager.default = "xmonad";
      windowManager.xmonad = {
        enable = true;
        enableContribAndExtras = true;
      };
      desktopManager = {
        default = "none";
        xterm.enable = false;
        gnome3.enable = true;
      };
      displayManager = {
        lightdm.enable = true;

        # The config inception was inspired by:
        # http://ubuntuforum-br.org/index.php?topic=13784.0
        # Lambda symbol name taken from:
        # http://wiki.linuxquestions.org/wiki/List_of_Keysyms_Recognised_by_Xmodmap
        # To test a keycode:
        # xmodmap -e 'keycode 118 = bar Greek_lamda'
        sessionCommands = ''
          ${pkgs.haskellPackages.xmobar}/bin/xmobar ~/.xmobarrc &
          ${pkgs.fvwm}/bin/xpmroot ~/ownCloud/Images/emotion.png &
        '';
      };
    };

    gnome3 = {
      gnome-keyring.enable = true;
      seahorse.enable = true;
      gnome-terminal-server.enable = true;
      # gpaste.enable = true;                # clipboard manager
      tracker.enable = true;
      sushi.enable = true;                 # nautilus previewer
      gnome-online-accounts.enable = true;
      gnome-documents.enable = true;
      evolution-data-server.enable = true;
      gvfs.enable = true;
    };

    pcscd.enable = true;                   # required by yubioath

    # Taken from:
    # https://unix.stackexchange.com/questions/378711/how-do-i-configure-postgress-authorization-settings-in-nixos
    postgresql = {
      enable = true;
      package = pkgs.postgresql;
      authentication = pkgs.lib.mkForce ''
        # Generated file; do not edit!
        # TYPE  DATABASE        USER            ADDRESS                 METHOD
        local   all             all                                     trust
        host    all             all             127.0.0.1/32            trust
        host    all             all             ::1/128                 trust
      '';
    };

    # https://nixos.org/nixos/options.html#ipfs
    ipfs = {
      enable = false;
      enableGC = false;
      autoMount = false;
    };
  };

  security = {
    pam.services.lightdm.enableGnomeKeyring = true;
    sudo.enable = true;
    hideProcessInformation = false;
  };

  users = {
    mutableUsers = false;

    extraUsers =
      let
        andrehUser =  {
          andreh = {
            isNormalUser = true;
            uid = 1000;
            description = "EuAndreh";
            extraGroups = [ "wheel" "networkmanager" "docker" ];
            passwordFile = "/home/andreh/dev/libre/dotfiles/encrypted/password-hash.txt";
          };
        };
        # From the Guix manual:
        # https://www.gnu.org/software/guix/manual/en/html_node/Build-Environment-Setup.html#Build-Environment-Setup
        buildUser = (i:
          {
            "guixbuilder${i}" = {                   # guixbuilder$i
              group = "guixbuild";                  # -g guixbuild
              extraGroups = ["guixbuild"];          # -G guixbuild
              home = "/var/empty";                  # -d /var/empty
              shell = pkgs.nologin;                 # -s `which nologin`
              description = "Guix build user ${i}"; # -c "Guix buid user $i"
              isSystemUser = true;                  # --system
            };
          }
        );
      in
        # merge all users
        pkgs.lib.fold (str: acc: acc // buildUser str)
                      andrehUser
                      # for i in `seq -w 1 10`
                      (map (pkgs.lib.fixedWidthNumber 2) (builtins.genList (n: n+1) 10));

    extraGroups.guixbuild = {
      name = "guixbuild";
    };
  };

  systemd = {
    services = {
      # Derived from Guix guix-daemon.service.in
      # https://git.savannah.gnu.org/cgit/guix.git/tree/etc/guix-daemon.service.in?id=00c86a888488b16ce30634d3a3a9d871ed6734a2
     guix-daemon = {
       enable = false;
       description = "Build daemon for GNU Guix";
       serviceConfig = {
         ExecStart = "/var/guix/profiles/per-user/root/guix-profile/bin/guix-daemon --build-users-group=guixbuild";
         Environment="GUIX_LOCPATH=/root/.guix-profile/lib/locale";
         RemainAfterExit="yes";
         StandardOutput="syslog";
         StandardError="syslog";
         TaskMax= "8192";
       };
       wantedBy = [ "multi-user.target" ];
     };
    };
  };

  # This value determines the NixOS release with which your system is to be
  # compatible, in order to avoid breaking some software such as database
  # servers. You should change this only after NixOS release notes say you
  # should.
  system.stateVersion = "19.03"; # Did you read the comment?
}