Profpatsch/machines/profpatsch/base.nix
  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
# Base config shared by all machines
{ pkgs, config, lib, homeRepo, ... }:

let
  authKeys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDNMQvmOfon956Z0ZVdp186YhPHtSBrXsBwaCt0JAbkf/U/P+4fG0OROA++fHDiFM4RrRHH6plsGY3W6L26mSsCM2LtlHJINFZtVILkI26MDEIKWEsfBatDW+XNAvkfYEahy16P5CBtTVNKEGsTcPD+VDistHseFNKiVlSLDCvJ0vMwOykHhq+rdJmjJ8tkUWC2bNqTIH26bU0UbhMAtJstWqaTUGnB0WVutKmkZbnylLMICAvnFoZLoMPmbvx8efgLYY2vD1pRd8Uwnq9MFV1EPbkJoinTf1XSo8VUo7WCjL79aYSIvHmXG+5qKB9ed2GWbBLolAoXkZ00E4WsVp9H philip@nyx" ];

  philip = {
    name = "philip";
    extraGroups = [
      "wheel"
      "networkmanager"
      "libvirtd"
      "scanner"
      "adbusers"
    ];
    uid = 1000;
    createHome = true;
    home = "/home/philip";
    hashedPasswordFile = "/home/philip/.config/passwd";
    shell = "${lib.getBin pkgs.fish}/bin/fish";
    openssh.authorizedKeys.keys = authKeys;
    isNormalUser = true;
  };

in
{
  imports = [
    ../../users/Profpatsch/nixos-modules/module-list.nix
  ];

  config = {
    # Make shared values available to all sub-modules
    _module.args.authKeys = authKeys;
    _module.args.philip = philip;

    nix.package = pkgs.lix;
    # correctness before speed
    nix.settings.sandbox = true;

    nix.settings.max-jobs = "auto";
    nix.settings.experimental-features = [ "nix-command" "flakes" ];

    # /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";
    };

    # make sure the best hardware packages are always installed, even if non-free
    hardware.enableRedistributableFirmware = lib.mkDefault true;

    # 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/kot/Profpatsch/machines/profpatsch'
        alias nsp='nix-shell -p'
        alias nrs='nixos-rebuild switch'
        alias tad='tmux attach -d'
        alias gs='git status'
        alias m='micro'

        # 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
      net-tools         # netstat
      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
      vim               # slight improvement over vi
      homeRepo.micro    # modern terminal-based text editor
      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;

    # man-cache generation is very slow, skip it
    documentation.man.generateCaches = false;

  };

}