OSProber not working right

I switched to grub bootloader, since I read that it is the best way to dual boot with Windows. Correct me if I am wrong.
I now have in my config

# Bootloader.
  boot.loader = {
    grub = {
      enable = true;
      device = "nodev";
      efiSupport = true;
      useOSProber = true;
    };
    efi = {
      efiSysMountPoint = "/efi";
      canTouchEfiVariables = true;
    };
  };

But when I rebuild, I get

building Nix...
building the system configuration...
updating GRUB 2 menu...
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
lsblk: /dev/mapper/no*[0-9]: not a block device
lsblk: /dev/mapper/raid*[0-9]: not a block device
lsblk: /dev/mapper/disks*[0-9]: not a block device
Found Windows Boot Manager on /dev/sdb1@/efi/Microsoft/Boot/bootmgfw.efi
installing the GRUB 2 boot loader into /efi...
Installing for x86_64-efi platform.
/nix/store/d77m5axznh2h3a2chqad16d44qkdxkyh-grub-2.12-rc1/sbin/grub-install: error: failed to get canonical path of `/efi'.
/nix/store/qi2l9ddd6j5dqbglz6vgzxxqqdkgd06m-install-grub.pl: installation of GRUB EFI into /efi failed: No such file or directory
warning: error(s) occurred while switching to the new configuration

The relavent error messages imply that there is no filesystem mounted at /efi, have you mounted the EFI partition there? On a default install the EFI partition is mounted at /boot so you may not want the line efiSysMountPoint = "/efi"; in your config. If you provided your hardware-configuration.nix or wherever you have your filesystems defined in your configuration it would help.

# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:

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

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

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/1277b120-6355-4032-9efd-bf0a3e4ddad3";
      fsType = "ext4";
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/1913-EECC";
      fsType = "vfat";
    };

  swapDevices = [ ];

  # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
  # (the default) this is the recommended approach. When using systemd-networkd it's
  # still possible to use this option, but it's recommended to use it in conjunction
  # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
  networking.useDHCP = lib.mkDefault true;
  # networking.interfaces.enp0s20f0u3u1.useDHCP = lib.mkDefault true;
  # networking.interfaces.enp3s0.useDHCP = lib.mkDefault true;

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

Remove the line efiSysMountPoint = "/efi"; from your config and you should be good. You have your EFI partition mounted at /boot so having that line in your config tells grub to look for the EFI partition at /efi which won’t work.

I had to get rid of this line, too, because Nix complained that it didn’t exist.

But the funny thing is, I don’t get any error when rebuilding, but when I booted, there was still no option for Windows. :thinking:

Well, canTouchEfiVariables has existed for a very long time, so that’s pretty weird.

The windows drive needs to be mounted while the OSProber command is run, AFAIK. Temporarily mount it (Ex: sudo mount /dev/sdb3 /mnt) and then rebuild the system.