NixOS grub doesn't see Windows

Hello. I’m kinda new to NixOS but I managed to get most stuff working. I’m kinda trying to wrap my head around trying to list Windows in the GRUB menu. I managed to get it to list Manjaro using OSProber. here’s my /etc/nixos/configuration.nix:

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Use the GRUB 2 boot loader.
  boot.loader.grub.enable = true;
  boot.loader.grub.version = 2;
  boot.loader.grub.efiSupport = true;
  boot.loader.grub.useOSProber = true;
  boot.loader.grub.efiInstallAsRemovable = true;
  boot.loader.efi.efiSysMountPoint = "/boot/efi";
  # Define on which hard drive you want to install Grub.
  boot.loader.grub.device = "/dev/sda"; # or "nodev" for efi only


  networking.hostName = "nixos"; # Define your hostname.
  #networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # The global useDHCP flag is deprecated, therefore explicitly set to false here.
  # Per-interface useDHCP will be mandatory in the future, so this generated config
  # replicates the default behaviour.
  networking.useDHCP = false;
  networking.interfaces.enp3s0.useDHCP = true;
  networking.interfaces.wlp2s0.useDHCP = true;

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Select internationalisation properties.
  i18n = {
    consoleFont = "Lat2-Terminus16";
    consoleKeyMap = "pl";
    defaultLocale = "pl_PL.UTF-8";
  };

  # Set your time zone.
  time.timeZone = "Europe/Warsaw";

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  # environment.systemPackages = with pkgs; [
  #   wget vim
  # ];

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  programs.mtr.enable = true;
  programs.gnupg.agent = { enable = true; enableSSHSupport = true; };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Enable sound.
  sound.enable = true;
  hardware.pulseaudio.enable = true;

  # Enable the X11 windowing system.
  services.xserver.enable = true;
  services.xserver.layout = "pl";
  services.xserver.xkbOptions = "eurosign:e";

  # Enable touchpad support.
  services.xserver.libinput.enable = true;

  # Enable the KDE Desktop Environment.
  services.xserver.displayManager.sddm.enable = true;
  services.xserver.desktopManager.plasma5.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.nix = {
    isNormalUser = true;
    extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
  };

  # This value determines the NixOS release with which your system is to be
  # compatible, in order to avoid breaking some software such as database
  # servers. You should change this only after NixOS release notes say you
  # should.
  system.stateVersion = "19.09"; # Did you read the comment?
  environment.systemPackages = [
  pkgs.firefox
  pkgs.xarchiver
  pkgs.xfce.mousepad
  pkgs.awesome
  pkgs.gcc
  pkgs.scrot
  pkgs.gimp
  pkgs.signal-desktop
  pkgs.filezilla
  pkgs.ntfs3g
  pkgs.mpv
  ];
}

and /etc/nixos/hardware-configuration.nix

# 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, ... }:

{
  imports =
    [ <nixpkgs/nixos/modules/installer/scan/not-detected.nix>
    ];

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

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/000...";
      fsType = "ext4";
    };

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

  swapDevices =
    [ { device = "/dev/disk/by-uuid/93f..."; }
    ];

  nix.maxJobs = lib.mkDefault 4;
  powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
}

additionally, [ -d /sys/firmware/efi/efivars ] && echo "UEFI" || echo "Legacy" outputs Legacy. and I’m not seeing generations in the GRUB menu, just the standard configuration. First time reporting a nix problem and I’m probably doing a lot of thing wrong, so just tell me the right way. Thanks :slight_smile:

Update: I do have rollback, maybe I pressed enter one time too many back then, hence i didn’t see the generations. :slight_smile:

It looks like you are booting in legacy mode but configure grub in efi mode…
If os-prober is not detecting windows, you can try mounting the windows partition and running nixos-rebuild switch while this partition is mounted. Also note that it seems that os-prober can only detect efi windows when booted in efi.

Alright. So seems like my issue was related to this: grub efi fails on latest nixos-unstable · Issue #61718 · NixOS/nixpkgs · GitHub (got error: symbol `grub_file_filters’ not found / Entering rescue mode when chainloading Windows manually) but it was so annoying I got mad and changed my partition scheme from mbr to gpt and reinstalling everything. Sorry I couldn’t provide more info for that Grub issue, but this was better than throwing my laptop out of the window in rage. I’m also now using systemd-boot on 20.03 and it detects windows with os-prober no problem.

Can be closed I guess?

1 Like