zaphyra's git: nixfiles

zaphyra and void's nixfiles

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 
{

  system = "x86_64-linux";
  nixpkgsStable = true;

  domain = "infra.zaphyra.eu";

  sshPubKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMrPIC3CoGpLDxsz1kiOXpv7EpNoFEgI6nCNckD69rpJ";

  hardware = {
    cpuVendor = "intel";
    allowHibernation = false;
  };

  networking = {
    ip4IsPrivate = false;
    ip4Address = "194.36.145.49";
    ip4PrefixLength = 22;
    defaultGateway4 = "194.36.144.1";

    ip6IsPrivate = false;
    ip6Address = "2a03:4000:4d:5e::1";
    ip6PrefixLength = 64;
    defaultGateway6 = "fe80::1";

    hasDN42 = true;
    dn42Address = "fd6b:6174:6a61::1";
  };

  configuration =
    {
      modulesPath,
      inputs,
      config,
      lib,
      pkgs,
      ...
    }:
    {

      imports = [
        (modulesPath + "/profiles/minimal.nix")
        ./dn42.nix
      ];

      boot.initrd.systemd.emergencyAccess = true;
      boot.kernel.sysctl."net.ipv6.conf.all.proxy_ndp" = true;

      sops.secrets = {
        wgPrivateKey = {
          owner = "systemd-network";
          group = "systemd-network";
        };
        "resticEnv/novus" = {
          sopsFile = inputs.self.sopsSecrets.common;
        };
      };

      modules = {
        security.kernel.enable = false;
        filesystem = {
          impermanence.system.enable = true;
          impermanence.home.enable = true;
          rootDisk = {
            enable = true;
            encrypt = true;
            type = "zfs";
            path = "/dev/vda";
            reservedSpace = "500M";
            parts = {
              nix = true;
            };
            swap = {
              enable = true;
              size = "2G";
            };
          };
        };

        presets = {
          base.enable = true;
          netcup.enable = true;
          zaphyra = {
            enable = true;
            syncthing.enable = false;
            dnsServer.enable = true;
          };
        };

        services = {
          resticBackup.targets = {
            novus = {
              repository = "rest:https://restic.novus.infra.zaphyra.eu";
              environmentFile = config.sops.secrets."resticEnv/novus".path;
            };
          };
        };

        websites = {
          "restic.novus.infra.zaphyra.eu".enable = true;
          "flauschehorn.zaphyra.eu".enable = true;
          "ip.zaphyra.eu".enable = true;

          #old fedi-instance
          "ctu.cx".enable = true;
          "fedi.ctu.cx".enable = true;
        };

        users.zaphyra.enable = true;
      };

      networking.firewall = {
        allowedUDPPorts = [
          config.systemd.network.netdevs."20-wg0".wireguardConfig.ListenPort
        ];
        trustedInterfaces = [
          "wg0"
        ];
      };

      systemd.network = {
        config.networkConfig = {
          IPv6Forwarding = true;
        };

        netdevs."20-wg0" = {
          netdevConfig = {
            Kind = "wireguard";
            Name = "wg0";
          };

          wireguardConfig = {
            PrivateKeyFile = config.sops.secrets.wgPrivateKey.path;
            ListenPort = 51820;
            FirewallMark = 51820;
          };

          wireguardPeers = [
            {
              PublicKey = "nvyhYuWJl/dKyV/2+bDrUisvL3mi38PsNzfdIDDwSjY=";
              AllowedIPs = [ "::/0" ];
              PersistentKeepalive = 10;
            }
          ];
        };

        networks."20-wg0" = {
          name = "wg0";
          routes = [
            {
              Destination = "2a03:4000:4d:5e:acab::/112";
            }
          ];
          linkConfig.RequiredForOnline = false;
        };
      };

      services.ndppd = {
        enable = true;
        proxies.ens3.rules."2a03:4000:4d:5e:acab::/112".method = "static";
      };

      system.stateVersion = "24.11";
      home-manager.users.zaphyra.home.stateVersion = "24.11";
    };

}