rename machine type -> kind

This commit is contained in:
Pim Kunis 2024-02-29 20:13:28 +01:00
parent 45d9ab3cb7
commit 904098c877
6 changed files with 26 additions and 26 deletions

View file

@ -36,7 +36,7 @@
lib = pkgs.lib; lib = pkgs.lib;
pkgs-unstable = nixpkgs-unstable.legacyPackages.${controllerArch}; pkgs-unstable = nixpkgs-unstable.legacyPackages.${controllerArch};
machines = (lib.modules.evalModules { modules = [ (import ./nixos/machines) ]; }).config.machines; machines = (lib.modules.evalModules { modules = [ (import ./nixos/machines) ]; }).config.machines;
physicalMachines = lib.filterAttrs (n: v: v.type == "physical") machines; physicalMachines = lib.filterAttrs (n: v: v.kind == "physical") machines;
mkNixosSystems = systemDef: mkNixosSystems = systemDef:
builtins.mapAttrs builtins.mapAttrs
(name: machine: (name: machine:

View file

@ -6,8 +6,8 @@
disko.nixosModules.disko disko.nixosModules.disko
agenix.nixosModules.default agenix.nixosModules.default
] ]
++ lib.lists.optional (machine.type == "physical") ./physical.nix ++ lib.lists.optional (machine.kind == "physical") ./physical.nix
++ lib.lists.optional (machine.type == "virtual") ./virtual; ++ lib.lists.optional (machine.kind == "virtual") ./virtual;
config = { config = {
time.timeZone = "Europe/Amsterdam"; time.timeZone = "Europe/Amsterdam";
@ -15,16 +15,16 @@
i18n = { i18n = {
defaultLocale = "en_US.UTF-8"; defaultLocale = "en_US.UTF-8";
extraLocaleSettings = { extraLocaleSettings = let extraLocale = "nl_NL.UTF-8"; in {
LC_ADDRESS = "nl_NL.UTF-8"; LC_ADDRESS = extraLocale;
LC_IDENTIFICATION = "nl_NL.UTF-8"; LC_IDENTIFICATION = extraLocale;
LC_MEASUREMENT = "nl_NL.UTF-8"; LC_MEASUREMENT = extraLocale;
LC_MONETARY = "nl_NL.UTF-8"; LC_MONETARY = extraLocale;
LC_NAME = "nl_NL.UTF-8"; LC_NAME = extraLocale;
LC_NUMERIC = "nl_NL.UTF-8"; LC_NUMERIC = extraLocale;
LC_PAPER = "nl_NL.UTF-8"; LC_PAPER = extraLocale;
LC_TELEPHONE = "nl_NL.UTF-8"; LC_TELEPHONE = extraLocale;
LC_TIME = "nl_NL.UTF-8"; LC_TIME = extraLocale;
}; };
}; };

View file

@ -3,7 +3,7 @@ let
machineOpts = { ... }: { machineOpts = { ... }: {
options = { options = {
# TODO: rename to kind? # TODO: rename to kind?
type = lib.mkOption { kind = lib.mkOption {
type = lib.types.enum [ "physical" "virtual" ]; type = lib.types.enum [ "physical" "virtual" ];
description = '' description = ''
Whether this machine is physical or virtual. Whether this machine is physical or virtual.
@ -56,7 +56,7 @@ in
config = { config = {
machines = { machines = {
warwick = { warwick = {
type = "physical"; kind = "physical";
arch = "aarch64-linux"; arch = "aarch64-linux";
isRaspberryPi = true; isRaspberryPi = true;
@ -68,7 +68,7 @@ in
}; };
atlas = { atlas = {
type = "physical"; kind = "physical";
arch = "x86_64-linux"; arch = "x86_64-linux";
isHypervisor = true; isHypervisor = true;
@ -87,7 +87,7 @@ in
}; };
jefke = { jefke = {
type = "physical"; kind = "physical";
arch = "x86_64-linux"; arch = "x86_64-linux";
isHypervisor = true; isHypervisor = true;
@ -106,7 +106,7 @@ in
}; };
lewis = { lewis = {
type = "physical"; kind = "physical";
arch = "x86_64-linux"; arch = "x86_64-linux";
isHypervisor = true; isHypervisor = true;
@ -129,7 +129,7 @@ in
}; };
hermes = { hermes = {
type = "virtual"; kind = "virtual";
hypervisorName = "lewis"; hypervisorName = "lewis";
nixosModule = { hypervisorConfig, ... }: { nixosModule = { hypervisorConfig, ... }: {
@ -156,7 +156,7 @@ in
}; };
maestro = { maestro = {
type = "virtual"; kind = "virtual";
hypervisorName = "atlas"; hypervisorName = "atlas";
nixosModule = { config, ... }: { nixosModule = { config, ... }: {
@ -173,7 +173,7 @@ in
}; };
bancomart = { bancomart = {
type = "virtual"; kind = "virtual";
hypervisorName = "jefke"; hypervisorName = "jefke";
nixosModule = { nixosModule = {
@ -187,7 +187,7 @@ in
}; };
vpay = { vpay = {
type = "virtual"; kind = "virtual";
hypervisorName = "lewis"; hypervisorName = "lewis";
nixosModule = { nixosModule = {

View file

@ -48,7 +48,7 @@ in {
config = { config = {
networking = { networking = {
domain = if machine.type == "physical" then "hyp" else "dmz"; domain = if machine.kind == "physical" then "hyp" else "dmz";
nftables.enable = true; nftables.enable = true;
useDHCP = false; useDHCP = false;
@ -117,7 +117,7 @@ in {
networkConfig.Bridge = cfg.dmz.bridgeName; networkConfig.Bridge = cfg.dmz.bridgeName;
}; };
}) })
(lib.optionalAttrs (machine.type == "virtual") { (lib.optionalAttrs (machine.kind == "virtual") {
"30-main-nic" = { "30-main-nic" = {
matchConfig.Name = "en*"; matchConfig.Name = "en*";

View file

@ -57,7 +57,7 @@
microvm.vms = microvm.vms =
let let
vmsForHypervisor = lib.filterAttrs (n: v: v.type == "virtual" && v.hypervisorName == config.networking.hostName) machines; vmsForHypervisor = lib.filterAttrs (n: v: v.kind == "virtual" && v.hypervisorName == config.networking.hostName) machines;
in in
builtins.mapAttrs builtins.mapAttrs
(name: vm: (name: vm:

View file

@ -12,7 +12,7 @@ in
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
lab.vm.shares = lib.mkIf (machine.type == "virtual") [{ lab.vm.shares = lib.mkIf (machine.kind == "virtual") [{
name = "docker"; name = "docker";
mountPoint = "/var/lib/docker"; mountPoint = "/var/lib/docker";
}]; }];