mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +03:00
Use mkImageMediaOverride for filesystem attributes of various images (#397330)
This commit is contained in:
commit
326702f8bb
14 changed files with 81 additions and 63 deletions
|
@ -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";
|
||||
|
|
|
@ -113,7 +113,7 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
fileSystems = {
|
||||
fileSystems = lib.mkImageMediaOverride {
|
||||
"/" = {
|
||||
device = "/dev/disk/by-label/${cfg.label}";
|
||||
inherit (cfg) label;
|
||||
|
|
|
@ -39,7 +39,7 @@ with lib;
|
|||
in
|
||||
mkMerge [
|
||||
{
|
||||
fileSystems."/" = lib.mkDefault {
|
||||
fileSystems."/" = lib.mkImageMediaOverride {
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
autoResize = true;
|
||||
fsType = "ext4";
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -21,7 +21,7 @@ in
|
|||
../profiles/qemu-guest.nix
|
||||
];
|
||||
|
||||
fileSystems."/" = {
|
||||
fileSystems."/" = lib.mkImageMediaOverride {
|
||||
fsType = "ext4";
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
autoResize = true;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
];
|
||||
|
||||
config = {
|
||||
fileSystems."/" = {
|
||||
fileSystems."/" = lib.mkImageMediaOverride {
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
fsType = "ext4";
|
||||
autoResize = true;
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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" ];
|
||||
|
|
|
@ -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
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -275,7 +275,7 @@ in
|
|||
};
|
||||
|
||||
fileSystems =
|
||||
{
|
||||
lib.mkImageMediaOverride {
|
||||
"/" = {
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
autoResize = true;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue