aboutsummaryrefslogtreecommitdiff
path: root/node/caribou.nix
blob: 77fc35b977cc5fb9f08b2a00517f6905fa36066e (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
# Configuration file local to this node

{ config, pkgs, ... }:

{
  # Use the systemd-boot EFI boot loader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.timeout = 20;
  boot.loader.efi.canTouchEfiVariables = true;

  networking.hostName = "caribou"; # Define your hostname.

  networking.interfaces.eno1.useDHCP = false;
  networking.interfaces.eno1.ipv4.addresses = [
    {
      address = "192.168.1.23";
      prefixLength = 24;
    }
  ];
  networking.interfaces.eno1.ipv6.addresses = [
    {
      address = "2a01:e0a:c:a720::23";
      prefixLength = 64;
    }
  ];

  networking.wireguard.interfaces.wg0 = {
    ips = [ "10.42.0.23/16" ];
    listenPort = 33723;
  };

  # OR use USB modem plugged in here
  #networking.interfaces.enp0s20u1.useDHCP = true;

  # Activate as Nomad and Consul server node
  services.nomad.settings.server.enabled = true;
  services.consul.extraConfig.server = true;

  # Enable netdata monitoring
  services.netdata.enable = true;

  # ----

  # Enable nix-serve
  services.nix-serve = {
    enable = true;
    secretKeyFile = "/var/cache-priv-key.pem";
  };

  # Configure a Nginx web server to serve NixOS cache
  services.nginx = {
    enable = true;
    virtualHosts = {
      "binarycache.home.adnab.me" = {
        serverAliases = [ "binarycache" ];
        listen = [ {
          addr = "0.0.0.0";
          port = 7980;
        } ];
        locations."/".extraConfig = ''
          proxy_pass http://localhost:${toString config.services.nix-serve.port};
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        '';
       };
    };
  };

  networking.firewall.allowedTCPPorts = [ 7980 ];
}