diff options
| author | Tim Keller <tjk@tjkeller.xyz> | 2026-01-03 17:53:34 -0600 |
|---|---|---|
| committer | Tim Keller <tjk@tjkeller.xyz> | 2026-01-03 17:53:34 -0600 |
| commit | 77d3722c1580dc25219f590754e2e6bf34441e99 (patch) | |
| tree | 26dd5100220321b0adb60ee312888802b43c38dd | |
| parent | 5586f41b100369e06f476695c88992f999e0c523 (diff) | |
| download | nixos-77d3722c1580dc25219f590754e2e6bf34441e99.tar.xz nixos-77d3722c1580dc25219f590754e2e6bf34441e99.zip | |
zfs support in bootloader
| -rw-r--r-- | nixos/bootloader.nix | 25 |
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; }; |
