summaryrefslogtreecommitdiffstats
path: root/nixos
diff options
context:
space:
mode:
authorSandro <sandro.jaeckel@gmail.com>2024-06-03 00:12:40 +0200
committerGitHub <noreply@github.com>2024-06-03 00:12:40 +0200
commit1e8d02875fcf6717d411ca053c929ce6b13d2aa4 (patch)
tree79c7f41473c6895952e21f8ef7a1013856692722 /nixos
parent778a1f2c47fe5a43e43264d23efc7118553aec5f (diff)
parent523f157dba0a1eec1a42090fcd5bc58b71593fbd (diff)
Merge pull request #307287 from illustris/proxmox-vma
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/virtualisation/proxmox-image.nix83
1 files changed, 53 insertions, 30 deletions
diff --git a/nixos/modules/virtualisation/proxmox-image.nix b/nixos/modules/virtualisation/proxmox-image.nix
index 6349bcef99e6..01ad86c08cd7 100644
--- a/nixos/modules/virtualisation/proxmox-image.nix
+++ b/nixos/modules/virtualisation/proxmox-image.nix
@@ -16,7 +16,7 @@ with lib;
};
scsihw = mkOption {
type = types.str;
- default = "virtio-scsi-pci";
+ default = "virtio-scsi-single";
example = "lsi";
description = ''
SCSI controller type. Must be one of the supported values given in
@@ -158,6 +158,31 @@ with lib;
any specific VMID.
'';
};
+ cloudInit = {
+ enable = mkOption {
+ type = types.bool;
+ default = true;
+ description = ''
+ Whether the VM should accept cloud init configurations from PVE.
+ '';
+ };
+ defaultStorage = mkOption {
+ default = "local-lvm";
+ example = "tank";
+ type = types.str;
+ description = ''
+ Default storage name for cloud init drive.
+ '';
+ };
+ device = mkOption {
+ default = "ide2";
+ example = "scsi0";
+ type = types.str;
+ description = ''
+ Bus/device to which the cloud init drive is attached.
+ '';
+ };
+ };
};
config = let
@@ -216,37 +241,21 @@ with lib;
seccompSupport = false;
guestAgentSupport = false;
}).overrideAttrs ( super: rec {
-
- version = "7.2.1";
+ # Check https://github.com/proxmox/pve-qemu/tree/master for the version
+ # of qemu and patch to use
+ version = "8.1.5";
src = pkgs.fetchurl {
- url= "https://download.qemu.org/qemu-${version}.tar.xz";
- sha256 = "sha256-jIVpms+dekOl/immTN1WNwsMLRrQdLr3CYqCTReq1zs=";
+ url = "https://download.qemu.org/qemu-${version}.tar.xz";
+ hash = "sha256-l2Ox7+xP1JeWtQgNCINRLXDLY4nq1lxmHMNoalIjKJY=";
};
patches = [
# Proxmox' VMA tool is published as a particular patch upon QEMU
- (pkgs.fetchpatch {
- url =
- let
- rev = "abb04bb6272c1202ca9face0827917552b9d06f6";
- path = "debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch";
- in "https://git.proxmox.com/?p=pve-qemu.git;a=blob_plain;hb=${rev};f=${path}";
- hash = "sha256-3d0HHdvaExCry6zcULnziYnWIAnn24vECkI4sjj2BMg=";
- })
-
- # Proxmox' VMA tool uses O_DIRECT which fails on tmpfs
- # Filed to upstream issue tracker: https://bugzilla.proxmox.com/show_bug.cgi?id=4710
- (pkgs.writeText "inline.patch" ''
- --- a/vma-writer.c 2023-05-01 15:11:13.361341177 +0200
- +++ b/vma-writer.c 2023-05-01 15:10:51.785293129 +0200
- @@ -306,7 +306,7 @@
- /* try to use O_NONBLOCK */
- fcntl(vmaw->fd, F_SETFL, fcntl(vmaw->fd, F_GETFL)|O_NONBLOCK);
- } else {
- - oflags = O_NONBLOCK|O_DIRECT|O_WRONLY|O_EXCL;
- + oflags = O_NONBLOCK|O_WRONLY|O_EXCL;
- vmaw->fd = qemu_create(filename, oflags, 0644, errp);
- }
- '')
+ "${pkgs.fetchFromGitHub {
+ owner = "proxmox";
+ repo = "pve-qemu";
+ rev = "71dd2d48f9122e60e4c0a8480122a27aab15dc70";
+ hash = "sha256-Q8AxNv4geDdlbVIWphRO5P3ESo0SGgvUpVPmPJzubJM=";
+ }}/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch"
];
buildInputs = super.buildInputs ++ [ pkgs.libuuid ];
@@ -262,7 +271,7 @@ with lib;
mv "vzdump-qemu-${cfg.filenameSuffix}.vma.zst" $out/
mkdir -p $out/nix-support
- echo "file vma $out/vzdump-qemu-${cfg.filenameSuffix}.vma.zst" >> $out/nix-support/hydra-build-products
+ echo "file vma $out/vzdump-qemu-${cfg.filenameSuffix}.vma.zst" > $out/nix-support/hydra-build-products
'';
inherit (cfg.qemuConf) additionalSpace diskSize bootSize;
format = "raw";
@@ -298,6 +307,20 @@ with lib;
fsType = "vfat";
};
- services.qemuGuest.enable = lib.mkDefault true;
+ networking = mkIf cfg.cloudInit.enable {
+ hostName = mkForce "";
+ useDHCP = false;
+ };
+
+ services = {
+ cloud-init = mkIf cfg.cloudInit.enable {
+ enable = true;
+ network.enable = true;
+ };
+ sshd.enable = mkDefault true;
+ qemuGuest.enable = true;
+ };
+
+ proxmox.qemuExtraConf.${cfg.cloudInit.device} = "${cfg.cloudInit.defaultStorage}:vm-9999-cloudinit,media=cdrom";
};
}