all repos — nixfiles @ fc06ee8a9be5144abdde508cd57eeac34ea9b7d2

System and user configuration, managed by nix and home-manager

system/hosts/linde.nix (view raw)

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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running `nixos-help`).

{
  lib,
  pkgs,
  ...
}:

with lib;
let
  netif = "eth0";
  hostname = "linde";
  net-ip4 = "116.203.248.56";
  net-mask4 = 32;
  net-gw = "172.31.1.1";
  prefix6 = "2a01:4f8:c012:23a4";
  net-ip6 = "${prefix6}::1";
  net-mask6 = 64;
  net-gw6 = "fe80::1";
  domain = "alin.ovh";
  oldDomain = "alanpearce.eu";
in
{
  imports = [
    # Include the results of the hardware scan.
    ./linde-hardware.nix

    ../roles/server.nix
    ../roles/reverse-proxy.nix
    ../roles/auth-dns.nix
    ../roles/binary-cache.nix
    ../roles/calendar-anonymiser.nix
    ../roles/file-server.nix
    ../roles/forgejo-runner.nix
    ../roles/goatcounter.nix
    ../roles/mailer.nix
    ../roles/nix-remote-builder.nix
    ../roles/paperless.nix
    ../roles/push-notifications.nix
    ../roles/readeck.nix
    ../roles/redis-website.nix
    ../roles/searchix.nix
    ../roles/sso.nix
    ../roles/subdomain-redirector.nix
    ../roles/video-library.nix
    ../roles/git-server.nix
  ];

  boot.loader.efi.efiSysMountPoint = "/boot/efi";

  environment.systemPackages = with pkgs; [
    cifs-utils
    knot-dns
  ];

  # Initial empty root password for easy login:
  users.users.root.initialHashedPassword = "";
  programs.ssh.extraConfig = ''
    Host ${domain} git.${domain}
      Hostname git.${domain}
      User gitolite
  '';

  nix = {
    settings = {
      max-jobs = 2;
    };

    buildMachines = [
      {
        protocol = "ssh-ng";
        sshUser = "nixremote";
        hostName = "granatum.opia.ovh";
        system = "aarch64-linux";
        maxJobs = 2;
        speedFactor = 1;
        supportedFeatures = [ "kvm" ];
      }
    ];
  };

  networking = {
    hostName = hostname;
    inherit domain;
    dhcpcd.enable = false;
    nameservers = [
      "2606:4700:4700::1111"
      "2606:4700:4700::1001"
      "1.1.1.1"
      "1.0.0.1"
    ];
    hosts = lib.mkForce {
      ${net-ip4} = [
        "${hostname}.${domain}"
        hostname
      ];
      ${net-ip6} = [
        "${hostname}.${domain}"
        hostname
      ];
    };
    defaultGateway = {
      address = net-gw;
      interface = netif;
    };
    defaultGateway6 = {
      address = net-gw6;
      interface = netif;
    };
    interfaces.${netif} = {
      ipv4 = {
        addresses = [
          {
            address = net-ip4;
            prefixLength = net-mask4;
          }
        ];
        routes = [
          {
            address = net-gw;
            prefixLength = 32;
          }
        ];
      };
      ipv6 = {
        addresses = [
          {
            address = net-ip6;
            prefixLength = net-mask6;
          }
        ];
      };
    };
    resolvconf = {
      enable = false;
      useLocalResolver = false;
    };
  };
  services.cloud-init.network.enable = false;
  services.resolved = {
    enable = true;
    settings.Resolve = {
      DNSSEC = true;
    };
  };
  systemd.network.wait-online.enable = lib.mkForce true;

  zramSwap = {
    enable = true;
    algorithm = "zstd";
  };

  security.sudo.extraConfig = ''
    Defaults:root,%wheel env_keep+=EDITOR
  '';

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It's perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "23.05"; # Did you read the comment?

  services.powerdns.extraConfig = ''
    local-address=${net-ip4} ${net-ip6}
  '';

  services.caddy = {
    virtualHosts =
      let
        inherit (import ../../lib/caddy.nix { inherit lib; }) security-headers;
      in
      {
        "go.${domain}" = {
          extraConfig = ''
            encode zstd gzip
            ${security-headers { }}
            root * /srv/http/go.alin.ovh
            file_server
          '';
        };
        "go.${oldDomain}" = {
          extraConfig = ''
            encode zstd gzip
            ${security-headers { }}
            root * /srv/http/go
            file_server
          '';
        };
      };
  };
}