From 17d2029ba21647344c389c882c1babe9848f7501 Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 24 Jun 2022 00:53:43 -0700 Subject: [PATCH] image: make the gpt headerHole configurable --- machines/moby/firmware.nix | 3 +++ modules/image.nix | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/machines/moby/firmware.nix b/machines/moby/firmware.nix index 29a30fca..a8a89ead 100644 --- a/machines/moby/firmware.nix +++ b/machines/moby/firmware.nix @@ -1,5 +1,8 @@ { config, pkgs, ... }: { + # we need space in the GPT header to place tow-boot. + # only actually need 1 MB, but better to over-allocate than under-allocate + colinsane.image.extraGPTPadding = 16 * 1024 * 1024; system.build.img = pkgs.runCommandNoCC "nixos_full-disk-image.img" {} '' cp -v ${config.system.build.img-without-firmware}/nixos.img $out chmod +w $out diff --git a/modules/image.nix b/modules/image.nix index 45134b64..5673221b 100644 --- a/modules/image.nix +++ b/modules/image.nix @@ -10,6 +10,10 @@ in default = []; type = types.listOf types.package; }; + colinsane.image.extraGPTPadding = mkOption { + default = 0; + type = types.int; + }; }; config = let # return true if super starts with sub @@ -52,8 +56,7 @@ in # leave some space for firmware # TODO: we'd prefer to turn this into a protected firmware partition, rather than reserving space in the GPT header itself # Tow-Boot manages to do that; not sure how. - # TODO: does this method work on all systems (test on lappy) - headerHole = imageBuilder.size.MiB 16; + headerHole = cfg.extraGPTPadding; partitions = [ (fsBuilderMapBoot."${bootFs.fsType}" { # fs properties