summaryrefslogtreecommitdiff
path: root/ymir.nix
blob: a4bef801f8a06f97432814652a773579bc00bbe8 (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
{ config, pkgs, ... }:

let
  luaPam = pkgs.callPackage ./custom/luaPam.nix {};                                                                              
  luaPosix = pkgs.callPackage ./custom/luaPosix.nix {};                                                                              
in {
  imports =
    [
      ./ymir-hw.nix
      ./custom/zsh.nix
      ./users.nix
    ];

  boot.loader.grub = {
    enable = true;
    version = 2;
    device = "/dev/vda";
  };

  boot.kernel.sysctl = {
    "net.ipv4.tcp_keepalive_time" = 60;
    "net.ipv4.tcp_keepalive_intvl" = 10;
    "net.ipv4.tcp_keepalive_probes" = 6;
  };

  nixpkgs.config.packageOverrides = pkgs:
    rec {
      prosody = pkgs.callPackage ./customized/prosody.nix ({
          inherit (pkgs.lua51Packages) luasocket luasec luaexpat luafilesystem luabitop luaevent luazlib;
          lua5 = pkgs.lua5_1;
          extraModules = ["mod_auth_pam"];
          extraLibs = [luaPam luaPosix];
        });
    };

  environment.systemPackages = with pkgs; [
    git
    mosh
    rsync
    tmux
    zsh
  ];

  networking = {
    hostName = "ymir";
    hostId = "1c5c994e";
    firewall = {
      enable = true;
      allowPing = true;
      allowedTCPPorts = [ 22
                          5222
                          5269
                        ];
      allowedUDPPortRanges = [ { from = 60000; to = 61000; } # mosh
                             ];
    };
    enableIPv6 = true;
    defaultGateway6 = "fe80::1";
    interfaces."enp0s3" = {
      ipv6Address = "2a03:4000:6:d004::";
      ipv6PrefixLength = 64;
    };
  };

  users.extraUsers.root = let
    template = (import users/gkleen.nix);
    in {
        inherit (template) shell;
        openssh.authorizedKeys.keyFiles = template.openssh.authorizedKeys.keyFiles;
      };

  services.ntp = {
    enable = false;
  };

  # List services that you want to enable:

  services.openssh = {
    enable = true;
    passwordAuthentication = false;
  };

  services.fcron = {
    enable = true;
    systab = ''
      %weekly * * nix-collect-garbage --delete-older-than '7d'
    '';
  };

  services.chrony = {
    enable = true;
  };

  services.prosody = {
    enable = true;
    admins = [
               "gkleen@xmpp.li"
             ];
    allowRegistration = false;
    extraModules = [ "private"
                     "auth_pam"
                   ];
    extraConfig = ''
      authentication="pam"
    '';

    virtualHosts.default = {
      enabled = true;
      domain = "xmpp.li";
      ssl = {
        key = "certs/xmpp.li.key";
        cert = "certs/xmpp.li.crt";
      };
    };
  };
  security.pam.services."xmpp".text = ''
    auth    required                    pam_warn.so audit
    auth    required                    pam_succeed_if.so user ingroup xmpp audit
    auth    [success=1 default=ignore]  pam_unix.so obscure sha512 nodelay audit
    auth    requisite                   pam_deny.so audit
    auth    required                    pam_permit.so audit
  '';
  users.groups."xmpp" = {
    members = [ "gkleen"
              ];
  };
}