lol

Use mkImageMediaOverride for filesystem attributes of various images (#397330)

authored by

jopejoe1 and committed by
GitHub
326702f8 ab829c99

+81 -63
+1 -1
nixos/modules/installer/sd-card/sd-image.nix
··· 185 config = { 186 hardware.enableAllHardware = true; 187 188 - fileSystems = { 189 "/boot/firmware" = { 190 device = "/dev/disk/by-label/${config.sdImage.firmwarePartitionName}"; 191 fsType = "vfat";
··· 185 config = { 186 hardware.enableAllHardware = true; 187 188 + fileSystems = lib.mkImageMediaOverride { 189 "/boot/firmware" = { 190 device = "/dev/disk/by-label/${config.sdImage.firmwarePartitionName}"; 191 fsType = "vfat";
+1 -1
nixos/modules/virtualisation/azure-image.nix
··· 113 ''; 114 }; 115 116 - fileSystems = { 117 "/" = { 118 device = "/dev/disk/by-label/${cfg.label}"; 119 inherit (cfg) label;
··· 113 ''; 114 }; 115 116 + fileSystems = lib.mkImageMediaOverride { 117 "/" = { 118 device = "/dev/disk/by-label/${cfg.label}"; 119 inherit (cfg) label;
+1 -1
nixos/modules/virtualisation/digital-ocean-config.nix
··· 39 in 40 mkMerge [ 41 { 42 - fileSystems."/" = lib.mkDefault { 43 device = "/dev/disk/by-label/nixos"; 44 autoResize = true; 45 fsType = "ext4";
··· 39 in 40 mkMerge [ 41 { 42 + fileSystems."/" = lib.mkImageMediaOverride { 43 device = "/dev/disk/by-label/nixos"; 44 autoResize = true; 45 fsType = "ext4";
+1 -1
nixos/modules/virtualisation/disk-image.nix
··· 37 boot.loader.systemd-boot.enable = lib.mkDefault cfg.efiSupport; 38 boot.growPartition = lib.mkDefault true; 39 40 - fileSystems = { 41 "/" = { 42 device = "/dev/disk/by-label/nixos"; 43 autoResize = true;
··· 37 boot.loader.systemd-boot.enable = lib.mkDefault cfg.efiSupport; 38 boot.growPartition = lib.mkDefault true; 39 40 + fileSystems = lib.mkImageMediaOverride { 41 "/" = { 42 device = "/dev/disk/by-label/nixos"; 43 autoResize = true;
+1 -1
nixos/modules/virtualisation/google-compute-config.nix
··· 21 ../profiles/qemu-guest.nix 22 ]; 23 24 - fileSystems."/" = { 25 fsType = "ext4"; 26 device = "/dev/disk/by-label/nixos"; 27 autoResize = true;
··· 21 ../profiles/qemu-guest.nix 22 ]; 23 24 + fileSystems."/" = lib.mkImageMediaOverride { 25 fsType = "ext4"; 26 device = "/dev/disk/by-label/nixos"; 27 autoResize = true;
+10 -8
nixos/modules/virtualisation/hyperv-image.nix
··· 73 inherit config lib pkgs; 74 }; 75 76 - fileSystems."/" = { 77 - device = "/dev/disk/by-label/nixos"; 78 - autoResize = true; 79 - fsType = "ext4"; 80 - }; 81 82 - fileSystems."/boot" = { 83 - device = "/dev/disk/by-label/ESP"; 84 - fsType = "vfat"; 85 }; 86 87 boot.growPartition = true;
··· 73 inherit config lib pkgs; 74 }; 75 76 + fileSystems = lib.mkImageMediaOverride { 77 + "/" = { 78 + device = "/dev/disk/by-label/nixos"; 79 + autoResize = true; 80 + fsType = "ext4"; 81 + }; 82 83 + "/boot" = { 84 + device = "/dev/disk/by-label/ESP"; 85 + fsType = "vfat"; 86 + }; 87 }; 88 89 boot.growPartition = true;
+1 -1
nixos/modules/virtualisation/kubevirt.nix
··· 12 ]; 13 14 config = { 15 - fileSystems."/" = { 16 device = "/dev/disk/by-label/nixos"; 17 fsType = "ext4"; 18 autoResize = true;
··· 12 ]; 13 14 config = { 15 + fileSystems."/" = lib.mkImageMediaOverride { 16 device = "/dev/disk/by-label/nixos"; 17 fsType = "ext4"; 18 autoResize = true;
+3 -5
nixos/modules/virtualisation/linode-config.nix
··· 1 { 2 - config, 3 lib, 4 pkgs, 5 ... 6 }: 7 - with lib; 8 { 9 imports = [ ../profiles/qemu-guest.nix ]; 10 ··· 12 enable = true; 13 14 settings.PermitRootLogin = "prohibit-password"; 15 - settings.PasswordAuthentication = mkDefault false; 16 }; 17 18 networking = { ··· 34 sysstat 35 ]; 36 37 - fileSystems."/" = { 38 fsType = "ext4"; 39 device = "/dev/sda"; 40 autoResize = true; 41 }; 42 43 - swapDevices = mkDefault [ { device = "/dev/sdb"; } ]; 44 45 # Enable LISH and Linode Booting w/ GRUB 46 boot = {
··· 1 { 2 lib, 3 pkgs, 4 ... 5 }: 6 { 7 imports = [ ../profiles/qemu-guest.nix ]; 8 ··· 10 enable = true; 11 12 settings.PermitRootLogin = "prohibit-password"; 13 + settings.PasswordAuthentication = lib.mkDefault false; 14 }; 15 16 networking = { ··· 32 sysstat 33 ]; 34 35 + fileSystems."/" = lib.mkImageMediaOverride { 36 fsType = "ext4"; 37 device = "/dev/sda"; 38 autoResize = true; 39 }; 40 41 + swapDevices = lib.mkDefault [ { device = "/dev/sdb"; } ]; 42 43 # Enable LISH and Linode Booting w/ GRUB 44 boot = {
+10 -8
nixos/modules/virtualisation/oci-common.nix
··· 30 31 boot.growPartition = true; 32 33 - fileSystems."/" = { 34 - device = "/dev/disk/by-label/nixos"; 35 - fsType = "ext4"; 36 - autoResize = true; 37 - }; 38 39 - fileSystems."/boot" = lib.mkIf cfg.efi { 40 - device = "/dev/disk/by-label/ESP"; 41 - fsType = "vfat"; 42 }; 43 44 boot.loader.efi.canTouchEfiVariables = false;
··· 30 31 boot.growPartition = true; 32 33 + fileSystems = lib.mkImageMediaOverride { 34 + "/" = { 35 + device = "/dev/disk/by-label/nixos"; 36 + fsType = "ext4"; 37 + autoResize = true; 38 + }; 39 40 + "/boot" = lib.mkIf cfg.efi { 41 + device = "/dev/disk/by-label/ESP"; 42 + fsType = "vfat"; 43 + }; 44 }; 45 46 boot.loader.efi.canTouchEfiVariables = false;
+15 -11
nixos/modules/virtualisation/openstack-config.nix
··· 33 ]; 34 35 config = { 36 - fileSystems."/" = mkIf (!cfg.zfs.enable) { 37 - device = "/dev/disk/by-label/nixos"; 38 - fsType = "ext4"; 39 - autoResize = true; 40 - }; 41 42 - fileSystems."/boot" = mkIf (cfg.efi || cfg.zfs.enable) { 43 - # The ZFS image uses a partition labeled ESP whether or not we're 44 - # booting with EFI. 45 - device = "/dev/disk/by-label/ESP"; 46 - fsType = "vfat"; 47 - }; 48 49 boot.growPartition = true; 50 boot.kernelParams = [ "console=tty1" ];
··· 33 ]; 34 35 config = { 36 + fileSystems."/" = mkIf (!cfg.zfs.enable) ( 37 + lib.mkImageMediaOverride { 38 + device = "/dev/disk/by-label/nixos"; 39 + fsType = "ext4"; 40 + autoResize = true; 41 + } 42 + ); 43 44 + fileSystems."/boot" = mkIf (cfg.efi || cfg.zfs.enable) ( 45 + lib.mkImageMediaOverride { 46 + # The ZFS image uses a partition labeled ESP whether or not we're 47 + # booting with EFI. 48 + device = "/dev/disk/by-label/ESP"; 49 + fsType = "vfat"; 50 + } 51 + ); 52 53 boot.growPartition = true; 54 boot.kernelParams = [ "console=tty1" ];
+9 -7
nixos/modules/virtualisation/openstack-options.nix
··· 70 _: value: ((value.mount or null) != null) 71 ) config.openstack.zfs.datasets; 72 in 73 - lib.mapAttrs' ( 74 - dataset: opts: 75 - lib.nameValuePair opts.mount { 76 - device = dataset; 77 - fsType = "zfs"; 78 - } 79 - ) mountable; 80 }; 81 }
··· 70 _: value: ((value.mount or null) != null) 71 ) config.openstack.zfs.datasets; 72 in 73 + lib.mkImageMediaOverride ( 74 + lib.mapAttrs' ( 75 + dataset: opts: 76 + lib.nameValuePair opts.mount { 77 + device = dataset; 78 + fsType = "zfs"; 79 + } 80 + ) mountable 81 + ); 82 }; 83 }
+17 -9
nixos/modules/virtualisation/proxmox-image.nix
··· 306 '' 307 ${vma}/bin/vma create "${config.image.baseName}.vma" \ 308 -c ${ 309 - cfgFile "qemu-server.conf" (cfg.qemuConf // cfg.qemuExtraConf) 310 }/qemu-server.conf drive-virtio0=$diskImage 311 rm $diskImage 312 ${pkgs.zstd}/bin/zstd "${config.image.baseName}.vma" ··· 346 ]; 347 }; 348 349 - fileSystems."/" = { 350 - device = "/dev/disk/by-label/nixos"; 351 - autoResize = true; 352 - fsType = "ext4"; 353 - }; 354 - fileSystems."/boot" = lib.mkIf hasBootPartition { 355 - device = "/dev/disk/by-label/ESP"; 356 - fsType = "vfat"; 357 }; 358 359 networking = mkIf cfg.cloudInit.enable {
··· 306 '' 307 ${vma}/bin/vma create "${config.image.baseName}.vma" \ 308 -c ${ 309 + cfgFile "qemu-server.conf" ( 310 + (builtins.removeAttrs cfg.qemuConf [ "diskSize" ]) 311 + // { 312 + inherit (config.virtualisation) diskSize; 313 + } 314 + // cfg.qemuExtraConf 315 + ) 316 }/qemu-server.conf drive-virtio0=$diskImage 317 rm $diskImage 318 ${pkgs.zstd}/bin/zstd "${config.image.baseName}.vma" ··· 352 ]; 353 }; 354 355 + fileSystems = lib.mkImageMediaOverride { 356 + "/" = { 357 + device = "/dev/disk/by-label/nixos"; 358 + autoResize = true; 359 + fsType = "ext4"; 360 + }; 361 + "/boot" = lib.mkIf hasBootPartition { 362 + device = "/dev/disk/by-label/ESP"; 363 + fsType = "vfat"; 364 + }; 365 }; 366 367 networking = mkIf cfg.cloudInit.enable {
+1 -1
nixos/modules/virtualisation/virtualbox-image.nix
··· 275 }; 276 277 fileSystems = 278 - { 279 "/" = { 280 device = "/dev/disk/by-label/nixos"; 281 autoResize = true;
··· 275 }; 276 277 fileSystems = 278 + lib.mkImageMediaOverride { 279 "/" = { 280 device = "/dev/disk/by-label/nixos"; 281 autoResize = true;
+10 -8
nixos/modules/virtualisation/vmware-image.nix
··· 83 inherit config lib pkgs; 84 }; 85 86 - fileSystems."/" = { 87 - device = "/dev/disk/by-label/nixos"; 88 - autoResize = true; 89 - fsType = "ext4"; 90 - }; 91 92 - fileSystems."/boot" = { 93 - device = "/dev/disk/by-label/ESP"; 94 - fsType = "vfat"; 95 }; 96 97 boot.growPartition = true;
··· 83 inherit config lib pkgs; 84 }; 85 86 + fileSystems = lib.mkImageMediaOverride { 87 + "/" = { 88 + device = "/dev/disk/by-label/nixos"; 89 + autoResize = true; 90 + fsType = "ext4"; 91 + }; 92 93 + "/boot" = { 94 + device = "/dev/disk/by-label/ESP"; 95 + fsType = "vfat"; 96 + }; 97 }; 98 99 boot.growPartition = true;