nixos-servers/nixos/machines/default.nix

205 lines
4.7 KiB
Nix
Raw Normal View History

2024-02-28 23:28:38 +00:00
{ lib, ... }:
let
machineOpts = { ... }: {
options = {
# TODO: rename to kind?
2024-02-29 19:13:28 +00:00
kind = lib.mkOption {
2024-02-28 23:28:38 +00:00
type = lib.types.enum [ "physical" "virtual" ];
description = ''
Whether this machine is physical or virtual.
'';
2024-02-26 22:08:12 +00:00
};
2024-02-28 23:28:38 +00:00
hypervisorName = lib.mkOption {
default = null;
type = with lib.types; nullOr str;
description = ''
The host name of the hypervisor hosting this virtual machine.
'';
};
2024-02-28 23:28:38 +00:00
arch = lib.mkOption {
default = null;
type = with lib.types; nullOr str;
description = ''
CPU architecture of this machine.
'';
};
isRaspberryPi = lib.mkOption {
default = false;
type = lib.types.bool;
};
2024-02-28 23:28:38 +00:00
isHypervisor = lib.mkOption {
default = false;
type = lib.types.bool;
2024-02-27 22:28:52 +00:00
};
2024-02-28 23:28:38 +00:00
nixosModule = lib.mkOption {
default = { ... }: { };
type = lib.types.anything;
description = ''
Customized configuration for this machine in the form of a NixOS module.
'';
};
};
};
2024-02-28 23:28:38 +00:00
in
{
options = {
machines = lib.mkOption {
type = with lib.types; attrsOf (submodule machineOpts);
};
};
2024-02-28 23:28:38 +00:00
config = {
machines = {
warwick = {
2024-02-29 19:13:28 +00:00
kind = "physical";
2024-02-28 23:28:38 +00:00
arch = "aarch64-linux";
isRaspberryPi = true;
nixosModule.lab = {
storage = {
osDisk = "/dev/sda";
};
};
};
2024-01-17 20:28:15 +00:00
2024-02-28 23:28:38 +00:00
atlas = {
2024-02-29 19:13:28 +00:00
kind = "physical";
2024-02-28 23:28:38 +00:00
arch = "x86_64-linux";
isHypervisor = true;
nixosModule.lab = {
storage = {
osDisk = "/dev/sda";
dataPartition = "/dev/nvme0n1p1";
};
ssh = {
useCertificates = true;
hostCert = builtins.readFile ./certificates/atlas/host_ed25519.crt;
userCert = builtins.readFile ./certificates/atlas/user_ed25519.crt;
};
};
};
2024-02-28 23:28:38 +00:00
jefke = {
2024-02-29 19:13:28 +00:00
kind = "physical";
2024-02-28 23:28:38 +00:00
arch = "x86_64-linux";
isHypervisor = true;
nixosModule.lab = {
storage = {
osDisk = "/dev/sda";
dataPartition = "/dev/nvme0n1p1";
};
ssh = {
useCertificates = true;
hostCert = builtins.readFile ./certificates/jefke/host_ed25519.crt;
userCert = builtins.readFile ./certificates/jefke/user_ed25519.crt;
};
2024-02-27 22:28:52 +00:00
};
2024-02-28 23:28:38 +00:00
};
2024-02-28 23:28:38 +00:00
lewis = {
2024-02-29 19:13:28 +00:00
kind = "physical";
2024-02-28 23:28:38 +00:00
arch = "x86_64-linux";
isHypervisor = true;
nixosModule.lab = {
backups.enable = true;
data-sharing.enable = true;
networking.dmz.allowConnectivity = true;
storage = {
osDisk = "/dev/sda";
dataPartition = "/dev/nvme0n1p1";
};
ssh = {
useCertificates = true;
hostCert = builtins.readFile ./certificates/lewis/host_ed25519.crt;
userCert = builtins.readFile ./certificates/lewis/user_ed25519.crt;
};
};
};
2024-02-07 22:15:48 +00:00
2024-02-28 23:28:38 +00:00
hermes = {
2024-02-29 19:13:28 +00:00
kind = "virtual";
2024-02-28 23:28:38 +00:00
hypervisorName = "lewis";
2024-02-29 18:50:05 +00:00
nixosModule = { hypervisorConfig, ... }: {
2024-02-28 23:28:38 +00:00
lab = {
networking = {
dmz.services.enable = true;
staticNetworking = true;
2024-02-29 18:50:05 +00:00
staticIPv4 = hypervisorConfig.lab.networking.dmz.ipv4.services;
staticIPv6 = hypervisorConfig.lab.networking.dmz.ipv6.services;
2024-02-28 23:28:38 +00:00
};
vm = {
2024-02-29 18:50:05 +00:00
# TODO: would be cool to create a check that a mac address is only ever assigned to one VM.
# TODO: idea: what if we generated these IDs by hashing the host name and reducing that to the amount of hosts possible?
2024-02-28 23:28:38 +00:00
id = 7;
shares = [{
name = "dnsmasq";
mountPoint = "/var/lib/dnsmasq";
}];
};
};
};
2024-01-29 21:21:15 +00:00
};
2024-02-28 23:28:38 +00:00
maestro = {
2024-02-29 19:13:28 +00:00
kind = "virtual";
2024-02-28 23:28:38 +00:00
hypervisorName = "atlas";
2024-02-28 23:28:38 +00:00
nixosModule = { config, ... }: {
microvm.balloonMem = 7680;
2024-02-28 23:28:38 +00:00
lab = {
dockerSwarm.enable = true;
2024-02-28 23:28:38 +00:00
vm = {
id = 1;
};
};
2024-02-07 22:15:48 +00:00
};
};
2024-02-28 23:28:38 +00:00
bancomart = {
2024-02-29 19:13:28 +00:00
kind = "virtual";
2024-02-28 23:28:38 +00:00
hypervisorName = "jefke";
2024-02-28 23:28:38 +00:00
nixosModule = {
microvm.balloonMem = 7680;
2024-02-28 23:28:38 +00:00
lab = {
dockerSwarm.enable = true;
vm.id = 2;
};
};
2024-02-06 21:03:25 +00:00
};
2024-02-28 23:28:38 +00:00
vpay = {
2024-02-29 19:13:28 +00:00
kind = "virtual";
2024-02-28 23:28:38 +00:00
hypervisorName = "lewis";
2024-02-06 21:03:25 +00:00
2024-02-28 23:28:38 +00:00
nixosModule = {
microvm.balloonMem = 5120;
2024-02-28 23:28:38 +00:00
lab = {
dockerSwarm.enable = true;
vm.id = 3;
};
};
};
};
};
}