From 55829c13b551b6704242e7eaa167bba748f7ceac Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 6 Jul 2024 16:30:34 +0300 Subject: [PATCH] roles/iso: allow squashfs compression to be overriden --- modules/core/roles/iso/image/module.nix | 32 ++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/modules/core/roles/iso/image/module.nix b/modules/core/roles/iso/image/module.nix index b9bef6319..179075e07 100644 --- a/modules/core/roles/iso/image/module.nix +++ b/modules/core/roles/iso/image/module.nix @@ -5,7 +5,9 @@ lib, ... }: let - inherit (lib) cleanSource mkImageMediaOverride; + inherit (builtins) substring; + inherit (lib.sources) cleanSource; + inherit (lib.modules) mkDefault mkImageMediaOverride; in { # the ISO image must be completely immutable in the sense that we do not # want the user to be able modify the ISO image after booting into it @@ -13,15 +15,19 @@ in { system.switch.enable = false; isoImage = let - # hostname will be set as a "top-level" attribute in hosts.nix, per-host. - # therefore we can use the networking.hostName to get the hostname of the live - # system without defining it explicitly in the system-agnostic ISO role module + # `hostname` will always be defined as a "top-level" attribute in hosts.nix + # while the host is being "constructed" so to speak. Therefore we can use + # networking.hostName (instead of `meta.hostname`) to get the hostname + # of the system we are building the ISO for without hardcoding anything + # in this role module, since this is meant to be system-agnostic. Though + # at the off chance that networking.hostName is not defined, we default to + # "nixos" as the hostname to avoid errors or empty strings. hostname = config.networking.hostName or "nixos"; # if the system is built from a git repository, we want to include the git revision # in the ISO name. If the tree is dirty, we use the term "dirty" to make it explicit # and include the date in the ISO name. - rev = self.shortRev or "${builtins.substring 0 8 self.lastModifiedDate}-dirty"; + rev = self.shortRev or "${substring 0 8 self.lastModifiedDate}-dirty"; # the format of the iso will always be uniform: # $hostname-$release-$rev-$arch @@ -36,8 +42,11 @@ in { # volumeID is used is used by stage 1 of the boot process, so it must be distintctive volumeID = mkImageMediaOverride "${name}"; - # maximum compression, in exchange for build speed - squashfsCompression = "zstd -Xcompression-level 19"; # default uses gzip + # Maximum compression in exchange for speed, assuming ISOs to be built on GHA CI + # which has a 2GB limit for uploaded artifacts. Use mkDefault to allow hosts that + # import this role to override the compression options, potentially for faster builds + # or if the build host has space to spare. + squashfsCompression = mkDefault "zstd -Xcompression-level 19"; # default uses gzip # ISO image should be an EFI-bootable volume makeEfiBootable = true; @@ -48,12 +57,13 @@ in { # is this supposed to make the ISO image bootable from *CD* instead of USB? makeUsbBootable = true; - # Get rid of "installer" suffix in boot menu + # Get rid of "installer" suffix in boot menu. Not all ISO images are + # installers. appendToMenuLabel = ""; contents = [ { - # my module system already contains an option to add memtest86+ + # My module system already contains an option to add memtest86+ # to the boot menu at will but in case our system is unbootable # lets include memtest86+ in the ISO image # so that we may test the memory of the system @@ -62,10 +72,10 @@ in { target = "/boot/memtest.bin"; } { - # link this flake to /etc/nixos/flake so that the user can + # Link system flake to /root/nyx so that the user can # can initiate a rebuild without having to clone and wait # useful if this installer is meant to be used on a system - # that cannot access github + # that cannot access GitHub. source = cleanSource self; target = "/root/nyx"; }