about summary refs log tree commit diff
path: root/machines/profpatsch/base.nix
blob: e0b2fd7dafaaf8412c22c211ae73dd7f0bf2817a (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
# Base config shared by all machines
{ pkgs, config, lib, ... }:

let
  # TODO: inject into every config from outside
  myLib  = import ./lib.nix  { inherit pkgs lib; };
  myPkgs = import ./pkgs.nix { inherit pkgs lib myLib; };

in
{
  config = {
    # correctness before speed
    nix.settings.sandbox = true;

    nix.settings.max-jobs = "auto";

    # /tmp should never be depended on
    boot.tmp.cleanOnBoot = true;

    # Setting it to UTC explicitely makes it impossible to override at runtime
    time.timeZone = lib.mkDefault "UTC";

    # Set default input keymapping to neo (haha sorry everybody)
    console = {
      font = "lat9w-16";
      keyMap = "neo";
    };

    # the kernel OOM is not good enough without swap,
    # and I don’t like swap. This kills the most hoggy
    # processes when the system goes under a free space limit
    services.earlyoom = {
      enable = true;
      freeMemThreshold = 5; # <5% free
    };

    # bounded journal size
    services.journald.extraConfig = "SystemMaxUse=500M";

    programs.bash = {
      interactiveShellInit = ''
        alias c='vim /root/vuizvui/machines/profpatsch'
        alias nsp='nix-shell -p'
        alias nrs='nixos-rebuild switch'
        alias tad='tmux attach -d'
        alias gs='git status'

        # search recursively in cwd for file glob (insensitive)
        findia () { find -iname "*''${*}*"; }
        # like findia, but first argument is directory
        findian () { path="$1"; shift; find $path -iname "*''${*}*"; }
        # like findian, but searches whole filepath
        findiap () { path="$1"; shift; find $path -ipame "*''${*}*"; }
      '';
    };

    environment.systemPackages = with pkgs; [
      curl              # transfer data to/from a URL
      binutils          # debugging binary files
      dos2unix          # text file conversion
      file              # file information
      htop              # top replacement
      ncdu              # disk size checker
      nmap              # stats about clients in the network
      man-pages          # system manpages (not included by default)
      mkpasswd          # UNIX password creator
      lr                # list recursively, ls & find replacement
      ripgrep           # file content searcher, > ag > ack > grep
      rsync             # file syncing tool
      strace            # tracing syscalls
      tmux              # detachable terminal multiplexer
      traceroute        # trace ip routes
      wget              # the other URL file fetcher
      myPkgs.vim        # slight improvement over vi
      xe                # xargs with a modern interface
    ];

    i18n = {
      defaultLocale = "en_US.UTF-8";
      extraLocaleSettings = {
        LC_TIME = "de_DE.UTF-8";
      };
    };

    # Nobody wants mutable state. :)
    users.mutableUsers = false;

  };

}