1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.boot.loader.systemd-boot;
7
8 efi = config.boot.loader.efi;
9
10 gummibootBuilder = pkgs.substituteAll {
11 src = ./systemd-boot-builder.py;
12
13 isExecutable = true;
14
15 inherit (pkgs) python;
16
17 systemd = config.systemd.package;
18
19 nix = config.nix.package.out;
20
21 timeout = if config.boot.loader.timeout != null then config.boot.loader.timeout else "";
22
23 inherit (efi) efiSysMountPoint canTouchEfiVariables;
24 };
25in {
26
27 imports =
28 [ (mkRenamedOptionModule [ "boot" "loader" "gummiboot" "enable" ] [ "boot" "loader" "systemd-boot" "enable" ])
29 ];
30
31 options.boot.loader.systemd-boot = {
32 enable = mkOption {
33 default = false;
34
35 type = types.bool;
36
37 description = "Whether to enable the systemd-boot (formerly gummiboot) EFI boot manager";
38 };
39 };
40
41 config = mkIf cfg.enable {
42 assertions = [
43 {
44 assertion = (config.boot.kernelPackages.kernel.features or { efiBootStub = true; }) ? efiBootStub;
45
46 message = "This kernel does not support the EFI boot stub";
47 }
48 ];
49
50 boot.loader.grub.enable = mkDefault false;
51
52 system = {
53 build.installBootLoader = gummibootBuilder;
54
55 boot.loader.id = "systemd-boot";
56
57 requiredKernelConfig = with config.lib.kernelConfig; [
58 (isYes "EFI_STUB")
59 ];
60 };
61 };
62}