Dual-booting windows and nixos problems

I am trying to dual boot Windows 10 and NixOS,
managed to install both systems on different partitions of the same drive, (NixOS graphical install)

i have a configuration from my older NixOS system + Flake, which i changed to use the GRUB bootloader (i will mention that this is my first time setting it up).

at first both systems worked fine, but now, issuing sudo nixos-rebuild switch --flake /etc/nixos/#myNixos (my flake) gives me the (shortened) error:

updating GRUB 2 menu...
installing the GRUB 2 boot loader into /boot...
Installing for x86_64-efi platform.
/nix/store/qlh04m1a1i5ix9v98nqfqmvgrwvj6y40-grub-2.12/sbin/grub-install: error: /boot doesn't look like an EFI partition.
/nix/store/pa2pnwnzkz4figsji4wnmgad9m7fa0r6-install-grub.pl: installation of GRUB EFI into /boot failed: Inappropriate ioctl for device
Failed to install bootloader
warning: error(s) occurred while switching to the new configuration
**some context of my system:**
>> lsblk --fs
NAME        FSTYPE FSVER LABEL       UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                                      
└─sda1      ext4   1.0               05c4c68c-77c8-4591-828d-ec9199bee8f5    1,7T     2% /media/HDD
sdb                                                                                      
sdc                                                                                      
└─sdc1      vfat   FAT32 NIXOS-PLASM 1A17-076C                                           
sdd                                                                                      
nvme0n1                                                                                  
├─nvme0n1p1 ntfs                     E23EC7703EC73C73                                    
├─nvme0n1p2 ntfs                     94943A7D943A6242                                    
└─nvme0n1p3 ext4   1.0   NIXOS       691df4d9-d26c-433c-a597-aded6b1e12e8  353,2G    15% /nix/store
                                                                                         /
nvme1n1                                                                                  
└─nvme1n1p1 ext4   1.0   FREESSD     81163b6b-1264-4744-8539-221fb6f62f15  692,8G    21% /media/SSD0

grub config in configuration.nix:

  boot.loader = {
    grub = {
      enable                = true;
      fsIdentifier          = "label";
      efiSupport            = true;
      efiInstallAsRemovable = true;
      devices               = [ "nodev" ];
    };
  };

hardware-configuration.nix:

{ config, lib, pkgs, modulesPath, ... }:

{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
    ];

  boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-amd" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/691df4d9-d26c-433c-a597-aded6b1e12e8";
      fsType = "ext4";
    };

  fileSystems."/media/HDD" =
    { device = "/dev/disk/by-uuid/05c4c68c-77c8-4591-828d-ec9199bee8f5";
      fsType = "ext4";
    };

  fileSystems."/media/SSD0" =
    { device = "/dev/disk/by-uuid/81163b6b-1264-4744-8539-221fb6f62f15";
      fsType = "ext4";
    };

  swapDevices = [ ];

  networking.useDHCP = lib.mkDefault true;


  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;

view from gparted of the drive with both windows and nixos

its because the efi parition is ntfs, while linux expects a efi paritition to be fat32, wierd that windows is using ntfs for efi

I don’t see any efi partition, unless I’m missing something? I only see the ext4 partition marked bootable, implying MBR or that it’s an ESP iirc, and EFI-MBR is sometimes possible but a relatively niche setup IMO.

@S3NP41-v Did you check if you’re using EFI or not? The error you’re getting seems to imply… not.

i checked my BIOS, and indeed you are right, i had all set to legacy for whatever reason…

i take it that i will have to reinstall both of the systems to get it to work properly now?
Thank you for your help.

No, just change your grub configuration to disable EFI settings and point at the correct device (use by-uuid or by-label, not /dev/sda1-type identifiers!)

EDIT: I meant by-id, disks don’t have UUIDs.

Though, I generally recommend EFI rather than legacy BIOS, and switching at this point would uh… certainly be a little involved. But Windows has a bad habit of messing with the boot loader when you don’t use EFI.

1 Like

this is a fresh install of both systems, i don’t mind at all reinstalling them both to have a cleaner overall configuration

Yea, that seems like a good idea then. Enable EFI, and install NixOS before Windows, not the other way around, so they share the ESP and systemd-boot can automatically find Windows.

1 Like

If you do that wont windows make its own esp

No, Windows tries to reuse an existing ESP if one exists. Like, on my system, I installed Windows to a different drive entirely, and it still installed its boot loader on the ESP of my NixOS drive.

this was the solution,
Thank you to everyone who replied,
i didnt expect i had it all in legacy mode

also to add for someone coming after me; nixos-install adds/fixes the linux EFI entry, might help booting into the installer