summaryrefslogtreecommitdiff
path: root/sys/boot/efi.nix
blob: 35cf687ad7d4229aa413b8deab818c65a27a5823 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{ config, lib, ... }:
with lib; let
  cfg = config.local.boot.efi;
in
{
  options.local.boot.efi = {
    enable = mkEnableOption "EFI with FAT32 system partition";

    esp.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.canTouchEfiVariables = !cfg.removable;
        grub.efiInstallAsRemovable = cfg.removable;
      };
    };

    fileSystems."/boot" = {
      device = "/dev/disk/by-uuid/${cfg.esp.uuid}";
      fsType = "vfat";
      options = [ "noatime" "umask=027" "sync" ];
      neededForBoot = true;
    };
  };
}