summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nixos/bootloader.nix25
1 files changed, 21 insertions, 4 deletions
diff --git a/nixos/bootloader.nix b/nixos/bootloader.nix
index bb807cf..e2921bf 100644
--- a/nixos/bootloader.nix
+++ b/nixos/bootloader.nix
@@ -1,7 +1,5 @@
{ lib, config, ... }: let
cfg = config.boot._loader;
- usingEfi = cfg.mode == "efi";
- usingBios = cfg.mode == "bios";
in {
options.boot._loader = {
enable = lib.mkEnableOption "enable unified bootloader config";
@@ -20,17 +18,36 @@ in {
type = lib.types.str;
description = "device to install grub on";
};
+ zfsSupport = lib.mkEnableOption "zfs boot device support";
};
memtest86.enable = lib.mkEnableOption "make Memtest86+ available from the bootloader";
};
- config = lib.mkIf cfg.enable {
+ config = let
+ usingEfi = cfg.mode == "efi";
+ usingBios = cfg.mode == "bios";
+ in lib.mkIf cfg.enable {
+ assertions = [
+ {
+ assertion = cfg.loader != "grub" || !cfg.grub.zfsSupport || usingEfi;
+ message = "zfsSupport option requires using efi boot mode";
+ }
+ ];
+
boot.loader = {
grub = lib.mkIf (cfg.loader == "grub") {
enable = true;
+ # bios
+ device = lib.mkIf usingBios cfg.grub.biosDevice;
+ # efi
efiSupport = usingEfi;
efiInstallAsRemovable = usingEfi;
- device = if usingBios then cfg.grub.biosDevice else "nodev";
+ # zfs
+ zfsSupport = cfg.grub.zfsSupport;
+ mirroredBoots = lib.mkIf cfg.grub.zfsSupport [
+ { devices = [ "nodev" ]; path = "/boot"; }
+ ];
+ # misc
enableCryptodisk = true;
memtest86.enable = cfg.memtest86.enable;
};