DavHau
313db5643f
All checks were successful
buildbot/nix-build .#checks.aarch64-darwin.nixos-test_install_machine Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-test_install_machine Build done.
buildbot/nix-build .#checks.x86_64-linux.check-for-breakpoints Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-ts-api Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-iso-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.package-default Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-deb Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-fakeroot Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-git Build done.
buildbot/nix-build .#checks.x86_64-linux.package-module-docs Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-flash-installer Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-iso-installer Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-flash-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-cli-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-cli Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-archlinux Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-e2fsprogs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-rpm Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-test-backup Build done.
buildbot/nix-build .#checks.x86_64-linux."clan-dep-python3.11-qemu" Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-test-backup Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-nix Build done.
buildbot/nix-build .#checks.x86_64-linux.renderClanOptions Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-openssh Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-webview-ui Build done.
buildbot/nix-build .#checks.x86_64-linux."clan-dep-python3.11-mypy" Build done.
buildbot/nix-build .#checks.x86_64-linux.deltachat Build done.
buildbot/nix-build .#checks.x86_64-linux.borgbackup Build done.
buildbot/nix-build .#checks.x86_64-linux.matrix-synapse Build done.
buildbot/nix-build .#checks.x86_64-linux.package-editor Build done.
buildbot/nix-build .#checks.x86_64-linux.package-merge-after-ci Build done.
buildbot/nix-build .#checks.x86_64-linux.package-zt-tcp-relay Build done.
buildbot/nix-build .#checks.x86_64-linux.postgresql Build done.
buildbot/nix-build .#checks.x86_64-linux.package-function-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.secrets Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-rsync Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-sops Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-bash Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-test-backup Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-sshpass Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-zbar Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-apk Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-age Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-tor Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-app-no-breakpoints Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-default Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-clan-cli Build done.
buildbot/nix-build .#checks.x86_64-linux.container Build done.
buildbot/nix-build .#checks.x86_64-linux.lib-jsonschema-example-valid Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-app-pytest Build done.
buildbot/nix-build .#checks.x86_64-linux.lib-jsonschema-nix-unit-tests Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-test_install_machine Build done.
buildbot/nix-build .#checks.x86_64-linux.package-deploy-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.module-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.package-impure-checks Build done.
buildbot/nix-build .#checks.x86_64-linux.treefmt Build done.
buildbot/nix-build .#checks.x86_64-linux.package-moonlight-sunshine-accept Build done.
buildbot/nix-build .#checks.x86_64-linux.package-pending-reviews Build done.
buildbot/nix-build .#checks.x86_64-linux.package-tea-create-pr Build done.
buildbot/nix-build .#checks.x86_64-linux.package-zerotier-members Build done.
buildbot/nix-build .#checks.x86_64-linux.package-zerotierone Build done.
buildbot/nix-build .#checks.x86_64-linux.package-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-pytest-without-core Build done.
buildbot/nix-build .#checks.x86_64-linux.package-webview-ui Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-app Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-flash-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-iso-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.template-minimal Build done.
buildbot/nix-build .#checks.x86_64-linux.package-module-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.wayland-proxy-virtwl Build done.
buildbot/nix-build .#checks.x86_64-linux.zt-tcp-relay Build done.
buildbot/nix-build .#checks.x86_64-linux.package-iso-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.syncthing Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-clan-app Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-pytest-with-core Build done.
checks / checks-impure (pull_request) Successful in 2m10s
buildbot/nix-build .#checks.x86_64-linux.package-gui-install-test-ubuntu-22-04 Build done.
buildbot/nix-build .#checks.x86_64-linux.test-backups Build done.
buildbot/nix-build .#checks.x86_64-linux.flash Build done.
buildbot/nix-build .#checks.x86_64-linux.test-installation Build done.
buildbot/nix-eval Build done.
260 lines
7.2 KiB
Nix
260 lines
7.2 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
pkgs,
|
|
options,
|
|
extendModules,
|
|
modulesPath,
|
|
...
|
|
}:
|
|
let
|
|
# Flatten the list of state folders into a single list
|
|
stateFolders = lib.flatten (
|
|
lib.mapAttrsToList (_item: attrs: attrs.folders) config.clan.core.state
|
|
);
|
|
|
|
vmModule = {
|
|
imports = [
|
|
(modulesPath + "/virtualisation/qemu-vm.nix")
|
|
./serial.nix
|
|
];
|
|
|
|
# required for issuing shell commands via qga
|
|
services.qemuGuest.enable = true;
|
|
|
|
# required to react to system_powerdown qmp command
|
|
# Some desktop managers like xfce override the poweroff signal and therefore
|
|
# make it impossible to handle it via 'logind' directly.
|
|
services.acpid.enable = true;
|
|
services.acpid.handlers.power.event = "button/power.*";
|
|
services.acpid.handlers.power.action = "poweroff";
|
|
|
|
# only works on x11
|
|
services.spice-vdagentd.enable = config.services.xserver.enable;
|
|
|
|
boot.initrd.systemd.enable = true;
|
|
|
|
# currently needed for system.etc.overlay.enable
|
|
boot.kernelPackages = pkgs.linuxPackages_latest;
|
|
|
|
boot.initrd.systemd.storePaths = [
|
|
pkgs.util-linux
|
|
pkgs.e2fsprogs
|
|
];
|
|
boot.initrd.systemd.emergencyAccess = true;
|
|
|
|
# sysusers is faster than nixos's perl scripts
|
|
# and doesn't require state.
|
|
systemd.sysusers.enable = true;
|
|
users.mutableUsers = false;
|
|
users.allowNoPasswordLogin = true;
|
|
|
|
boot.initrd.kernelModules = [ "virtiofs" ];
|
|
virtualisation.writableStore = false;
|
|
virtualisation.fileSystems = lib.mkForce (
|
|
{
|
|
"/nix/store" = {
|
|
device = "nix-store";
|
|
options = [
|
|
"x-systemd.requires=systemd-modules-load.service"
|
|
"ro"
|
|
];
|
|
fsType = "virtiofs";
|
|
};
|
|
|
|
"/" = {
|
|
device = "/dev/vda";
|
|
fsType = "ext4";
|
|
options = [
|
|
"defaults"
|
|
"x-systemd.makefs"
|
|
"nobarrier"
|
|
"noatime"
|
|
"nodiratime"
|
|
"data=writeback"
|
|
"discard"
|
|
];
|
|
};
|
|
|
|
"/vmstate" = {
|
|
device = "/dev/vdb";
|
|
options = [
|
|
"x-systemd.makefs"
|
|
"noatime"
|
|
"nodiratime"
|
|
"discard"
|
|
];
|
|
noCheck = true;
|
|
fsType = "ext4";
|
|
};
|
|
|
|
${config.clan.core.secretsUploadDirectory} = {
|
|
device = "secrets";
|
|
fsType = "9p";
|
|
neededForBoot = true;
|
|
options = [
|
|
"trans=virtio"
|
|
"version=9p2000.L"
|
|
"cache=loose"
|
|
];
|
|
};
|
|
}
|
|
// lib.listToAttrs (
|
|
map (
|
|
folder:
|
|
lib.nameValuePair folder {
|
|
device = "/vmstate${folder}";
|
|
fsType = "none";
|
|
options = [ "bind" ];
|
|
}
|
|
) stateFolders
|
|
)
|
|
);
|
|
};
|
|
|
|
# We cannot simply merge the VM config into the current system config, because
|
|
# it is not necessarily a VM.
|
|
# Instead we use extendModules to create a second instance of the current
|
|
# system configuration, and then merge the VM config into that.
|
|
vmConfig = extendModules { modules = [ vmModule ]; };
|
|
in
|
|
{
|
|
options = {
|
|
clan.virtualisation = {
|
|
cores = lib.mkOption {
|
|
type = lib.types.ints.positive;
|
|
default = 1;
|
|
description = ''
|
|
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 = ''
|
|
The memory size in megabytes of the virtual machine.
|
|
'';
|
|
};
|
|
|
|
graphics = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = ''
|
|
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.
|
|
'';
|
|
};
|
|
|
|
waypipe = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
description = ''
|
|
Whether to use waypipe for native wayland passthrough, or not.
|
|
'';
|
|
};
|
|
};
|
|
# All important VM config variables needed by the vm runner
|
|
# this is really just a remapping of values defined elsewhere
|
|
# and therefore not intended to be set by the user
|
|
clan.core.vm.inspect = {
|
|
clan_name = lib.mkOption {
|
|
type = lib.types.str;
|
|
internal = true;
|
|
readOnly = true;
|
|
description = ''
|
|
the name of the clan
|
|
'';
|
|
};
|
|
memory_size = lib.mkOption {
|
|
type = lib.types.int;
|
|
internal = true;
|
|
readOnly = true;
|
|
description = ''
|
|
the amount of memory to allocate to the vm
|
|
'';
|
|
};
|
|
cores = lib.mkOption {
|
|
type = lib.types.int;
|
|
internal = true;
|
|
readOnly = true;
|
|
description = ''
|
|
the number of cores to allocate to the vm
|
|
'';
|
|
};
|
|
graphics = lib.mkOption {
|
|
type = lib.types.bool;
|
|
internal = true;
|
|
readOnly = true;
|
|
description = ''
|
|
whether to enable graphics for the vm
|
|
'';
|
|
};
|
|
waypipe = lib.mkOption {
|
|
type = lib.types.bool;
|
|
internal = true;
|
|
readOnly = true;
|
|
description = ''
|
|
whether to enable native wayland window passthrough with waypipe for the vm
|
|
'';
|
|
};
|
|
machine_icon = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.path;
|
|
internal = true;
|
|
readOnly = true;
|
|
description = ''
|
|
the location of the clan icon
|
|
'';
|
|
};
|
|
machine_name = lib.mkOption {
|
|
type = lib.types.str;
|
|
internal = true;
|
|
readOnly = true;
|
|
description = ''
|
|
the name of the vm
|
|
'';
|
|
};
|
|
machine_description = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.str;
|
|
internal = true;
|
|
readOnly = true;
|
|
description = ''
|
|
the description of the vm
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = {
|
|
# for clan vm inspect
|
|
clan.core.vm.inspect = {
|
|
clan_name = config.clan.core.clanName;
|
|
machine_icon = config.clan.core.machineIcon or config.clan.core.clanIcon;
|
|
machine_name = config.clan.core.machineName;
|
|
machine_description = config.clan.core.machineDescription;
|
|
memory_size = config.clan.virtualisation.memorySize;
|
|
inherit (config.clan.virtualisation) cores graphics waypipe;
|
|
};
|
|
# for clan vm create
|
|
system.clan.vm = {
|
|
create = pkgs.writeText "vm.json" (
|
|
builtins.toJSON {
|
|
initrd = "${vmConfig.config.system.build.initialRamdisk}/${vmConfig.config.system.boot.loader.initrdFile}";
|
|
toplevel = vmConfig.config.system.build.toplevel;
|
|
regInfo = (pkgs.closureInfo { rootPaths = vmConfig.config.virtualisation.additionalPaths; });
|
|
inherit (config.clan.virtualisation) memorySize cores graphics;
|
|
}
|
|
);
|
|
};
|
|
|
|
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;
|
|
};
|
|
};
|
|
}
|