From 77d3722c1580dc25219f590754e2e6bf34441e99 Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Sat, 3 Jan 2026 17:53:34 -0600 Subject: zfs support in bootloader --- nixos/bootloader.nix | 25 +++++++++++++++++++++---- 1 file 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; }; -- cgit v1.2.3