nixos-generators icon indicating copy to clipboard operation
nixos-generators copied to clipboard

Expose Storage Options in proxmox.nix

Open reinthal opened this issue 1 year ago • 0 comments

Feature added

  • Exposes the upstream options to configure underlying storage.

What problem does it solve?

When Proxmox does not have local-lvm as a default storage then qmrestore fails.

restore vma archive: zstd -q -d -c /root/vzdump-qemu-nixos-24.11.20240921.9357f4f.vma.zst | vma extract -v -r /var/tmp/vzdumptmp906885.fifo - /var/tmp/vzdumptmp906885
CFG: size: 401 name: qemu-server.conf
DEV: dev_id=1 size: 21474836480 devname: drive-virtio0
CTIME: Mon Sep 23 15:15:37 2024
new volume ID is 'local-zfs:vm-9604-cloudinit'
temporary volume 'local-zfs:vm-9604-cloudinit' sucessfuly removed
no lock found trying to remove 'create'  lock
error before or during data restore, some or all disks were not completely restored. VM 9604 state is NOT cleaned up.

TASK ERROR: command 'set -o pipefail && zstd -q -d -c /root/vzdump-qemu-nixos-24.11.20240921.9357f4f.vma.zst | vma extract -v -r /var/tmp/vzdumptmp906885.fifo - /var/tmp/vzdumptmp906885' failed: storage 'local-lvm' is not available on node 'pve'

steps to reproduce

Test setting virtio0 to a non-existing storage device. For exampl, use the following flake and set the device using the PRs exposed functionality

 {
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
    nixos-generators = {
      url = "github:reinthal/nixos-generators";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  outputs = {
    nixpkgs,
    nixos-generators,
    ...
  }: let
    system = "x86_64-linux";
  in {
    packages.x86_64-linux = {
      proxmox = nixos-generators.nixosGenerate {
        system = "${system}";
        specialArgs = {
          diskSize = "20480";
          virtio0 = "local-zfs:vm-9999-disk-0";
          cloudInitDefaultStorage = "local-zfs";
        };
        modules = [
          ({...}: {nix.registry.nixpkgs.flake = nixpkgs;})
          ./server
        ];
        format = "proxmox";
      };

      proxmox-lxc = nixos-generators.nixosGenerate {
        system = "${system}";
        modules = [
          ({...}: {nix.registry.nixpkgs.flake = nixpkgs;})
          ./server
        ];
        format = "proxmox-lxc";
      };
    };
  };
}

reinthal avatar Sep 23 '24 13:09 reinthal