summaryrefslogtreecommitdiff
path: root/sys/boot/chain.nix
blob: b6a9ab2004e5d1623ce25a421d9bc0f21aeacc21 (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
36
37
38
39
40
41
42
43
44
45
46
47
{
  config,
  lib,
  pkgs,
  ...
}:
with lib; let
  cfg = config.local.boot;
in {
  options.local.boot = {
    loader = mkOption {
      type = types.enum ["none" "out-of-band" "grub" "systemd-boot"];
    };

    kernel = mkOption {
      type = types.raw;
    };
  };

  config = mkIf (cfg.loader != "none") {
    boot = {
      kernelPackages = cfg.kernel;

      loader =
        if cfg.loader == "none" || cfg.loader == "out-of-band"
        then {
          grub.enable = false;
        }
        else if cfg.loader == "grub"
        then {
          grub = {
            enable = true;
            device = "nodev";
            efiSupport = true;
          };
        }
        else if cfg.loader == "systemd-boot"
        then {
          systemd-boot = {
            enable = true;
            editor = true;
          };
        }
        else throw "unexpected config.local.boot.loader setting: ${cfg.loader}";
    };
  };
}