forked from mirrors/nixpkgs
29027fd1e1
Using pkgs.lib on the spine of module evaluation is problematic because the pkgs argument depends on the result of module evaluation. To prevent an infinite recursion, pkgs and some of the modules are evaluated twice, which is inefficient. Using ‘with lib’ prevents this problem.
68 lines
1.3 KiB
Nix
68 lines
1.3 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.boot.loader.gummiboot;
|
|
|
|
efi = config.boot.loader.efi;
|
|
|
|
gummibootBuilder = pkgs.substituteAll {
|
|
src = ./gummiboot-builder.py;
|
|
|
|
isExecutable = true;
|
|
|
|
inherit (pkgs) python gummiboot;
|
|
|
|
nix = config.nix.package;
|
|
|
|
inherit (cfg) timeout;
|
|
|
|
inherit (efi) efiSysMountPoint canTouchEfiVariables;
|
|
};
|
|
in {
|
|
options.boot.loader.gummiboot = {
|
|
enable = mkOption {
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
description = "Whether to enable the gummiboot UEFI boot manager";
|
|
};
|
|
|
|
timeout = mkOption {
|
|
default = null;
|
|
|
|
example = 4;
|
|
|
|
type = types.nullOr types.int;
|
|
|
|
description = ''
|
|
Timeout (in seconds) for how long to show the menu (null if none).
|
|
Note that even with no timeout the menu can be forced if the space
|
|
key is pressed during bootup
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
assertions = [
|
|
{
|
|
assertion = (config.boot.kernelPackages.kernel.features or { efiBootStub = true; }) ? efiBootStub;
|
|
|
|
message = "This kernel does not support the EFI boot stub";
|
|
}
|
|
];
|
|
|
|
system = {
|
|
build.installBootLoader = gummibootBuilder;
|
|
|
|
boot.loader.id = "gummiboot";
|
|
|
|
requiredKernelConfig = with config.lib.kernelConfig; [
|
|
(isYes "EFI_STUB")
|
|
];
|
|
};
|
|
};
|
|
}
|