From a015290fcf723977e809a20e5e56221e555ddf56 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sun, 28 Jan 2024 13:46:32 +0100 Subject: [PATCH] derive domain from server type --- nixos/machines/default.nix | 21 ++++----------------- nixos/modules/networking/default.nix | 1 + nixos/physical.nix | 2 +- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/nixos/machines/default.nix b/nixos/machines/default.nix index b936b53..fb4eac4 100644 --- a/nixos/machines/default.nix +++ b/nixos/machines/default.nix @@ -4,11 +4,7 @@ type = "physical"; nixosModule = { - networking = { - hostName = "jefke"; - # TODO: generate this using type? - domain = "hyp"; - }; + networking.hostName = "jefke"; lab = { terraformDatabase.enable = true; @@ -34,10 +30,7 @@ nixosModule = { config, ... }: let inherit (config.lab.networking) dmzServicesIPv4 dmzServicesIPv6; in { - networking = { - hostName = "atlas"; - domain = "hyp"; - }; + networking.hostName = "atlas"; lab = { networking = { @@ -65,10 +58,7 @@ type = "physical"; nixosModule = { pkgs, ... }: { - networking = { - hostName = "lewis"; - domain = "hyp"; - }; + networking.hostName = "lewis"; lab = { dataHost.enable = true; @@ -96,10 +86,7 @@ echo "Hello world from inside a virtual machine!!" | ${pkgs.lolcat}/bin/lolcat ''; - networking = { - hostName = "my-microvm"; - domain = "dmz"; - }; + networking.hostName = "my-microvm"; lab.vmMacAddress = "BA:DB:EE:F0:00:00"; }; diff --git a/nixos/modules/networking/default.nix b/nixos/modules/networking/default.nix index e1f8b71..5e7fa18 100644 --- a/nixos/modules/networking/default.nix +++ b/nixos/modules/networking/default.nix @@ -89,6 +89,7 @@ in { config = { networking = { + domain = if machine.type == "physical" then "hyp" else "dmz"; nftables.enable = true; useDHCP = machine.type == "virtual"; diff --git a/nixos/physical.nix b/nixos/physical.nix index 67b459a..35858fb 100644 --- a/nixos/physical.nix +++ b/nixos/physical.nix @@ -1,4 +1,4 @@ -{ pkgs, config, lib, modulesPath, machine, microvm, disko, agenix, machines, ... }: { +{ pkgs, config, lib, modulesPath, microvm, disko, agenix, machines, ... }: { imports = [ (modulesPath + "/installer/scan/not-detected.nix") microvm.nixosModules.host