NixOS freezes when plugging in external SSD

My system freezes whenever I plug in my 2TB Seagate external SSD, and I’m not really sure what’s causing it. I’m able to load it when live booting using a different OS so it’s likely a software issue. The SSD is in exfat format, I’m not sure if that’s the cause? I tried adding the line below from the QNA

boot.extraModulePackages = [ config.boot.kernelPackages.exfat-nofuse ];

and got the error

error: A definition for option `boot.extraModulePackages."[definition 3-entry 1]"' is not of type `package'. Definition values:
       - In `/nix/store/x6glzrs23l39664458ygb8x3f5p2b74r-source/hosts/rotom/configuration.nix': null

Here’s the (hopefully) relevant parts in my configuration.nix

{
  config,
  pkgs,
  lib,
  inputs,
  ...
}: {
  imports = [
    ./hardware-configuration.nix
    inputs.hardware.nixosModules.framework-16-7040-amd
    inputs.home-manager.nixosModules.default
  ];

  system.stateVersion = "24.05"; # Did you read the comment?

  ...
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.supportedFilesystems = [
    "btrfs"
    "reiserfs"
    "vfat"
    "f2fs"
    "xfs"
    "ntfs"
    "cifs"
    "exfat"
  ];

  ...

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

  hardware.bluetooth.enable = true;
  services.udisks2.enable = true; # For USB support
  services.gvfs.enable = true; # USB
  services.fwupd.enable = true;

  environment.systemPackages = with pkgs; [
    wget
    alejandra
    blender
    obsidian
    (pkgs.discord.override {
      withOpenASAR = true;
      withVencord = true;
    })
    zotero
    flameshot
    kitty
    okular
    vlc
    ntfs3g # For mounting USB drives
    usbutils
    exfat
    neofetch
    networkmanagerapplet
    brightnessctl
    ...
  ];

...

Booting my PC with the SSD connected causes the OS to stop loading (though the message is different now than what I was getting before).

Any help is appreciated, thanks!

That option was only available for kernel 4.19 and 5.4. Since 5.7, it is built-in in the kernel, no need for that option any more.
As for booting with SSD, maybe you can boot with it, then without it, and check journactl -l -b -1 to see previous boot logs.

Ah I couldn’t find any information on it apart from the wiki, thanks for the info!

I nuked my whole PC and tried adding everything back in one by one to see which line was causing the issue. I couldn’t reproduce it in the end, the only difference between my old config files and the current one is the flake lock file, removing the boot.supportedFilesystem line (didn’t change anything by adding that back) and removing usbutils.

The newly generated hardware-configuration.nix had additionally "usb_storage" "sd_mod" in availableKernelModules which is probably the cause? I’ve not looked into that file so I’m not sure why the two files are different though.