From 2f73e6b472d89d5e52c697568f92422b101532b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 27 Sep 2023 14:31:19 +0200 Subject: [PATCH] drop requirement for importing qemu-vm.nix --- nixosModules/clanCore/vm.nix | 53 ++++++++++++++++--- pkgs/clan-cli/clan_cli/config/machine.py | 2 - .../tests/test_flake_with_core/flake.nix | 3 +- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/nixosModules/clanCore/vm.nix b/nixosModules/clanCore/vm.nix index 4382c8ca1..26a874f22 100644 --- a/nixosModules/clanCore/vm.nix +++ b/nixosModules/clanCore/vm.nix @@ -1,8 +1,47 @@ -{ config, options, lib, ... }: { - system.clan.vm.config = { - enabled = options.virtualisation ? cores; - } // (lib.optionalAttrs (options.virtualisation ? cores) { - inherit (config.virtualisation) cores graphics; - memory_size = config.virtualisation.memorySize; - }); +{ lib, config, options, ... }: +{ + options = { + clan.virtualisation = { + cores = lib.mkOption { + type = lib.types.ints.positive; + default = 1; + description = lib.mdDoc '' + Specify the number of cores the guest is permitted to use. + The number can be higher than the available cores on the + host system. + ''; + }; + + memorySize = lib.mkOption { + type = lib.types.ints.positive; + default = 1024; + description = lib.mdDoc '' + The memory size in megabytes of the virtual machine. + ''; + }; + + graphics = lib.mkOption { + type = lib.types.bool; + default = true; + description = lib.mdDoc '' + Whether to run QEMU with a graphics window, or in nographic mode. + Serial console will be enabled on both settings, but this will + change the preferred console. + ''; + }; + }; + }; + + config = { + system.clan.vm.config = { + inherit (config.clan.virtualisation) cores graphics; + memory_size = config.clan.virtualisation.memorySize; + }; + + virtualisation = lib.optionalAttrs (options.virtualisation ? cores) { + memorySize = lib.mkDefault config.clan.virtualisation.memorySize; + graphics = lib.mkDefault config.clan.virtualisation.graphics; + cores = lib.mkDefault config.clan.virtualisation.cores; + }; + }; } diff --git a/pkgs/clan-cli/clan_cli/config/machine.py b/pkgs/clan-cli/clan_cli/config/machine.py index 90563194a..c309b36f9 100644 --- a/pkgs/clan-cli/clan_cli/config/machine.py +++ b/pkgs/clan-cli/clan_cli/config/machine.py @@ -52,8 +52,6 @@ def schema_for_machine(machine_name: str, flake: Optional[Path] = None) -> dict: flags=[ "--impure", "--show-trace", - "--extra-experimental-features", - "nix-command flakes", "--expr", f""" let diff --git a/pkgs/clan-cli/tests/test_flake_with_core/flake.nix b/pkgs/clan-cli/tests/test_flake_with_core/flake.nix index c4e03bd72..6a645cd42 100644 --- a/pkgs/clan-cli/tests/test_flake_with_core/flake.nix +++ b/pkgs/clan-cli/tests/test_flake_with_core/flake.nix @@ -10,8 +10,7 @@ clan = clan-core.lib.buildClan { directory = self; machines = { - vm1 = { modulesPath, lib, ... }: { - imports = [ "${toString modulesPath}/virtualisation/qemu-vm.nix" ]; + vm1 = { lib, ... }: { clan.networking.deploymentAddress = "__CLAN_DEPLOYMENT_ADDRESS__"; sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__"; system.stateVersion = lib.version;