From 42128ebbe19d0aa3841245a423aeb6636c9b23d3 Mon Sep 17 00:00:00 2001 From: Grisha Shipunov Date: Sun, 19 Jan 2025 20:38:22 +0100 Subject: move microvms to hosts folder --- flake.nix | 4 +-- hosts/auth/default.nix | 78 +++++++++++++++++++++++++++++++++++++++++++ hosts/auth/keycloak.nix | 18 ++++++++++ hosts/radicale/default.nix | 74 ++++++++++++++++++++++++++++++++++++++++ microvms/auth/default.nix | 78 ------------------------------------------- microvms/auth/keycloak.nix | 18 ---------- microvms/radicale/default.nix | 74 ---------------------------------------- 7 files changed, 172 insertions(+), 172 deletions(-) create mode 100644 hosts/auth/default.nix create mode 100644 hosts/auth/keycloak.nix create mode 100644 hosts/radicale/default.nix delete mode 100644 microvms/auth/default.nix delete mode 100644 microvms/auth/keycloak.nix delete mode 100644 microvms/radicale/default.nix diff --git a/flake.nix b/flake.nix index ecae4b7..77e0dd8 100644 --- a/flake.nix +++ b/flake.nix @@ -107,7 +107,7 @@ sops-nix.nixosModules.sops microvm.nixosModules.microvm - ./microvms/auth + ./hosts/auth ./modules/server ./modules/wg ]; @@ -120,7 +120,7 @@ sops-nix.nixosModules.sops microvm.nixosModules.microvm - ./microvms/radicale + ./hosts/radicale ./modules/server ./modules/wg ]; diff --git a/hosts/auth/default.nix b/hosts/auth/default.nix new file mode 100644 index 0000000..b4c23f1 --- /dev/null +++ b/hosts/auth/default.nix @@ -0,0 +1,78 @@ +{ config, lib, ... }: +let + mac = "02:00:00:00:00:01"; +in +{ + imports = [ + ./keycloak.nix + ]; + sops.defaultSopsFile = ../../secrets/auth/secrets.yaml; + sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; + + sops.secrets = { + "wg/0xa-proxy" = { + owner = config.users.users.systemd-network.name; + }; + "keycloak/db_pass" = { }; + }; + + microvm = { + hypervisor = "qemu"; + mem = 2 * 1024; + vcpu = 2; + interfaces = [ + { + type = "tap"; + id = "uvm-auth"; + mac = mac; + } + ]; + shares = + [ + { + source = "/nix/store"; + mountPoint = "/nix/.ro-store"; + tag = "store"; + proto = "virtiofs"; + socket = "store.socket"; + } + ] + ++ map + (dir: { + source = dir; + mountPoint = "/${dir}"; + tag = dir; + proto = "virtiofs"; + socket = "${dir}.socket"; + }) + [ + "etc" + "var" + "home" + ]; + }; + + networking.useNetworkd = true; + networking.firewall.enable = lib.mkForce false; # firewalling done by the host + + systemd.network = { + enable = true; + networks."11-host" = { + matchConfig.MACAddress = mac; + networkConfig = { + Address = "10.99.99.11/24"; + DHCP = "no"; + }; + routes = [ + { + Gateway = "10.99.99.1"; + Destination = "0.0.0.0/0"; + Metric = 1024; + } + ]; + }; + }; + + networking.hostName = "auth"; + system.stateVersion = "24.11"; +} diff --git a/hosts/auth/keycloak.nix b/hosts/auth/keycloak.nix new file mode 100644 index 0000000..de537ef --- /dev/null +++ b/hosts/auth/keycloak.nix @@ -0,0 +1,18 @@ +{ config, ... }: +{ + services.keycloak = { + enable = true; + database = { + type = "postgresql"; + createLocally = true; + passwordFile = config.sops.secrets."keycloak/db_pass".path; + }; + settings = { + hostname = "https://auth.oxapentane.com"; + http-port = 38080; + http-enabled = true; + proxy-headers = "xforwarded"; + proxy-trusted-addresses = "10.89.88.0/24,fd31:185d:722f::/48"; + }; + }; +} diff --git a/hosts/radicale/default.nix b/hosts/radicale/default.nix new file mode 100644 index 0000000..7ed8f11 --- /dev/null +++ b/hosts/radicale/default.nix @@ -0,0 +1,74 @@ +{ config, lib, ... }: +let + mac = "02:00:00:00:00:02"; +in +{ + sops.defaultSopsFile = ../../secrets/radicale/secrets.yaml; + sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; + + sops.secrets = { + "wg/0xa-proxy" = { + owner = config.users.users.systemd-network.name; + }; + }; + + microvm = { + hypervisor = "qemu"; + mem = 1 * 1024; + vcpu = 1; + interfaces = [ + { + type = "tap"; + id = "uvm-radicale"; + mac = mac; + } + ]; + shares = + [ + { + source = "/nix/store"; + mountPoint = "/nix/.ro-store"; + tag = "store"; + proto = "virtiofs"; + socket = "store.socket"; + } + ] + ++ map + (dir: { + source = dir; + mountPoint = "/${dir}"; + tag = dir; + proto = "virtiofs"; + socket = "${dir}.socket"; + }) + [ + "etc" + "var" + "home" + ]; + }; + + networking.useNetworkd = true; + networking.firewall.enable = lib.mkForce false; # firewalling done by the host + + systemd.network = { + enable = true; + networks."11-host" = { + matchConfig.MACAddress = mac; + networkConfig = { + Address = "10.99.99.12/24"; + DHCP = "no"; + }; + routes = [ + { + Gateway = "10.99.99.1"; + Destination = "0.0.0.0/0"; + Metric = 1024; + } + ]; + }; + }; + + networking.hostName = "radicale"; + system.stateVersion = "24.11"; +} diff --git a/microvms/auth/default.nix b/microvms/auth/default.nix deleted file mode 100644 index b4c23f1..0000000 --- a/microvms/auth/default.nix +++ /dev/null @@ -1,78 +0,0 @@ -{ config, lib, ... }: -let - mac = "02:00:00:00:00:01"; -in -{ - imports = [ - ./keycloak.nix - ]; - sops.defaultSopsFile = ../../secrets/auth/secrets.yaml; - sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; - - sops.secrets = { - "wg/0xa-proxy" = { - owner = config.users.users.systemd-network.name; - }; - "keycloak/db_pass" = { }; - }; - - microvm = { - hypervisor = "qemu"; - mem = 2 * 1024; - vcpu = 2; - interfaces = [ - { - type = "tap"; - id = "uvm-auth"; - mac = mac; - } - ]; - shares = - [ - { - source = "/nix/store"; - mountPoint = "/nix/.ro-store"; - tag = "store"; - proto = "virtiofs"; - socket = "store.socket"; - } - ] - ++ map - (dir: { - source = dir; - mountPoint = "/${dir}"; - tag = dir; - proto = "virtiofs"; - socket = "${dir}.socket"; - }) - [ - "etc" - "var" - "home" - ]; - }; - - networking.useNetworkd = true; - networking.firewall.enable = lib.mkForce false; # firewalling done by the host - - systemd.network = { - enable = true; - networks."11-host" = { - matchConfig.MACAddress = mac; - networkConfig = { - Address = "10.99.99.11/24"; - DHCP = "no"; - }; - routes = [ - { - Gateway = "10.99.99.1"; - Destination = "0.0.0.0/0"; - Metric = 1024; - } - ]; - }; - }; - - networking.hostName = "auth"; - system.stateVersion = "24.11"; -} diff --git a/microvms/auth/keycloak.nix b/microvms/auth/keycloak.nix deleted file mode 100644 index de537ef..0000000 --- a/microvms/auth/keycloak.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ config, ... }: -{ - services.keycloak = { - enable = true; - database = { - type = "postgresql"; - createLocally = true; - passwordFile = config.sops.secrets."keycloak/db_pass".path; - }; - settings = { - hostname = "https://auth.oxapentane.com"; - http-port = 38080; - http-enabled = true; - proxy-headers = "xforwarded"; - proxy-trusted-addresses = "10.89.88.0/24,fd31:185d:722f::/48"; - }; - }; -} diff --git a/microvms/radicale/default.nix b/microvms/radicale/default.nix deleted file mode 100644 index 7ed8f11..0000000 --- a/microvms/radicale/default.nix +++ /dev/null @@ -1,74 +0,0 @@ -{ config, lib, ... }: -let - mac = "02:00:00:00:00:02"; -in -{ - sops.defaultSopsFile = ../../secrets/radicale/secrets.yaml; - sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; - - sops.secrets = { - "wg/0xa-proxy" = { - owner = config.users.users.systemd-network.name; - }; - }; - - microvm = { - hypervisor = "qemu"; - mem = 1 * 1024; - vcpu = 1; - interfaces = [ - { - type = "tap"; - id = "uvm-radicale"; - mac = mac; - } - ]; - shares = - [ - { - source = "/nix/store"; - mountPoint = "/nix/.ro-store"; - tag = "store"; - proto = "virtiofs"; - socket = "store.socket"; - } - ] - ++ map - (dir: { - source = dir; - mountPoint = "/${dir}"; - tag = dir; - proto = "virtiofs"; - socket = "${dir}.socket"; - }) - [ - "etc" - "var" - "home" - ]; - }; - - networking.useNetworkd = true; - networking.firewall.enable = lib.mkForce false; # firewalling done by the host - - systemd.network = { - enable = true; - networks."11-host" = { - matchConfig.MACAddress = mac; - networkConfig = { - Address = "10.99.99.12/24"; - DHCP = "no"; - }; - routes = [ - { - Gateway = "10.99.99.1"; - Destination = "0.0.0.0/0"; - Metric = 1024; - } - ]; - }; - }; - - networking.hostName = "radicale"; - system.stateVersion = "24.11"; -} -- cgit v1.3.1