From d48bfa332c0ce12dcff8184a8f6c3d64cedeba46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Barnouin?= Date: Thu, 12 Dec 2024 11:54:49 +0100 Subject: [PATCH] Separate LXC, VM and microvm configs (it's getting ugly, need to tidy things up soon) --- flake.nix | 7 +------ services/minimalConfig/default.nix | 5 ++++- services/minimalConfig/vm.nix | 12 ++++++++++++ systems/microvm.nix | 4 ++-- 4 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 services/minimalConfig/vm.nix diff --git a/flake.nix b/flake.nix index 3d2bc1c..8844cde 100644 --- a/flake.nix +++ b/flake.nix @@ -84,11 +84,6 @@ }; services.vm = { enable = true; - hostname = "jellyfin"; - vm_ip = "192.168.1.42"; - vm_cpu = 4; - vm_mem = 8192; - macAddr = "02:00:00:00:00:42"; }; } ]; @@ -144,7 +139,7 @@ proxy_ip = proxy_host; pgsql_ip = pgsql_host; }; - services.vm = { + services.micro_vm = { enable = true; hostname = "grafana"; vm_ip = "192.168.1.20"; diff --git a/services/minimalConfig/default.nix b/services/minimalConfig/default.nix index 8eb1549..fd83cb6 100644 --- a/services/minimalConfig/default.nix +++ b/services/minimalConfig/default.nix @@ -1,7 +1,10 @@ { config, pkgs, lib, inputs, modulesPath, ... }: { - imports = [ ./lxc.nix ]; + imports = [ + ./lxc.nix + ./vm.nix + ]; nix = { settings.experimental-features = [ "nix-command" "flakes" ]; diff --git a/services/minimalConfig/vm.nix b/services/minimalConfig/vm.nix new file mode 100644 index 0000000..96c3ff3 --- /dev/null +++ b/services/minimalConfig/vm.nix @@ -0,0 +1,12 @@ +{lib, config, modulesPath, ...}: +let + cfg = config.services.vm; +in +{ + options.services.vm = { + enable = lib.mkEnableOption "Enable LXC container config"; + }; + config = lib.mkIf cfg.enable { + services.cloud-init.network.enable = true; + }; +} diff --git a/systems/microvm.nix b/systems/microvm.nix index d7ef82a..5fd71c7 100644 --- a/systems/microvm.nix +++ b/systems/microvm.nix @@ -1,9 +1,9 @@ { inputs, lib, config, microvm, ... }: let - cfg = config.services.vm; + cfg = config.services.micro_vm; in { - options.services.vm = { + options.services.micro_vm = { enable = lib.mkEnableOption "Enable NixOS microvm config"; hostname = lib.mkOption { type = lib.types.str;