nixfiles/nixos/vms/estuary/default.nix

135 lines
3.9 KiB
Nix
Raw Normal View History

{
nixos.systems.estuary = {
system = "x86_64-linux";
nixpkgs = "mine";
home-manager = "mine";
2022-05-17 23:27:14 +01:00
assignments.internal = {
2022-05-18 23:29:52 +01:00
name = "estuary-vm";
2022-05-17 23:27:14 +01:00
altNames = [ "fw" ];
ipv4 = {
address = "10.100.0.1";
gateway = null;
};
ipv6.address = "2a0e:97c0:4d1:0::1";
};
configuration = { lib, pkgs, modulesPath, config, assignments, allAssignments, ... }:
let
2022-05-18 22:52:42 +01:00
inherit (lib) mkIf mkMerge mkForce;
2022-05-17 23:27:14 +01:00
inherit (lib.my) networkdAssignment;
in
{
imports = [ "${modulesPath}/profiles/qemu-guest.nix" ./dns.nix ];
config = mkMerge [
{
2022-05-23 00:57:25 +01:00
networking.domain = lib.my.colonyDomain;
2022-05-18 23:29:52 +01:00
boot.kernelParams = [ "console=ttyS0,115200n8" ];
fileSystems = {
"/boot" = {
device = "/dev/disk/by-label/ESP";
fsType = "vfat";
};
"/nix" = {
device = "/dev/main/nix";
fsType = "ext4";
};
"/persist" = {
device = "/dev/main/persist";
fsType = "ext4";
neededForBoot = true;
};
};
services = {
lvm = {
dmeventd.enable = true;
};
};
systemd.network = {
links = {
"10-wan" = {
matchConfig.MACAddress = "52:54:00:a1:b2:5f";
linkConfig.Name = "wan";
};
"10-base" = {
matchConfig.MACAddress = "52:54:00:ab:f1:52";
linkConfig.Name = "base";
};
};
networks = {
#"80-wan" = {
# matchConfig.Name = "wan";
# address = [
# "1.2.3.4/24"
# "2a00::2/64"
# ];
#};
"80-wan" = {
matchConfig.Name = "wan";
DHCP = "ipv4";
2022-05-23 00:57:25 +01:00
dhcpV4Config = {
UseDNS = false;
UseHostname = false;
};
};
2022-05-18 22:52:42 +01:00
"80-base" = mkMerge [
(networkdAssignment "base" assignments.internal)
{
2022-05-23 00:57:25 +01:00
dns = [ "127.0.0.1" "::1" ];
domains = [ config.networking.domain ];
2022-05-18 22:52:42 +01:00
networkConfig = {
IPv6AcceptRA = mkForce false;
IPv6SendRA = true;
};
2022-05-23 00:57:25 +01:00
ipv6SendRAConfig = {
DNS = [ assignments.internal.ipv6.address ];
Domains = [ config.networking.domain ];
};
2022-05-18 22:52:42 +01:00
ipv6Prefixes = [
{
ipv6PrefixConfig.Prefix = "2a0e:97c0:4d1:0::/64";
}
];
}
];
};
};
my = {
2022-05-28 19:02:13 +01:00
secrets.key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPhxM5mnguExkcLue47QKk1vA72OoPc3HOqqoHqHHfa1";
server.enable = true;
firewall = {
trustedInterfaces = [ "base" ];
nat = {
enable = true;
externalInterface = "wan";
};
extraRules = ''
table nat {
chain postrouting {
ip saddr 10.100.0.0/16 masquerade
}
}
'';
};
};
}
(mkIf config.my.build.isDevVM {
systemd.network = {
netdevs."05-dummy-base".netdevConfig = {
Name = "base";
Kind = "dummy";
};
};
})
];
};
};
}