1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-23 01:41:05 +03:00

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

This commit is contained in:
jopejoe1 2025-04-24 18:54:06 +02:00 committed by GitHub
commit 326702f8bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 81 additions and 63 deletions

View file

@ -185,7 +185,7 @@ in
config = { config = {
hardware.enableAllHardware = true; hardware.enableAllHardware = true;
fileSystems = { fileSystems = lib.mkImageMediaOverride {
"/boot/firmware" = { "/boot/firmware" = {
device = "/dev/disk/by-label/${config.sdImage.firmwarePartitionName}"; device = "/dev/disk/by-label/${config.sdImage.firmwarePartitionName}";
fsType = "vfat"; fsType = "vfat";

View file

@ -113,7 +113,7 @@ in
''; '';
}; };
fileSystems = { fileSystems = lib.mkImageMediaOverride {
"/" = { "/" = {
device = "/dev/disk/by-label/${cfg.label}"; device = "/dev/disk/by-label/${cfg.label}";
inherit (cfg) label; inherit (cfg) label;

View file

@ -39,7 +39,7 @@ with lib;
in in
mkMerge [ mkMerge [
{ {
fileSystems."/" = lib.mkDefault { fileSystems."/" = lib.mkImageMediaOverride {
device = "/dev/disk/by-label/nixos"; device = "/dev/disk/by-label/nixos";
autoResize = true; autoResize = true;
fsType = "ext4"; fsType = "ext4";

View file

@ -37,7 +37,7 @@ in
boot.loader.systemd-boot.enable = lib.mkDefault cfg.efiSupport; boot.loader.systemd-boot.enable = lib.mkDefault cfg.efiSupport;
boot.growPartition = lib.mkDefault true; boot.growPartition = lib.mkDefault true;
fileSystems = { fileSystems = lib.mkImageMediaOverride {
"/" = { "/" = {
device = "/dev/disk/by-label/nixos"; device = "/dev/disk/by-label/nixos";
autoResize = true; autoResize = true;

View file

@ -21,7 +21,7 @@ in
../profiles/qemu-guest.nix ../profiles/qemu-guest.nix
]; ];
fileSystems."/" = { fileSystems."/" = lib.mkImageMediaOverride {
fsType = "ext4"; fsType = "ext4";
device = "/dev/disk/by-label/nixos"; device = "/dev/disk/by-label/nixos";
autoResize = true; autoResize = true;

View file

@ -73,15 +73,17 @@ in
inherit config lib pkgs; inherit config lib pkgs;
}; };
fileSystems."/" = { fileSystems = lib.mkImageMediaOverride {
device = "/dev/disk/by-label/nixos"; "/" = {
autoResize = true; device = "/dev/disk/by-label/nixos";
fsType = "ext4"; autoResize = true;
}; fsType = "ext4";
};
fileSystems."/boot" = { "/boot" = {
device = "/dev/disk/by-label/ESP"; device = "/dev/disk/by-label/ESP";
fsType = "vfat"; fsType = "vfat";
};
}; };
boot.growPartition = true; boot.growPartition = true;

View file

@ -12,7 +12,7 @@
]; ];
config = { config = {
fileSystems."/" = { fileSystems."/" = lib.mkImageMediaOverride {
device = "/dev/disk/by-label/nixos"; device = "/dev/disk/by-label/nixos";
fsType = "ext4"; fsType = "ext4";
autoResize = true; autoResize = true;

View file

@ -1,10 +1,8 @@
{ {
config,
lib, lib,
pkgs, pkgs,
... ...
}: }:
with lib;
{ {
imports = [ ../profiles/qemu-guest.nix ]; imports = [ ../profiles/qemu-guest.nix ];
@ -12,7 +10,7 @@ with lib;
enable = true; enable = true;
settings.PermitRootLogin = "prohibit-password"; settings.PermitRootLogin = "prohibit-password";
settings.PasswordAuthentication = mkDefault false; settings.PasswordAuthentication = lib.mkDefault false;
}; };
networking = { networking = {
@ -34,13 +32,13 @@ with lib;
sysstat sysstat
]; ];
fileSystems."/" = { fileSystems."/" = lib.mkImageMediaOverride {
fsType = "ext4"; fsType = "ext4";
device = "/dev/sda"; device = "/dev/sda";
autoResize = true; autoResize = true;
}; };
swapDevices = mkDefault [ { device = "/dev/sdb"; } ]; swapDevices = lib.mkDefault [ { device = "/dev/sdb"; } ];
# Enable LISH and Linode Booting w/ GRUB # Enable LISH and Linode Booting w/ GRUB
boot = { boot = {

View file

@ -30,15 +30,17 @@ in
boot.growPartition = true; boot.growPartition = true;
fileSystems."/" = { fileSystems = lib.mkImageMediaOverride {
device = "/dev/disk/by-label/nixos"; "/" = {
fsType = "ext4"; device = "/dev/disk/by-label/nixos";
autoResize = true; fsType = "ext4";
}; autoResize = true;
};
fileSystems."/boot" = lib.mkIf cfg.efi { "/boot" = lib.mkIf cfg.efi {
device = "/dev/disk/by-label/ESP"; device = "/dev/disk/by-label/ESP";
fsType = "vfat"; fsType = "vfat";
};
}; };
boot.loader.efi.canTouchEfiVariables = false; boot.loader.efi.canTouchEfiVariables = false;

View file

@ -33,18 +33,22 @@ in
]; ];
config = { config = {
fileSystems."/" = mkIf (!cfg.zfs.enable) { fileSystems."/" = mkIf (!cfg.zfs.enable) (
device = "/dev/disk/by-label/nixos"; lib.mkImageMediaOverride {
fsType = "ext4"; device = "/dev/disk/by-label/nixos";
autoResize = true; fsType = "ext4";
}; autoResize = true;
}
);
fileSystems."/boot" = mkIf (cfg.efi || cfg.zfs.enable) { fileSystems."/boot" = mkIf (cfg.efi || cfg.zfs.enable) (
# The ZFS image uses a partition labeled ESP whether or not we're lib.mkImageMediaOverride {
# booting with EFI. # The ZFS image uses a partition labeled ESP whether or not we're
device = "/dev/disk/by-label/ESP"; # booting with EFI.
fsType = "vfat"; device = "/dev/disk/by-label/ESP";
}; fsType = "vfat";
}
);
boot.growPartition = true; boot.growPartition = true;
boot.kernelParams = [ "console=tty1" ]; boot.kernelParams = [ "console=tty1" ];

View file

@ -70,12 +70,14 @@ in
_: value: ((value.mount or null) != null) _: value: ((value.mount or null) != null)
) config.openstack.zfs.datasets; ) config.openstack.zfs.datasets;
in in
lib.mapAttrs' ( lib.mkImageMediaOverride (
dataset: opts: lib.mapAttrs' (
lib.nameValuePair opts.mount { dataset: opts:
device = dataset; lib.nameValuePair opts.mount {
fsType = "zfs"; device = dataset;
} fsType = "zfs";
) mountable; }
) mountable
);
}; };
} }

View file

@ -306,7 +306,13 @@ with lib;
'' ''
${vma}/bin/vma create "${config.image.baseName}.vma" \ ${vma}/bin/vma create "${config.image.baseName}.vma" \
-c ${ -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 }/qemu-server.conf drive-virtio0=$diskImage
rm $diskImage rm $diskImage
${pkgs.zstd}/bin/zstd "${config.image.baseName}.vma" ${pkgs.zstd}/bin/zstd "${config.image.baseName}.vma"
@ -346,14 +352,16 @@ with lib;
]; ];
}; };
fileSystems."/" = { fileSystems = lib.mkImageMediaOverride {
device = "/dev/disk/by-label/nixos"; "/" = {
autoResize = true; device = "/dev/disk/by-label/nixos";
fsType = "ext4"; autoResize = true;
}; fsType = "ext4";
fileSystems."/boot" = lib.mkIf hasBootPartition { };
device = "/dev/disk/by-label/ESP"; "/boot" = lib.mkIf hasBootPartition {
fsType = "vfat"; device = "/dev/disk/by-label/ESP";
fsType = "vfat";
};
}; };
networking = mkIf cfg.cloudInit.enable { networking = mkIf cfg.cloudInit.enable {

View file

@ -275,7 +275,7 @@ in
}; };
fileSystems = fileSystems =
{ lib.mkImageMediaOverride {
"/" = { "/" = {
device = "/dev/disk/by-label/nixos"; device = "/dev/disk/by-label/nixos";
autoResize = true; autoResize = true;

View file

@ -83,15 +83,17 @@ in
inherit config lib pkgs; inherit config lib pkgs;
}; };
fileSystems."/" = { fileSystems = lib.mkImageMediaOverride {
device = "/dev/disk/by-label/nixos"; "/" = {
autoResize = true; device = "/dev/disk/by-label/nixos";
fsType = "ext4"; autoResize = true;
}; fsType = "ext4";
};
fileSystems."/boot" = { "/boot" = {
device = "/dev/disk/by-label/ESP"; device = "/dev/disk/by-label/ESP";
fsType = "vfat"; fsType = "vfat";
};
}; };
boot.growPartition = true; boot.growPartition = true;