{ config, lib, ... }: with lib; let cfg = config.local.boot.efi; in { options.local.boot.efi = { enable = mkEnableOption "EFI with FAT32 system partition"; esp = { mountpoint = mkOption { type = types.enum [ "/boot" "/boot/efi" ]; default = "/boot"; }; uuid = mkOption { type = types.strMatching "[0-9A-F]{4}-[0-9A-F]{4}"; }; }; removable = mkOption { type = types.bool; }; }; config = mkIf cfg.enable { boot = { initrd.supportedFilesystems = [ "vfat" ]; loader = { efi = { efiSysMountPoint = cfg.esp.mountpoint; canTouchEfiVariables = !cfg.removable; }; grub.efiInstallAsRemovable = cfg.removable; }; }; fileSystems.${cfg.esp.mountpoint} = { device = "/dev/disk/by-uuid/${cfg.esp.uuid}"; fsType = "vfat"; options = [ "noatime" "umask=027" "sync" ]; neededForBoot = true; }; }; }