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"; 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; 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"; 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; 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; 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; 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; diff --git a/nixos/modules/virtualisation/linode-config.nix b/nixos/modules/virtualisation/linode-config.nix index a6dbe4cbb8f0..721a6f8bdc69 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 = { @@ -34,13 +32,13 @@ with lib; sysstat ]; - fileSystems."/" = { + fileSystems."/" = lib.mkImageMediaOverride { fsType = "ext4"; device = "/dev/sda"; autoResize = true; }; - swapDevices = mkDefault [ { device = "/dev/sdb"; } ]; + swapDevices = lib.mkDefault [ { device = "/dev/sdb"; } ]; # Enable LISH and Linode Booting w/ GRUB boot = { 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; 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 + ); }; } diff --git a/nixos/modules/virtualisation/proxmox-image.nix b/nixos/modules/virtualisation/proxmox-image.nix index cb83a9e5ef29..25aa3aee93c7 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" @@ -346,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 { 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; 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;