central IP

This commit is contained in:
nora 2024-07-31 20:05:02 +02:00
parent 59ec8ef37b
commit cfe47e65c0
4 changed files with 42 additions and 28 deletions

View file

@ -7,6 +7,29 @@
# - An initialized Nixpkgs attribute set
nixpkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/a1cc729dcbc31d9b0d11d86dc7436163548a9665.tar.gz"); # nixos-24.05 2024-07-26
specialArgs = {
networkingConfig = {
dns1 = {
publicIPv4 = "154.38.163.74";
publicIPv6 = null;
};
dns2 = {
publicIPv4 = "128.140.3.7";
publicIPv6 = "2a01:4f8:c2c:d616::";
};
vps1 = {
publicIPv4 = "161.97.165.1";
publicIPv6 = null;
};
vps3 = {
publicIPv4 = "134.255.181.139";
publicIPv6 = null;
};
};
};
# If your Colmena host has nix configured to allow for remote builds
# (for nix-daemon, your user being included in trusted-users)
# you can set a machines file that will be passed to the underlying

View file

@ -1,4 +1,4 @@
{ pkgs, lib, ... }: {
{ pkgs, lib, networkingConfig, ... }: {
# get the package for the debugging tools
environment.systemPackages = with pkgs; [ knot-dns ];
@ -29,10 +29,10 @@
zone:
- domain: noratrieb.dev
storage: /var/lib/knot/zones/
file: ${import ./noratrieb.dev.nix { inherit pkgs; inherit lib; }}
file: ${import ./noratrieb.dev.nix { inherit pkgs lib networkingConfig; }}
- domain: nilstrieb.dev
storage: /var/lib/knot/zones/
file: ${import ./nilstrieb.dev.nix { inherit pkgs; inherit lib; }}
file: ${import ./nilstrieb.dev.nix { inherit pkgs lib; }}
log:
- target: syslog
any: info

View file

@ -4,15 +4,13 @@ let
data = with pkgs.nix-dns.lib.combinators;
let
hour1 = 3600;
normalHost = ipv4: ipv6:
lib.optionalAttrs (ipv4 != null) { A = [ (ttl hour1 (a ipv4)) ]; } //
lib.optionalAttrs (ipv6 != null) { AAAA = [ (ttl hour1 (aaaa ipv6)) ]; };
dns1 = normalHost "154.38.163.74" null;
dns2 = normalHost "128.140.3.7" "2a01:4f8:c2c:d616::";
vps1 = normalHost "161.97.165.1" null;
vps2 = normalHost "184.174.32.252" null;
hostsToDns = builtins.mapAttrs
(name: { publicIPv4, publicIPv6 }:
lib.optionalAttrs (publicIPv4 != null) { A = [ (ttl hour1 (a publicIPv4)) ]; } //
lib.optionalAttrs (publicIPv6 != null) { AAAA = [ (ttl hour1 (aaaa publicIPv6)) ]; })
networkingConfig;
in
with hostsToDns;
{
SOA = {
nameServer = "ns1.nilstrieb.dev";

View file

@ -1,18 +1,16 @@
# https://github.com/nix-community/dns.nix
{ pkgs, lib, ... }:
{ pkgs, lib, networkingConfig, ... }:
let
data = with pkgs.nix-dns.lib.combinators;
let
hour1 = 3600;
normalHost = ipv4: ipv6:
lib.optionalAttrs (ipv4 != null) { A = [ (ttl hour1 (a ipv4)) ]; } //
lib.optionalAttrs (ipv6 != null) { AAAA = [ (ttl hour1 (aaaa ipv6)) ]; };
dns1 = normalHost "154.38.163.74" null;
dns2 = normalHost "128.140.3.7" "2a01:4f8:c2c:d616::";
vps1 = normalHost "161.97.165.1" null;
vps3 = normalHost "134.255.181.139" null;
hostsToDns = builtins.mapAttrs
(name: { publicIPv4, publicIPv6 }:
lib.optionalAttrs (publicIPv4 != null) { A = [ (ttl hour1 (a publicIPv4)) ]; } //
lib.optionalAttrs (publicIPv6 != null) { AAAA = [ (ttl hour1 (aaaa publicIPv6)) ]; })
networkingConfig;
in
with hostsToDns;
# vps1 contains root noratrieb.dev
vps1 // {
SOA = {
@ -37,17 +35,12 @@ let
localhost.A = [ (a "127.0.0.1") ];
newtest.TXT = [ "uwu it works" ];
# TODO: generate dynamically from IPs...
infra.subdomains = {
inherit dns1;
inherit dns2;
inherit vps1;
inherit vps3;
};
infra.subdomains = hostsToDns;
};
};
in
pkgs.writeTextFile {
pkgs.writeTextFile
{
name = "noratrieb.dev.zone";
text = pkgs.nix-dns.lib.toString "noratrieb.dev" data;
}