2022-05-31 21:58:29 +01:00
|
|
|
{ lib, ... }: {
|
2022-05-28 23:05:30 +01:00
|
|
|
imports = [ ./vms ];
|
|
|
|
|
2022-02-20 15:59:07 +00:00
|
|
|
nixos.systems.colony = {
|
|
|
|
system = "x86_64-linux";
|
2022-05-28 18:38:03 +01:00
|
|
|
nixpkgs = "mine-stable";
|
|
|
|
home-manager = "mine-stable";
|
2022-02-19 22:55:53 +00:00
|
|
|
|
2022-05-28 15:30:12 +01:00
|
|
|
assignments = {
|
|
|
|
internal = {
|
|
|
|
altNames = [ "vm" ];
|
2022-06-05 16:40:44 +01:00
|
|
|
domain = lib.my.colony.domain;
|
2022-05-31 21:58:29 +01:00
|
|
|
ipv4.address = "${lib.my.colony.start.base.v4}2";
|
|
|
|
ipv6 = {
|
2022-05-29 03:30:40 +01:00
|
|
|
iid = "::2";
|
2022-05-31 21:58:29 +01:00
|
|
|
address = "${lib.my.colony.start.base.v6}2";
|
2022-05-29 03:30:40 +01:00
|
|
|
};
|
2022-05-28 15:30:12 +01:00
|
|
|
};
|
|
|
|
vms = {
|
|
|
|
ipv4 = {
|
2022-05-31 21:58:29 +01:00
|
|
|
address = "${lib.my.colony.start.vms.v4}1";
|
2022-05-28 15:30:12 +01:00
|
|
|
gateway = null;
|
|
|
|
};
|
2022-05-31 21:58:29 +01:00
|
|
|
ipv6.address = "${lib.my.colony.start.vms.v6}1";
|
2022-05-28 15:30:12 +01:00
|
|
|
};
|
2022-05-17 23:27:14 +01:00
|
|
|
};
|
|
|
|
|
2022-05-28 15:30:12 +01:00
|
|
|
configuration = { lib, pkgs, modulesPath, config, systems, assignments, allAssignments, ... }:
|
2022-02-21 00:37:09 +00:00
|
|
|
let
|
2022-05-29 15:22:49 +01:00
|
|
|
inherit (lib) mkIf mkMerge mkForce;
|
2022-05-17 23:27:14 +01:00
|
|
|
inherit (lib.my) networkdAssignment;
|
2022-02-21 00:37:09 +00:00
|
|
|
in
|
2022-02-20 15:59:07 +00:00
|
|
|
{
|
2022-05-28 23:05:30 +01:00
|
|
|
imports = [ "${modulesPath}/profiles/qemu-guest.nix" ];
|
2022-02-13 23:06:31 +00:00
|
|
|
|
2022-05-16 00:05:02 +01:00
|
|
|
boot.kernelParams = [ "intel_iommu=on" ];
|
|
|
|
boot.loader.systemd-boot.configurationLimit = 20;
|
2022-02-20 15:59:07 +00:00
|
|
|
fileSystems = {
|
|
|
|
"/boot" = {
|
2022-06-06 15:53:57 +01:00
|
|
|
device = "/dev/disk/by-uuid/83CA-3BCF";
|
2022-02-20 15:59:07 +00:00
|
|
|
fsType = "vfat";
|
|
|
|
};
|
|
|
|
"/nix" = {
|
2022-05-16 00:05:02 +01:00
|
|
|
device = "/dev/ssds/colony-nix";
|
2022-02-20 15:59:07 +00:00
|
|
|
fsType = "ext4";
|
|
|
|
};
|
|
|
|
"/persist" = {
|
2022-05-16 00:05:02 +01:00
|
|
|
device = "/dev/ssds/colony-persist";
|
2022-02-20 15:59:07 +00:00
|
|
|
fsType = "ext4";
|
|
|
|
neededForBoot = true;
|
|
|
|
};
|
|
|
|
};
|
2022-05-16 00:05:02 +01:00
|
|
|
services = {
|
|
|
|
lvm = {
|
|
|
|
boot.thin.enable = true;
|
|
|
|
dmeventd.enable = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
pciutils
|
2022-06-06 15:53:57 +01:00
|
|
|
partclone
|
2022-05-16 00:05:02 +01:00
|
|
|
];
|
2022-02-20 15:59:07 +00:00
|
|
|
|
2022-05-16 00:05:02 +01:00
|
|
|
systemd = {
|
|
|
|
network = {
|
2022-05-18 23:29:52 +01:00
|
|
|
links = {
|
|
|
|
"10-base-ext" = {
|
|
|
|
matchConfig.MACAddress = "52:54:00:81:bd:a1";
|
|
|
|
linkConfig.Name = "base-ext";
|
|
|
|
};
|
|
|
|
};
|
2022-05-28 15:30:12 +01:00
|
|
|
netdevs = {
|
|
|
|
"25-base".netdevConfig = {
|
|
|
|
Name = "base";
|
|
|
|
Kind = "bridge";
|
|
|
|
};
|
2022-05-29 15:22:49 +01:00
|
|
|
|
2022-05-28 15:30:12 +01:00
|
|
|
"25-vms".netdevConfig = {
|
|
|
|
Name = "vms";
|
|
|
|
Kind = "bridge";
|
|
|
|
};
|
2022-05-29 15:22:49 +01:00
|
|
|
"30-vms-dummy".netdevConfig = {
|
|
|
|
Name = "vms0";
|
|
|
|
Kind = "dummy";
|
|
|
|
};
|
2022-05-02 17:34:48 +01:00
|
|
|
};
|
2022-05-28 15:30:12 +01:00
|
|
|
|
2022-05-18 22:52:42 +01:00
|
|
|
networks = {
|
|
|
|
"80-base" = networkdAssignment "base" assignments.internal;
|
2022-05-18 23:29:52 +01:00
|
|
|
"80-base-ext" = {
|
|
|
|
matchConfig.Name = "base-ext";
|
|
|
|
networkConfig.Bridge = "base";
|
|
|
|
};
|
2022-05-28 15:30:12 +01:00
|
|
|
|
|
|
|
"80-vms" = mkMerge [
|
2022-05-29 03:30:40 +01:00
|
|
|
(networkdAssignment "vms" assignments.vms)
|
2022-05-28 15:30:12 +01:00
|
|
|
{
|
|
|
|
networkConfig = {
|
|
|
|
IPv6AcceptRA = mkForce false;
|
|
|
|
IPv6SendRA = true;
|
|
|
|
};
|
|
|
|
ipv6SendRAConfig = {
|
2022-05-29 15:48:26 +01:00
|
|
|
DNS = [ allAssignments.estuary.base.ipv6.address ];
|
2022-05-28 15:30:12 +01:00
|
|
|
Domains = [ config.networking.domain ];
|
|
|
|
};
|
|
|
|
ipv6Prefixes = [
|
|
|
|
{
|
2022-05-29 03:30:40 +01:00
|
|
|
ipv6PrefixConfig.Prefix = lib.my.colony.prefixes.vms.v6;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
routes = map (r: { routeConfig = r; }) [
|
|
|
|
{
|
|
|
|
Gateway = allAssignments.shill.internal.ipv4.address;
|
|
|
|
Destination = lib.my.colony.prefixes.ctrs.v4;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
Gateway = allAssignments.shill.internal.ipv6.address;
|
|
|
|
Destination = lib.my.colony.prefixes.ctrs.v6;
|
2022-05-28 15:30:12 +01:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
2022-05-29 15:22:49 +01:00
|
|
|
# Just so the vms interface will come up (in networkd's eyes), allowing dependant VMs to start.
|
|
|
|
# Could tweak the `waitOnline` for a single VM, but this seems better overall?
|
|
|
|
"80-vms-dummy" = {
|
|
|
|
matchConfig.Name = "vms0";
|
|
|
|
networkConfig.Bridge = "vms";
|
2022-05-18 22:52:42 +01:00
|
|
|
};
|
|
|
|
};
|
2022-05-02 17:34:48 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-05-16 00:05:02 +01:00
|
|
|
#environment.etc."udev/udev.conf".text = "udev_log=debug";
|
2022-03-26 14:20:30 +00:00
|
|
|
#systemd.services.systemd-networkd.environment.SYSTEMD_LOG_LEVEL = "debug";
|
2022-05-02 20:40:11 +01:00
|
|
|
virtualisation = {
|
|
|
|
cores = 8;
|
|
|
|
memorySize = 8192;
|
2022-05-16 00:05:02 +01:00
|
|
|
qemu.options = [
|
|
|
|
"-machine q35"
|
|
|
|
"-accel kvm,kernel-irqchip=split"
|
|
|
|
"-device intel-iommu,intremap=on,caching-mode=on"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
my = {
|
|
|
|
#deploy.generate.system.mode = "boot";
|
|
|
|
secrets = {
|
|
|
|
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKp5WDdDr/1NS3SJIDOKwcCNZDFOxqPAD7cbZWAP7EkX";
|
|
|
|
};
|
|
|
|
|
|
|
|
server.enable = true;
|
|
|
|
|
|
|
|
firewall = {
|
2022-05-29 03:30:40 +01:00
|
|
|
trustedInterfaces = [ "base" "vms" ];
|
2022-05-16 00:05:02 +01:00
|
|
|
};
|
2022-05-02 20:40:11 +01:00
|
|
|
};
|
2022-02-20 15:59:07 +00:00
|
|
|
};
|
2022-02-19 22:55:53 +00:00
|
|
|
};
|
2022-02-13 13:10:21 +00:00
|
|
|
}
|