1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 03:30:45 +00:00

nixos/qemu-vm: force enable switch-to-configuration when installing bootloader (#341288)

This commit is contained in:
K900 2024-09-12 19:10:53 +03:00 committed by GitHub
commit 9d3c35b682
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 11 deletions

View file

@ -23,10 +23,10 @@ in
};
}
({ config, ... }: {
# Don't pull in switch-to-configuration by default, except when specialisations are involved.
# Don't pull in switch-to-configuration by default, except when specialisations or early boot shenanigans are involved.
# This is mostly a Hydra optimization, so we don't rebuild all the tests every time switch-to-configuration-ng changes.
key = "no-switch-to-configuration";
system.switch.enable = mkDefault (config.isSpecialisation || config.specialisation != {});
system.switch.enable = mkDefault (config.isSpecialisation || config.specialisation != {} || config.virtualisation.installBootLoader);
})
];
}

View file

@ -276,15 +276,7 @@ let
onlyNixStore = false;
label = rootFilesystemLabel;
partitionTableType = selectPartitionTableLayout { inherit (cfg) useDefaultFilesystems useEFIBoot; };
# Bootloader should be installed on the system image only if we are booting through bootloaders.
# Though, if a user is not using our default filesystems, it is possible to not have any ESP
# or a strange partition table that's incompatible with GRUB configuration.
# As a consequence, this may lead to disk image creation failures.
# To avoid this, we prefer to let the user find out about how to install the bootloader on its ESP/disk.
# Usually, this can be through building your own disk image.
# TODO: If a user is interested into a more fine grained heuristic for `installBootLoader`
# by examining the actual contents of `cfg.fileSystems`, please send a PR.
installBootLoader = cfg.useBootLoader && cfg.useDefaultFilesystems;
installBootLoader = cfg.installBootLoader;
touchEFIVars = cfg.useEFIBoot;
diskSize = "auto";
additionalSpace = "0M";
@ -840,6 +832,19 @@ in
'';
};
virtualisation.installBootLoader =
mkOption {
type = types.bool;
default = cfg.useBootLoader && cfg.useDefaultFilesystems;
defaultText = "cfg.useBootLoader && cfg.useDefaultFilesystems";
description = ''
Install boot loader to target image.
This is best-effort and may break with unconventional partition setups.
Use `virtualisation.useDefaultFilesystems` for a known-working configuration.
'';
};
virtualisation.useEFIBoot =
mkOption {
type = types.bool;
@ -999,6 +1004,13 @@ in
If you have a more advanced usecase, please open an issue or a pull request.
'';
}
{
assertion = cfg.installBootLoader -> config.system.switch.enable;
message = ''
`system.switch.enable` must be enabled for `virtualisation.installBootLoader` to work.
Please enable it in your configuration.
'';
}
];
warnings =