drop requirement for importing qemu-vm.nix

This commit is contained in:
Jörg Thalheim
2023-09-27 14:31:19 +02:00
parent eba8be8006
commit ded120d065
3 changed files with 47 additions and 11 deletions

View File

@@ -1,8 +1,47 @@
{ config, options, lib, ... }: { { lib, config, options, ... }:
system.clan.vm.config = { {
enabled = options.virtualisation ? cores; options = {
} // (lib.optionalAttrs (options.virtualisation ? cores) { clan.virtualisation = {
inherit (config.virtualisation) cores graphics; cores = lib.mkOption {
memory_size = config.virtualisation.memorySize; 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;
};
};
} }

View File

@@ -52,8 +52,6 @@ def schema_for_machine(machine_name: str, flake: Optional[Path] = None) -> dict:
flags=[ flags=[
"--impure", "--impure",
"--show-trace", "--show-trace",
"--extra-experimental-features",
"nix-command flakes",
"--expr", "--expr",
f""" f"""
let let

View File

@@ -10,8 +10,7 @@
clan = clan-core.lib.buildClan { clan = clan-core.lib.buildClan {
directory = self; directory = self;
machines = { machines = {
vm1 = { modulesPath, lib, ... }: { vm1 = { lib, ... }: {
imports = [ "${toString modulesPath}/virtualisation/qemu-vm.nix" ];
clan.networking.deploymentAddress = "__CLAN_DEPLOYMENT_ADDRESS__"; clan.networking.deploymentAddress = "__CLAN_DEPLOYMENT_ADDRESS__";
sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__"; sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__";
system.stateVersion = lib.version; system.stateVersion = lib.version;