NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.37k stars 13.6k forks source link

Contradictory Errors When Configuring Unusual Boot Setups #316285

Open useranon350 opened 3 months ago

useranon350 commented 3 months ago

Describe the bug

A clear and concise description of what the bug is. Configuring boot.loader.generationsDir.enable = true; and boot.loader.systemd-boot.enable = true; causes an error due to multiple bootloaders, but disabling the latter causes an error due to You must set the option ‘boot.loader.grub.devices’ or 'boot.loader.grub.mirroredBoots' to make the system bootable.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Add boot.loader.generationsDir.enable = true; and boot.loader.systemd-boot.enable = true; to configuration.
  2. Run nixos-rebuild boot
  3. Observe error
  4. Set boot.loader.systemd-boot.enable = false;
  5. Run nixos-rebuild boot
  6. Observe error

Expected behavior

I expect disabling systemd boot to allow me to use generationsDir boot.

Screenshots

Not screenshots, but the errors.

With both enabled:

building Nix...
building the system configuration...
trace: warning: The option `services.xserver.displayManager.defaultSession' defined in `/etc/nixos/configuration.nix' has been renamed to `services.displayManager.defaultSession'.
error:
       … while calling the 'head' builtin

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:1575:11:

         1574|         || pred here (elemAt values 1) (head values) then
         1575|           head values
             |           ^
         1576|         else

       … while evaluating the attribute 'value'

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:809:9:

          808|     in warnDeprecation opt //
          809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          810|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The option `system.build.installBootLoader' is defined multiple times while it's expected to be unique.
       Only one bootloader can be enabled at a time. This requirement has not
       been checked until NixOS 22.05. Earlier versions defaulted to the last
       definition. Change your configuration to enable only one bootloader.

       Definition values:
       - In `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/loader/generations-dir/generations-dir.nix': <derivation generations-dir-builder.sh>
       - In `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix': <derivation install-systemd-boot.sh>
       Use `lib.mkForce value` or `lib.mkDefault value` to change the priority on any of these definitions

with systemd-boot disabled:

building Nix...
building the system configuration...
error:
       … while calling the 'head' builtin

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:1575:11:

         1574|         || pred here (elemAt values 1) (head values) then
         1575|           head values
             |           ^
         1576|         else

       … while evaluating the attribute 'value'

         at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:809:9:

          808|     in warnDeprecation opt //
          809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          810|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error:
       Failed assertions:
       - You must set the option ‘boot.loader.grub.devices’ or 'boot.loader.grub.mirroredBoots' to make the system bootable.

Additional context

Add any other context about the problem here.

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.32-1-MANJARO, NixOS, 24.05 (Uakari), 24.05.675.805a384895c6`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Add a :+1: reaction to issues you find important.

useranon350 commented 3 months ago

I think I found the issue. GRUB is the default bootloader, but is automatically disabled if systemd boot is enabled. Other boot options do not appear to have the same effect.

Kamrat-Haggberg commented 1 month ago

did you manage to fix it?

useranon350 commented 4 weeks ago

Yes, I manually disabled GRUB using "boot.loader.grub.enable = false;"