hosts/caesar: initial networking config; separate virt

This commit is contained in:
NotAShelf 2024-08-18 17:12:43 +03:00
parent 7bf5168b53
commit 7599920aad
No known key found for this signature in database
GPG key ID: AF26552424E53993
2 changed files with 43 additions and 31 deletions

View file

@ -1,17 +1,16 @@
{
config,
lib,
pkgs,
modulesPath,
lib,
...
}: {
imports = [
(modulesPath + "/virtualisation/qemu-vm.nix")
];
}: let
inherit (lib.modules) mkForce;
inherit (lib.meta) getExe;
in {
imports = [./virt.nix];
config = {
zramSwap.enable = lib.mkForce false;
services.thermald.enable = lib.mkForce false;
zramSwap.enable = mkForce false;
services.thermald.enable = mkForce false;
boot = {
initrd.supportedFilesystems = ["ext4"];
@ -23,31 +22,10 @@
enable = true;
enableCompletion = true;
promptInit = ''
eval "$(${lib.getExe pkgs.starship} init zsh)"
eval "$(${getExe pkgs.starship} init zsh)"
'';
};
virtualisation = {
memorySize = 8000;
diskSize = 200000;
cores = 8;
# fs
useDefaultFilesystems = false;
rootDevice = "/dev/disk/by-label/NIXOS_ROOT";
fileSystems = {
"/" = {
device = "${config.virtualisation.rootDevice}";
fsType = "xfs";
};
};
interfaces = {
vm0.vlan = 1;
};
};
boot.initrd.preLVMCommands = with pkgs; ''
if ! test -b /dev/vda2; then
${pkgs.parted}/bin/parted --script /dev/vda -- mklabel msdos

34
hosts/caesar/virt.nix Normal file
View file

@ -0,0 +1,34 @@
{
config,
modulesPath,
...
}: {
imports = [(modulesPath + "/virtualisation/qemu-vm.nix")];
virtualisation = {
memorySize = 8000;
diskSize = 200000;
cores = 8;
# fs
useDefaultFilesystems = false;
rootDevice = "/dev/disk/by-label/NIXOS_ROOT";
fileSystems = {
"/" = {
device = "${config.virtualisation.rootDevice}";
fsType = "xfs";
};
};
interfaces = {
vm0.vlan = 1;
};
qemu.networkingOptions = [
"-net nic,netdev=user.0,model=virtio"
"-netdev user,id=user.0,\${QEMU_NET_OPTS:+,$QEMU_NET_OPTS}"
"hostfwd=tcp::2222-:2222"
];
};
}