summaryrefslogtreecommitdiff
path: root/hosts/surtr/default.nix
blob: 85723005c567972084321953c13e300a722fe09e (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
{ flake, pkgs, ... }:
{
  imports = with flake.nixosModules.systemProfiles; [
    qemu-guest openssh rebuild-machines ./zfs.nix ./dns
  ];

  config = {
    nixpkgs = {
      system = "x86_64-linux";
    };

    networking.hostId = "a64cf4d7";
    environment.etc."machine-id".text = "a64cf4d793ab0a0ed3892ead609fc0bc";

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

      kernelPackages = pkgs.linuxPackages_latest;

      tmpOnTmpfs = true;

      supportedFilesystems = [ "zfs" ];
      zfs = {
        enableUnstable = true;
        devNodes = "/dev"; # /dev/vda2 does not show up in /dev/disk/by-id
      };
    };

    fileSystems = {
      "/" = {
        fsType = "tmpfs";
        options = [ "mode=0755" ];
      };

      "/boot" =
        { device = "/dev/disk/by-label/boot";
          fsType = "vfat";
        };
    };

    networking = {
      hostName = "surtr";
      domain = "muspelheim.yggdrasil";
      search = [ "muspelheim.yggdrasil" "yggdrasil" ];

      enableIPv6 = true;
      dhcpcd.enable = false;
      useDHCP = false;
      useNetworkd = true;
      defaultGateway = { address = "202.61.240.1"; };
      defaultGateway6 = { address = "fe80::1"; };
      interfaces."ens3" = {
        ipv4.addresses = [
          { address = "202.61.241.61"; prefixLength = 22; }
        ];
        ipv6.addresses = [
          { address = "2a03:4000:52:ada::"; prefixLength = 64; }
        ];
      };

      firewall = {
        enable = true;
        allowPing = true;
        allowedTCPPorts = [
          22 # ssh
        ];
        allowedUDPPortRanges = [
          { from = 60000; to = 61000; } # mosh
        ];
      };
    };

    services.openssh = {
      enable = true;
      passwordAuthentication = false;
      challengeResponseAuthentication = false;
      extraConfig = ''
        AllowGroups ssh
      '';
    };
    users.groups."ssh" = {
      members = ["root"];
    };

    security.sudo.extraConfig = ''
      Defaults lecture = never
    '';

    nix.gc = {
      automatic = true;
      options = "--delete-older-than 30d";
    };
  };
}