Stuck in Grub Cli

How I fixed this

  1. Booted into the live environment from a USB stick (e.g., installer ISO).
  2. Closed the installer and connected to the internet.
  3. Opened the terminal.
  4. Mounted the file system (use lsblk if you’re unsure which device to mount):
  • sudo mount /dev/nvme0n1p2 /mnt
  • sudo mount /dev/nvme0n1p1 /mnt/boot
  • sudo nixos-enter
  1. Used an existing configuration. For example, my original config is still located at /etc/nixos/configuration.nix.
  2. Ran the following commands to reinstall the bootloader:
  • unset SUDO_USER (needed to bypass PAM)
  • nixos-rebuild boot --install-bootloader
  1. You may also need to specify the configuration file with -I nixos-config=/etc/nixos/configuration.nix.

Additionally, I encountered a build failure with the following service, so I temporarily disabled it:

  • services.logrotate.enable = false

Once the build is complete, you may see the following messages:

  • System has not been booted with systemd as init system (PID 1). Can’t operate.
  • Failed to connect to system scope bus via local transport: host is down.

This is normal. By the end, it should confirm that a new boot entry has been created. Reboot your system and, at the GRUB CLI, type exit to reach the bootloader selection screen. From there, select the newly created entry, and your system should boot correctly.