aboutsummaryrefslogtreecommitdiff
path: root/hosts/ganymede/nixos.nix
blob: 14be488d28174da2c2689dd9a024631fb87356ba (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
{
  config,
  pkgs,
  lib,
  inputs,
  ...
}: {
  imports = [
    inputs.disko.nixosModules.disko
    ./disks.nix

    ./minecraft.nix

    ./iwlwifi.nix
    ./caddy.nix
  ];

  # backup usb teather configuration
  systemd.network.networks."80-usb-teather" = {
    name = "enp0s20f0u2";
    networkConfig.DHCP = "yes";
  };

  systemd.services."disable-wifi-powersave" = {
    description = "Disable wifi powersaving using iw";
    after = ["network.target"];
    serviceConfig.ExecStart = "${pkgs.iw}/bin/iw dev wlp108s0 set power_save off";
    wantedBy = ["default.target"];
  };

  # VPN to server
  systemd.network = {
    netdevs."10-wg0" = {
      netdevConfig = {
        Kind = "wireguard";
        Name = "wg0";
      };
      wireguardConfig = {
        PrivateKeyFile = config.collinux.secrets."wireguard-pk".path;
        ListenPort = 51820;
      };
      wireguardPeers = [
        {
          PublicKey = "seOq75FUGb+KThvOXCEAGdabWbb+jTRUntITpuAPgWA=";
          AllowedIPs = "0.0.0.0/0";
          Endpoint = "20.251.8.247:51820";
          PersistentKeepalive = 25;
        }
      ];
    };
    networks."wg0" = {
      matchConfig.Name = "wg0";
      address = ["10.100.0.2/24"];
      DHCP = "no";
      networkConfig.IPv6AcceptRA = false;
    };
  };

  # deploy user
  users.groups."deploy" = {};
  users.users."deploy" = {
    isSystemUser = true;
    group = "deploy";

    openssh.authorizedKeys.keys = config.users.users."collin".openssh.authorizedKeys.keys;
  };
  security.sudo.extraRules = [
    {
      users = ["deploy"];
      commands = [
        {
          command = "/nix/store/*/bin/switch-to-configuration";
          options = ["NOPASSWD"];
        }
        {
          command = "/run/current-system/sw/bin/shutdown";
          options = ["NOPASSWD"];
        }
      ];
    }
  ];

  services.fail2ban.enable = true;

  # merge logs from subdomains
  services.caddy.virtualHosts."up.williamsfam.us.com".logFormat = lib.mkForce ''
    output file /var/log/caddy/access-williamsfam.us.com.log
  '';

  # i broke something and this fixes it
  environment.etc."systemd/resolved.conf.d/10-dns.conf".text = config.environment.etc."systemd/resolved.conf".text;
}