From a80eca86d57f92f1925a368d9951e8931f6c29b2 Mon Sep 17 00:00:00 2001 From: phaer Date: Mon, 7 Apr 2025 13:25:05 +0200 Subject: [PATCH 01/15] virtualisation/linode-config: drop "with; lib" --- nixos/modules/virtualisation/linode-config.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nixos/modules/virtualisation/linode-config.nix b/nixos/modules/virtualisation/linode-config.nix index a6dbe4cbb8f0..08a76437c882 100644 --- a/nixos/modules/virtualisation/linode-config.nix +++ b/nixos/modules/virtualisation/linode-config.nix @@ -1,10 +1,8 @@ { - config, lib, pkgs, ... }: -with lib; { imports = [ ../profiles/qemu-guest.nix ]; @@ -12,7 +10,7 @@ with lib; enable = true; settings.PermitRootLogin = "prohibit-password"; - settings.PasswordAuthentication = mkDefault false; + settings.PasswordAuthentication = lib.mkDefault false; }; networking = { @@ -40,7 +38,7 @@ with lib; autoResize = true; }; - swapDevices = mkDefault [ { device = "/dev/sdb"; } ]; + swapDevices = lib.mkDefault [ { device = "/dev/sdb"; } ]; # Enable LISH and Linode Booting w/ GRUB boot = { From 9e704d72636f87c111f5abbc5813f45bc2ac5628 Mon Sep 17 00:00:00 2001 From: phaer Date: Mon, 7 Apr 2025 13:44:11 +0200 Subject: [PATCH 02/15] virtualisation/linode-config: use mkImageMediaOverride... ...for filesystem options. Before this change, users would typically encounter conflicting option definitions when trying to build an image for a generic nixos closure, i.e. `nixos-rebuild build-image --image-variant linode --flake .#my-host` --- nixos/modules/virtualisation/linode-config.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/linode-config.nix b/nixos/modules/virtualisation/linode-config.nix index 08a76437c882..721a6f8bdc69 100644 --- a/nixos/modules/virtualisation/linode-config.nix +++ b/nixos/modules/virtualisation/linode-config.nix @@ -32,7 +32,7 @@ sysstat ]; - fileSystems."/" = { + fileSystems."/" = lib.mkImageMediaOverride { fsType = "ext4"; device = "/dev/sda"; autoResize = true; From ae0274015624d3fff799b622a5a56bd24681c247 Mon Sep 17 00:00:00 2001 From: phaer Date: Wed, 9 Apr 2025 11:18:36 +0200 Subject: [PATCH 03/15] virtualisation/proxmox-image: remove obsolete proxmox.qemuConf.diskSize usage This was an oversight in my commit d37a3ea1efddb9667bb308d43e81a06286fe696b, and results in the following eval warning when proxmox images are used: `Obsolete option `proxmox.qemuConf.diskSize' is used. It was renamed to `virtualisation.diskSize'.` --- nixos/modules/virtualisation/proxmox-image.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/proxmox-image.nix b/nixos/modules/virtualisation/proxmox-image.nix index cb83a9e5ef29..4e8d1e4c9174 100644 --- a/nixos/modules/virtualisation/proxmox-image.nix +++ b/nixos/modules/virtualisation/proxmox-image.nix @@ -306,7 +306,13 @@ with lib; '' ${vma}/bin/vma create "${config.image.baseName}.vma" \ -c ${ - cfgFile "qemu-server.conf" (cfg.qemuConf // cfg.qemuExtraConf) + cfgFile "qemu-server.conf" ( + (builtins.removeAttrs cfg.qemuConf [ "diskSize" ]) + // { + inherit (config.virtualisation) diskSize; + } + // cfg.qemuExtraConf + ) }/qemu-server.conf drive-virtio0=$diskImage rm $diskImage ${pkgs.zstd}/bin/zstd "${config.image.baseName}.vma" From 3718f356c08bc6d4fbcce96d48d9f26f416fd5a2 Mon Sep 17 00:00:00 2001 From: phaer Date: Fri, 11 Apr 2025 12:33:11 +0200 Subject: [PATCH 04/15] virtualisation/promxox-image: use mkImageMediaOverride... ...for filesystem options. Before this change, users would typically encounter conflicting option definitions when trying to build an image for a generic nixos closure, i.e. `nixos-rebuild build-image --image-variant proxmox --flake .#my-host` --- nixos/modules/virtualisation/proxmox-image.nix | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/nixos/modules/virtualisation/proxmox-image.nix b/nixos/modules/virtualisation/proxmox-image.nix index 4e8d1e4c9174..25aa3aee93c7 100644 --- a/nixos/modules/virtualisation/proxmox-image.nix +++ b/nixos/modules/virtualisation/proxmox-image.nix @@ -352,14 +352,16 @@ with lib; ]; }; - fileSystems."/" = { - device = "/dev/disk/by-label/nixos"; - autoResize = true; - fsType = "ext4"; - }; - fileSystems."/boot" = lib.mkIf hasBootPartition { - device = "/dev/disk/by-label/ESP"; - fsType = "vfat"; + fileSystems = lib.mkImageMediaOverride { + "/" = { + device = "/dev/disk/by-label/nixos"; + autoResize = true; + fsType = "ext4"; + }; + "/boot" = lib.mkIf hasBootPartition { + device = "/dev/disk/by-label/ESP"; + fsType = "vfat"; + }; }; networking = mkIf cfg.cloudInit.enable { From c5d383a797cd32a38bd810de253505afe101addd Mon Sep 17 00:00:00 2001 From: phaer Date: Wed, 9 Apr 2025 12:19:13 +0200 Subject: [PATCH 05/15] virtualisation/disk-image: use mkImageMediaOverride... ...for filesystem options. Before this change, users would typically encounter conflicting option definitions when trying to build an image for a generic nixos closure, i.e. `nixos-rebuild build-image --image-variant qemu --flake .#my-host` --- nixos/modules/virtualisation/disk-image.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/disk-image.nix b/nixos/modules/virtualisation/disk-image.nix index c524b6627113..ef73e6d4f74a 100644 --- a/nixos/modules/virtualisation/disk-image.nix +++ b/nixos/modules/virtualisation/disk-image.nix @@ -37,7 +37,7 @@ in boot.loader.systemd-boot.enable = lib.mkDefault cfg.efiSupport; boot.growPartition = lib.mkDefault true; - fileSystems = { + fileSystems = lib.mkImageMediaOverride { "/" = { device = "/dev/disk/by-label/nixos"; autoResize = true; From 864030e5e825ec11252811c5c8e20e238c92c220 Mon Sep 17 00:00:00 2001 From: phaer Date: Wed, 9 Apr 2025 12:23:40 +0200 Subject: [PATCH 06/15] virtualisation/vmware-image: use mkImageMediaOverride... ...for filesystem options. Before this change, users would typically encounter conflicting option definitions when trying to build an image for a generic nixos closure, i.e. `nixos-rebuild build-image --image-variant vmware --flake .#my-host` --- nixos/modules/virtualisation/vmware-image.nix | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/nixos/modules/virtualisation/vmware-image.nix b/nixos/modules/virtualisation/vmware-image.nix index 6eebc6910ff0..f44c4b5bae07 100644 --- a/nixos/modules/virtualisation/vmware-image.nix +++ b/nixos/modules/virtualisation/vmware-image.nix @@ -83,15 +83,17 @@ in inherit config lib pkgs; }; - fileSystems."/" = { - device = "/dev/disk/by-label/nixos"; - autoResize = true; - fsType = "ext4"; - }; + fileSystems = lib.mkImageMediaOverride { + "/" = { + device = "/dev/disk/by-label/nixos"; + autoResize = true; + fsType = "ext4"; + }; - fileSystems."/boot" = { - device = "/dev/disk/by-label/ESP"; - fsType = "vfat"; + "/boot" = { + device = "/dev/disk/by-label/ESP"; + fsType = "vfat"; + }; }; boot.growPartition = true; From 4327e179f77d4100e8803ea50e90ef81d7e3f507 Mon Sep 17 00:00:00 2001 From: phaer Date: Wed, 9 Apr 2025 12:27:04 +0200 Subject: [PATCH 07/15] virtualisation/virtualbox-image: use mkImageMediaOverride... ...for filesystem and options. Before this change, users would typically encounter conflicting option definitions when trying to build an image for a generic nixos closure, i.e. `nixos-rebuild build-image --image-variant virtualbox --flake .#my-host` --- nixos/modules/virtualisation/virtualbox-image.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/virtualbox-image.nix b/nixos/modules/virtualisation/virtualbox-image.nix index 26633731f647..17dfa17cfbbb 100644 --- a/nixos/modules/virtualisation/virtualbox-image.nix +++ b/nixos/modules/virtualisation/virtualbox-image.nix @@ -275,7 +275,7 @@ in }; fileSystems = - { + lib.mkImageMediaOverride { "/" = { device = "/dev/disk/by-label/nixos"; autoResize = true; From 2742c7163ad441ffae744c0615f73cb4301fa03d Mon Sep 17 00:00:00 2001 From: phaer Date: Wed, 9 Apr 2025 12:44:55 +0200 Subject: [PATCH 08/15] virtualisation/kubevirt: use mkImageMediaOverride... ...for filesystem options. Before this change, users would typically encounter conflicting option definitions when trying to build an image for a generic nixos closure, i.e. `nixos-rebuild build-image --image-variant kubevirt --flake .#my-host` --- nixos/modules/virtualisation/kubevirt.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/kubevirt.nix b/nixos/modules/virtualisation/kubevirt.nix index 5e855d3af06e..6e91a8b67c6f 100644 --- a/nixos/modules/virtualisation/kubevirt.nix +++ b/nixos/modules/virtualisation/kubevirt.nix @@ -12,7 +12,7 @@ ]; config = { - fileSystems."/" = { + fileSystems."/" = lib.mkImageMediaOverride { device = "/dev/disk/by-label/nixos"; fsType = "ext4"; autoResize = true; From 61ba0446582326e339c2dfbf2b96cc37b16db6f2 Mon Sep 17 00:00:00 2001 From: phaer Date: Wed, 9 Apr 2025 12:52:50 +0200 Subject: [PATCH 09/15] virtualisation/oci-common: use mkImageMediaOverride... ...for filesystem options. Before this change, users would typically encounter conflicting option definitions when trying to build an image for a generic nixos closure, i.e. `nixos-rebuild build-image --image-variant common --flake .#my-host` --- nixos/modules/virtualisation/oci-common.nix | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/nixos/modules/virtualisation/oci-common.nix b/nixos/modules/virtualisation/oci-common.nix index d92cda7de437..73b68c57f3e2 100644 --- a/nixos/modules/virtualisation/oci-common.nix +++ b/nixos/modules/virtualisation/oci-common.nix @@ -30,15 +30,17 @@ in boot.growPartition = true; - fileSystems."/" = { - device = "/dev/disk/by-label/nixos"; - fsType = "ext4"; - autoResize = true; - }; + fileSystems = lib.mkImageMediaOverride { + "/" = { + device = "/dev/disk/by-label/nixos"; + fsType = "ext4"; + autoResize = true; + }; - fileSystems."/boot" = lib.mkIf cfg.efi { - device = "/dev/disk/by-label/ESP"; - fsType = "vfat"; + "/boot" = lib.mkIf cfg.efi { + device = "/dev/disk/by-label/ESP"; + fsType = "vfat"; + }; }; boot.loader.efi.canTouchEfiVariables = false; From 2f7435b5caa75da83305d470fdcbcfbb71a8c47c Mon Sep 17 00:00:00 2001 From: phaer Date: Wed, 9 Apr 2025 15:48:41 +0200 Subject: [PATCH 10/15] virtualisation/hyperv-image: use mkImageMediaOverride... ...for filesystem options. Before this change, users would typically encounter conflicting option definitions when trying to build an image for a generic nixos closure, i.e. `nixos-rebuild build-image --image-variant hyperv --flake .#my-host` --- nixos/modules/virtualisation/hyperv-image.nix | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/nixos/modules/virtualisation/hyperv-image.nix b/nixos/modules/virtualisation/hyperv-image.nix index 8f77d384a9ba..f292a60d71cd 100644 --- a/nixos/modules/virtualisation/hyperv-image.nix +++ b/nixos/modules/virtualisation/hyperv-image.nix @@ -73,15 +73,17 @@ in inherit config lib pkgs; }; - fileSystems."/" = { - device = "/dev/disk/by-label/nixos"; - autoResize = true; - fsType = "ext4"; - }; + fileSystems = lib.mkImageMediaOverride { + "/" = { + device = "/dev/disk/by-label/nixos"; + autoResize = true; + fsType = "ext4"; + }; - fileSystems."/boot" = { - device = "/dev/disk/by-label/ESP"; - fsType = "vfat"; + "/boot" = { + device = "/dev/disk/by-label/ESP"; + fsType = "vfat"; + }; }; boot.growPartition = true; From a79571b081f6b813f76288134a1f2915e7d1986a Mon Sep 17 00:00:00 2001 From: phaer Date: Wed, 9 Apr 2025 16:03:06 +0200 Subject: [PATCH 11/15] virtualisation/azure-image: use mkImageMediaOverride... ...for filesystem options. Before this change, users would typically encounter conflicting option definitions when trying to build an image for a generic nixos closure, i.e. `nixos-rebuild build-image --image-variant azure --flake .#my-host` --- nixos/modules/virtualisation/azure-image.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/azure-image.nix b/nixos/modules/virtualisation/azure-image.nix index 252381d0f198..fe28efe624c5 100644 --- a/nixos/modules/virtualisation/azure-image.nix +++ b/nixos/modules/virtualisation/azure-image.nix @@ -113,7 +113,7 @@ in ''; }; - fileSystems = { + fileSystems = lib.mkImageMediaOverride { "/" = { device = "/dev/disk/by-label/${cfg.label}"; inherit (cfg) label; From bf2b3f02869b63dd6a56719373101b8d74c18f3c Mon Sep 17 00:00:00 2001 From: phaer Date: Fri, 11 Apr 2025 11:34:31 +0200 Subject: [PATCH 12/15] virtualisation/digital-ocean-config: use mkImageMediaOverride... ...for filesystem options. Before this change, users would typically encounter conflicting option definitions when trying to build an image for a generic nixos closure, i.e. `nixos-rebuild build-image --image-variant digital-ocean --flake .#my-host` --- nixos/modules/virtualisation/digital-ocean-config.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/digital-ocean-config.nix b/nixos/modules/virtualisation/digital-ocean-config.nix index a38d2d15ab84..14d9b3feb1e4 100644 --- a/nixos/modules/virtualisation/digital-ocean-config.nix +++ b/nixos/modules/virtualisation/digital-ocean-config.nix @@ -39,7 +39,7 @@ with lib; in mkMerge [ { - fileSystems."/" = lib.mkDefault { + fileSystems."/" = lib.mkImageMediaOverride { device = "/dev/disk/by-label/nixos"; autoResize = true; fsType = "ext4"; From 6f83796aa5fad00d64763ad3d95a82cf3584707c Mon Sep 17 00:00:00 2001 From: phaer Date: Fri, 11 Apr 2025 11:38:05 +0200 Subject: [PATCH 13/15] virtualisation/google-compute-config: use mkImageMediaOverride... ...for filesystem and bootloader options. Before this change, users would typically encounter conflicting option definitions when trying to build an image for a generic nixos closure, i.e. `nixos-rebuild build-image --image-variant google-compute-config --flake .#my-host` --- nixos/modules/virtualisation/google-compute-config.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/google-compute-config.nix b/nixos/modules/virtualisation/google-compute-config.nix index 8f9e2b4f4075..c112d4132920 100644 --- a/nixos/modules/virtualisation/google-compute-config.nix +++ b/nixos/modules/virtualisation/google-compute-config.nix @@ -21,7 +21,7 @@ in ../profiles/qemu-guest.nix ]; - fileSystems."/" = { + fileSystems."/" = lib.mkImageMediaOverride { fsType = "ext4"; device = "/dev/disk/by-label/nixos"; autoResize = true; From 887f7d33e04bc999838d9dcd87113d84dd0a48c2 Mon Sep 17 00:00:00 2001 From: phaer Date: Fri, 11 Apr 2025 11:54:19 +0200 Subject: [PATCH 14/15] virtualisation/openstack: use mkImageMediaOverride... ...for filesystem options. Before this change, users would typically encounter conflicting option definitions when trying to build an image for a generic nixos closure, i.e. `nixos-rebuild build-image --image-variant openstack-zfs --flake .#my-host` --- .../virtualisation/openstack-config.nix | 26 +++++++++++-------- .../virtualisation/openstack-options.nix | 16 +++++++----- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/nixos/modules/virtualisation/openstack-config.nix b/nixos/modules/virtualisation/openstack-config.nix index caa3cbba6a6b..34031c303039 100644 --- a/nixos/modules/virtualisation/openstack-config.nix +++ b/nixos/modules/virtualisation/openstack-config.nix @@ -33,18 +33,22 @@ in ]; config = { - fileSystems."/" = mkIf (!cfg.zfs.enable) { - device = "/dev/disk/by-label/nixos"; - fsType = "ext4"; - autoResize = true; - }; + fileSystems."/" = mkIf (!cfg.zfs.enable) ( + lib.mkImageMediaOverride { + device = "/dev/disk/by-label/nixos"; + fsType = "ext4"; + autoResize = true; + } + ); - fileSystems."/boot" = mkIf (cfg.efi || cfg.zfs.enable) { - # The ZFS image uses a partition labeled ESP whether or not we're - # booting with EFI. - device = "/dev/disk/by-label/ESP"; - fsType = "vfat"; - }; + fileSystems."/boot" = mkIf (cfg.efi || cfg.zfs.enable) ( + lib.mkImageMediaOverride { + # The ZFS image uses a partition labeled ESP whether or not we're + # booting with EFI. + device = "/dev/disk/by-label/ESP"; + fsType = "vfat"; + } + ); boot.growPartition = true; boot.kernelParams = [ "console=tty1" ]; diff --git a/nixos/modules/virtualisation/openstack-options.nix b/nixos/modules/virtualisation/openstack-options.nix index 9d1b1efd676d..751e1612e833 100644 --- a/nixos/modules/virtualisation/openstack-options.nix +++ b/nixos/modules/virtualisation/openstack-options.nix @@ -70,12 +70,14 @@ in _: value: ((value.mount or null) != null) ) config.openstack.zfs.datasets; in - lib.mapAttrs' ( - dataset: opts: - lib.nameValuePair opts.mount { - device = dataset; - fsType = "zfs"; - } - ) mountable; + lib.mkImageMediaOverride ( + lib.mapAttrs' ( + dataset: opts: + lib.nameValuePair opts.mount { + device = dataset; + fsType = "zfs"; + } + ) mountable + ); }; } From 5bd99195fab011e2b04c2ff7eed9ef5d44b2fe86 Mon Sep 17 00:00:00 2001 From: phaer Date: Fri, 11 Apr 2025 12:22:51 +0200 Subject: [PATCH 15/15] installer/sd-card: use mkImageMediaOverride... ...for filesystem options. Before this change, users would typically encounter conflicting option definitions when trying to build an image for a generic nixos closure, i.e. `nixos-rebuild build-image --image-variant sd-card --flake .#my-host` --- nixos/modules/installer/sd-card/sd-image.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/installer/sd-card/sd-image.nix b/nixos/modules/installer/sd-card/sd-image.nix index d96216c4ae17..0fb725a035e3 100644 --- a/nixos/modules/installer/sd-card/sd-image.nix +++ b/nixos/modules/installer/sd-card/sd-image.nix @@ -185,7 +185,7 @@ in config = { hardware.enableAllHardware = true; - fileSystems = { + fileSystems = lib.mkImageMediaOverride { "/boot/firmware" = { device = "/dev/disk/by-label/${config.sdImage.firmwarePartitionName}"; fsType = "vfat";