From 09abf3bee975f62297f14ccfe2343a61de5f3dd2 Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 4 Aug 2023 01:38:49 +0200 Subject: [PATCH] Improve Proxmox backup image generation --- configuration/common/default.nix | 5 +++-- configuration/nixos-generators/default.nix | 21 +++++++++++++++++++ configuration/proxmox-vm/default.nix | 4 ++++ .../proxmox-vm/hardware-configuration.nix | 3 +++ flake.lock | 12 +++++------ hosts.nix | 1 - 6 files changed, 37 insertions(+), 9 deletions(-) diff --git a/configuration/common/default.nix b/configuration/common/default.nix index 1b2b085..e28c38a 100644 --- a/configuration/common/default.nix +++ b/configuration/common/default.nix @@ -58,11 +58,12 @@ [Unit] Description=print-public-ssh-host-key.service Before=getty@tty1.service + After=sshd.service [Service] Type=oneshot - ExecStart=/run/current-system/sw/bin/bash -c "/run/current-system/sw/bin/echo ----- ED25519 PUBLIC SSH HOST KEY -----\ - && /run/current-system/sw/bin/cut -d ' ' -f 1-2 /etc/ssh/ssh_host_ed25519_key.pub" + ExecStart=/run/current-system/sw/bin/bash -c "/run/current-system/sw/bin/echo -e \"----- ED25519 PUBLIC SSH HOST KEY -----\ + \n$(/run/current-system/sw/bin/cut -d ' ' -f 1-2 /etc/ssh/ssh_host_ed25519_key.pub)\"" RemainAfterExit=no StandardOutput=tty ''; diff --git a/configuration/nixos-generators/default.nix b/configuration/nixos-generators/default.nix index 2cda85e..e392d53 100644 --- a/configuration/nixos-generators/default.nix +++ b/configuration/nixos-generators/default.nix @@ -10,5 +10,26 @@ firewall.enable = true; }; + proxmox = { + qemuConf = { + ostype = "l26"; + cores = 2; + memory = 1024; + bios = "seabios"; + # Option not available in 23.05 + # diskSize = "8096"; + virtio0 = "local-zfs:base-disk-0,discard=on"; + boot = "order=virtio0"; + net0 = "tag=999,virtio=00:00:00:00:00:00,bridge=vmbr0,firewall=1"; + agent = true; + }; + qemuExtraConf = { + cpu = "cputype=host,flags=+aes"; + onboot = 1; + machine = "q35"; + template = 1; + }; + }; + system.stateVersion = "23.05"; } diff --git a/configuration/proxmox-vm/default.nix b/configuration/proxmox-vm/default.nix index 47ed7df..4c5bc6e 100644 --- a/configuration/proxmox-vm/default.nix +++ b/configuration/proxmox-vm/default.nix @@ -1,5 +1,9 @@ { ... }: { + imports = [ + ./hardware-configuration.nix + ]; + # Enable console output on TTY1 and serial console boot.kernelParams = [ "console=tty1" diff --git a/configuration/proxmox-vm/hardware-configuration.nix b/configuration/proxmox-vm/hardware-configuration.nix index 5fbbefa..0d9fa83 100644 --- a/configuration/proxmox-vm/hardware-configuration.nix +++ b/configuration/proxmox-vm/hardware-configuration.nix @@ -1,11 +1,14 @@ { config, lib, modulesPath, ... }: { + # hardware-configuration.nix copied and adapted from the default configuration generated by nixos-generators + imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; boot = { initrd = { + # To use the VirtIO SCSI disks, add the "virtio_scsi" kernel module to availableKernelModules availableKernelModules = [ "uhci_hcd" "ehci_pci" "ahci" "virtio_pci" "virtio_blk" ]; kernelModules = [ ]; }; diff --git a/flake.lock b/flake.lock index 7668670..61c7311 100644 --- a/flake.lock +++ b/flake.lock @@ -38,11 +38,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1690726002, - "narHash": "sha256-cACz6jCJZtsZHGCJAN4vMobxzH5s6FCOTZHMrh/Hu0M=", + "lastModified": 1691016377, + "narHash": "sha256-Vvi49vIL2CzX5bsfE3qovcmzJpkfMo/Mx/coCbu5Jeo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "391e8db1f06c3f74c2d313a73135515023af3993", + "rev": "ad73028def6716978adaec5b0b7706edc611a83e", "type": "github" }, "original": { @@ -54,11 +54,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1690738238, - "narHash": "sha256-yUFU7PGQzOEDX2Y64QV7xNHkn3RjkOTqvZ5oW5gbgGY=", + "lastModified": 1691071044, + "narHash": "sha256-bYBWtupK/NO/diSpye8TP1E0IC7wj29y2q6blD0FtPk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6376df481833e5f2e83eade8d8f2d04beed007d0", + "rev": "2a1f1797be6e4125ade0be6ac32bb70106ff7245", "type": "github" }, "original": { diff --git a/hosts.nix b/hosts.nix index 1116370..ab1de0e 100644 --- a/hosts.nix +++ b/hosts.nix @@ -4,7 +4,6 @@ let environments = { "proxmox" = [ ./configuration/proxmox-vm - ./configuration/proxmox-vm/hardware-configuration.nix ]; }; generateDefaults = hosts: builtins.mapAttrs (name: {