2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2013-02-02 05:03:45 +00:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2013-02-02 05:03:45 +00:00
|
|
|
|
|
|
|
let
|
2016-06-01 11:51:33 +01:00
|
|
|
cfg = config.boot.loader.systemd-boot;
|
2013-02-02 05:03:45 +00:00
|
|
|
|
|
|
|
efi = config.boot.loader.efi;
|
|
|
|
|
|
|
|
gummibootBuilder = pkgs.substituteAll {
|
2016-06-01 11:54:03 +01:00
|
|
|
src = ./systemd-boot-builder.py;
|
2013-02-02 05:03:45 +00:00
|
|
|
|
|
|
|
isExecutable = true;
|
|
|
|
|
2018-12-28 19:41:51 +00:00
|
|
|
inherit (pkgs.buildPackages) python3;
|
2016-05-31 15:52:40 +01:00
|
|
|
|
|
|
|
systemd = config.systemd.package;
|
2013-02-02 05:03:45 +00:00
|
|
|
|
2016-04-24 12:06:04 +01:00
|
|
|
nix = config.nix.package.out;
|
2013-02-02 05:03:45 +00:00
|
|
|
|
2016-05-25 09:34:54 +01:00
|
|
|
timeout = if config.boot.loader.timeout != null then config.boot.loader.timeout else "";
|
2013-02-02 05:03:45 +00:00
|
|
|
|
2017-01-21 13:24:26 +00:00
|
|
|
editor = if cfg.editor then "True" else "False";
|
|
|
|
|
2018-07-02 17:21:51 +01:00
|
|
|
inherit (cfg) consoleMode;
|
|
|
|
|
2013-02-21 17:33:54 +00:00
|
|
|
inherit (efi) efiSysMountPoint canTouchEfiVariables;
|
2013-02-02 05:03:45 +00:00
|
|
|
};
|
|
|
|
in {
|
2016-06-01 11:51:33 +01:00
|
|
|
|
|
|
|
imports =
|
|
|
|
[ (mkRenamedOptionModule [ "boot" "loader" "gummiboot" "enable" ] [ "boot" "loader" "systemd-boot" "enable" ])
|
|
|
|
];
|
|
|
|
|
|
|
|
options.boot.loader.systemd-boot = {
|
2013-02-02 05:03:45 +00:00
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
|
|
|
|
type = types.bool;
|
|
|
|
|
2016-05-31 15:52:40 +01:00
|
|
|
description = "Whether to enable the systemd-boot (formerly gummiboot) EFI boot manager";
|
2013-02-02 05:03:45 +00:00
|
|
|
};
|
2017-01-21 13:24:26 +00:00
|
|
|
|
|
|
|
editor = mkOption {
|
|
|
|
default = true;
|
|
|
|
|
|
|
|
type = types.bool;
|
|
|
|
|
|
|
|
description = ''
|
|
|
|
Whether to allow editing the kernel command-line before
|
|
|
|
boot. It is recommended to set this to false, as it allows
|
|
|
|
gaining root access by passing init=/bin/sh as a kernel
|
|
|
|
parameter. However, it is enabled by default for backwards
|
|
|
|
compatibility.
|
2017-01-21 13:42:10 +00:00
|
|
|
'';
|
2017-01-21 13:24:26 +00:00
|
|
|
};
|
2018-07-02 17:21:51 +01:00
|
|
|
|
|
|
|
consoleMode = mkOption {
|
|
|
|
default = "keep";
|
|
|
|
|
|
|
|
type = types.enum [ "0" "1" "2" "auto" "max" "keep" ];
|
|
|
|
|
|
|
|
description = ''
|
|
|
|
The resolution of the console. The following values are valid:
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem><para>
|
|
|
|
<literal>"0"</literal>: Standard UEFI 80x25 mode
|
|
|
|
</para></listitem>
|
|
|
|
<listitem><para>
|
|
|
|
<literal>"1"</literal>: 80x50 mode, not supported by all devices
|
|
|
|
</para></listitem>
|
|
|
|
<listitem><para>
|
|
|
|
<literal>"2"</literal>: The first non-standard mode provided by the device firmware, if any
|
|
|
|
</para></listitem>
|
|
|
|
<listitem><para>
|
|
|
|
<literal>"auto"</literal>: Pick a suitable mode automatically using heuristics
|
|
|
|
</para></listitem>
|
|
|
|
<listitem><para>
|
|
|
|
<literal>"max"</literal>: Pick the highest-numbered available mode
|
|
|
|
</para></listitem>
|
|
|
|
<listitem><para>
|
|
|
|
<literal>"keep"</literal>: Keep the mode selected by firmware (the default)
|
|
|
|
</para></listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
'';
|
|
|
|
};
|
2013-02-02 05:03:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
assertions = [
|
|
|
|
{
|
2013-03-03 22:48:33 +00:00
|
|
|
assertion = (config.boot.kernelPackages.kernel.features or { efiBootStub = true; }) ? efiBootStub;
|
2013-02-02 05:03:45 +00:00
|
|
|
|
|
|
|
message = "This kernel does not support the EFI boot stub";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2014-04-30 10:41:39 +01:00
|
|
|
boot.loader.grub.enable = mkDefault false;
|
|
|
|
|
2017-04-02 19:51:09 +01:00
|
|
|
boot.loader.supportsInitrdSecrets = true;
|
|
|
|
|
2013-02-02 05:03:45 +00:00
|
|
|
system = {
|
|
|
|
build.installBootLoader = gummibootBuilder;
|
|
|
|
|
2016-06-01 11:51:33 +01:00
|
|
|
boot.loader.id = "systemd-boot";
|
2013-02-02 05:03:45 +00:00
|
|
|
|
|
|
|
requiredKernelConfig = with config.lib.kernelConfig; [
|
|
|
|
(isYes "EFI_STUB")
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|