nix/nixos-module/server/qemu: move stuff here

This commit is contained in:
Astro 2021-04-11 00:35:10 +02:00
parent 17e9cbbb1a
commit 51460ad776
4 changed files with 34 additions and 19 deletions

View File

@ -18,6 +18,7 @@ in {
optionals (hostConfig.role == "server") [
./server/lxc-containers.nix
./server/network.nix
./server/qemu.nix
] ++
optionals (hostName == "server2") [
./server/server2.nix

View File

@ -33,20 +33,5 @@
users.users.root.initialHashedPassword = "";
# for vm-packages
virtualisation = lib.optionalAttrs (builtins.hasAttr "qemu" options.virtualisation) {
# larger than the defaults
memorySize = 8192;
cores = 2;
diskSize = 8192;
# 9P performance optimization that quelches a qemu warning
msize = 65536;
# allow building packages
writableStore = true;
# keep the store paths built inside the VM across reboots
writableStoreUseTmpfs = false;
qemu.options = [ "-enable-kvm" ];
};
system.stateVersion = "20.09";
}

View File

@ -70,10 +70,6 @@ in
);
networks = {
eth = {
matchConfig.Name = "eth*";
networkConfig.Bond = "bond0";
};
en = {
# physical ethernet ports
matchConfig.Name = "en*";

View File

@ -0,0 +1,33 @@
# Options for running under qemu (vm-packages)
{ inputs, lib, options, ... }:
{
# Get internet from qemu user networking
systemd.network = lib.optionalAttrs (options.virtualisation ? qemu) {
networks."00-qemu" = {
matchConfig.Name = "en*";
networkConfig.DHCP = "yes";
};
netdevs.bond0.bondConfig.MinLinks = 0;
};
# for vm-packages
virtualisation = lib.optionalAttrs (options.virtualisation ? qemu) {
# larger than the defaults
memorySize = 8192;
cores = 2;
diskSize = 8192;
# 9P performance optimization that quelches a qemu warning
msize = 65536;
# allow building packages
writableStore = true;
# keep the store paths built inside the VM across reboots
writableStoreUseTmpfs = false;
qemu.options = [ "-enable-kvm" ];
};
# Let the nix registry point to the state of your local checkout
# when running the virtual machine.
nix.registry = lib.optionalAttrs (options.virtualisation ? qemu) {
zentralwerk-network.flake = inputs.self;
};
}